I am using Paperclip for image upload in a Rails 3.2 app. The goal is to show users every time they create a new post, a different (randomly changing) default image, before they upload their own image.
I found this and this questions here, but unfortunately the solutions don't work for me.
This is the post.rb model:
has_attached_file :image, styles: { medium: "320x240>"}
validates_attachment :image,
content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png'] },
size: { less_than: 2.megabytes }
belongs_to :user
has_attached_file :image, styles: { thumb: "100x100", small: "160x120", medium: "320x240>", large: "640x480", fullscreen: "1000x300#" },
:default_url => '/assets/1.jpg'
Instead of :default_url => '/assets/1.jpg'
I would like to set something that shows randomly one of the ten images (1.jpg to 10.jpg).
If I try to use :default_url => lambda {'/assets/#{rand(5)}.jpg'}
I get this Error:
ArgumentError in Posts#new - wrong number of arguments (1 for 0)