ruby on rails - Paperclip DB storage: Attachments go in, but don't come out -


irb(main):001:0> e = event.last => #<event id: 7, address: "123 main st", start_date: "2011-02-09", start_time: "2000-01-01 14:49:00", title: "test event", poster_file: "\377���jfif\000\001\002\000\000d\000d\000\000\377�ducky\000\001\000\004\000\000\0002\000\000\377�!adobe\000d�...", poster_thumb_file: nil, created_at: "2011-02-09 14:49:45", updated_at: "2011-02-09 14:49:45", poster_file_name: nil, poster_content_type: "image/jpeg", poster_file_size: 134218, poster_updated_at: "2011-02-09 14:49:44"> irb(main):002:0> e.poster.url => "/posters/original/missing.png?1297262984" 

i using fork of paperclip gem pat shaughnessy. have tried, , gotten same problem fork found here, pretty sure me doing stupid. app hosted on heroku. followed the instructions of person forked paperclip , tried adapt them rails 3. route poster looks this:

resources :events   member     :poster   end end 

and in controller have:

class eventscontroller < applicationcontroller          downloads_files_for :event, :poster ... end 

and model:

class event < activerecord::base   attr_accessor :poster_thumb_file, :poster_file_name   has_attached_file :poster, :storage => :database, :styles => {:thumb => { :geometry => "100x100>", :column => 'poster_thumb_file'}} end 

i can't figure out missing these images display. advice appreciated!

try plural "posters" in routes file:

resources :events   member     :posters   end end 

the downloads_files_for method assumes plural attachment name in url; see: https://github.com/patshaughnessy/paperclip/blob/master/lib/paperclip/storage/database.rb#l190

if want use "poster" , not "posters" in url you'll have write controller action manually. it's event.find... , call send_data event.poster.file_contents , pass type , filename also.

did fix it? - pat


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -