I'm using rails 3.2.3 and am having issues with mass assignement.
I have a Hotel model and a Hphoto model (integrated with paperclip)
I have tried almost everything and still get mass-assignement error.
---------------------------------------------------------------
Hotel model
has_many :hphotos, :dependent=>:destroy
accepts_nested_attributes_for <other models>, :hphotos
attr_accessible: <other attributes>, :hphoto_attributes
---------------------------------------------------------------
Hphoto model
belongs_to :hotel
has_attached_file :photo,
:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
:url => "/system/:attachment/:id/:style/:filename"
attr_accessible :hphoto_attributes
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 2.megabytes
validates_attachment_content_type :photo, :content_type=> ['image/jpeg',
'image/png']
---------------------------------------------------------------
My hotel controller:
def new
@hotel = Hotel.new
@hotel.hphotos.build
respond_to do |format|
format.html
format.json { render :json => @hotel }
end
end
def create
@hotel = Hotel.new(params[:hotel])
<original scaffold code>
end
---------------------------------------------------------------
Thanks for your thoughts, this seems so simple yet I can't fix it
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.