Wednesday, 18 September 2013

Rails: js.erb for nested attributes

Rails: js.erb for nested attributes

I'm pretty familiar with ajax now but I'm a little confused as to how I
can render js for a nested attribute. Here's my setup
#Post Model
has_many images
accepts_nested_attributes_for :images, allow_destroy: true
#Image Model
belongs_to :post
#Images/create.js.erb
#alert me
#form for post
<%= f.fields_for :images, Image.new do |m| %>
#some drag & drop fields here
<% end %>

No comments:

Post a Comment