1

I have a model which takes an image called meal. I want to make sample data for every new account on the website, and then it will be automatically deleted after a certain number of logins.

How do I set the paperclip field :image in my meal model to store just the URL of the sample image instead of uploading a new one every time? I don't want to make a separate field in my model just for the path to the sample image, but I want to use the paperclip field image that I already have.

From the console I use this command to create sample data:

a = Meal.new(:image => File.new("#{Rails.root}/public/images/BagelCreamCheese_14.jpg", "r"), :category_of_foods => ["bagel"], :type_of_meal => "breakfast")

How can I simply store the URL for future sample data that will point to the same image like:

a = Meal.new(:image => "#{Rails.root}/public/images/BagelCreamCheese_14.jpg", :category_of_foods => ["bagel"], :type_of_meal => "breakfast")
# gives me a "No Handler Error"
achabacha322
  • 651
  • 10
  • 32

1 Answers1

0

Probably not possible, so I just ended up using the default_url to display a generic image for my sample data.

achabacha322
  • 651
  • 10
  • 32