hello, I have a model (item) with one attachment (photo) and one style (small): class Producto < ActiveRecord::Base has_attached_file :photo, :styles => { :small => "50x50"}, end I would like to add a new style (:large), so I modify item.rb: class Producto < ActiveRecord::Base has_attached_file :photo, :styles => {{ :small => "50x50"},{ :large => "150x150"}} end it seems to be ok, but when I submit in edit or new views, I get the following error: NoMethodError (undefined method `[]'' for nil:NilClass): app/controllers/admin/items_controller.rb:64:in `update'' app/controllers/admin/items_controller.rb:63:in `update'' Controller code: def update @item = Item.find(params[:id]) respond_to do |format| if @item.update_attributes(params[:item]) format.html { redirect_to(admin_items_path, :notice => ''OK'') } else format.html { render :action => "edit" } end end end If I remove the new style (:large) in item.rb everything works fine again... Could someone help me? Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Not sure, but have you tried using the syntax from the docs, particularly the last example? https://github.com/thoughtbot/paperclip/wiki/Usage I wonder if yours is valid Ruby but invalid has_attached_file syntax. On Jan 3, 10:34 am, Daniel Oton <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> class Producto < ActiveRecord::Base > has_attached_file :photo, :styles => {{ :small => "50x50"},{ :large => > "150x150"}} > end > > it seems to be ok, but when I submit in edit or new views, I get the > following error: > > NoMethodError (undefined method `[]'' for nil:NilClass):-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I changed the following according with documentation: has_attached_file :photo, :styles => { :small => {:geometry => ''50x50#''}, :large => {:geometry => ''150x150#''} } And it works! Using syntax from the docs seems to be a very good idea! :-) Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.