← Back to Upcase

Paperclip console command for Rails 4


(Shankar Dhanasekaran) #1

I want to upload paperclip files in console mode. In rails 3, I tried this http://stackoverflow.com/questions/4680265/paperclip-how-to-store-a-picture-in-a-rails-console and it worked.

YourPaperclippedModelHere.new(:your_paperclip_field => File.new(path,
“r”))

However, in Rails4, when I try this, I get

ActiveRecord::UnknownAttributeError: unknown attribute: your_paperclip_field

I am using the master branch of paperclip.


(Jaroslav Janukevic) #2

My guess would be, because of strong_params in Rails 4. You need to add

private
  def paperclip_model_parameters
    params.require(:parperclip_model_name).permit(:your_paperclip_field)
  end