form_for [@parent,@son],:remote=>true not asking for JS
- by Cibernox
Hi.
I have a plain old form. That form is used to create new objects of a nested model.
#restaurant.rb
has_many :courses
#courses.rb
belongs_to :restaurant
#routes.rb
resources :restaurants do
resources :courses
end
In my views(in haml), i have that code:
%li.course{'data-random'=>random}
= form_for([restaurant,course], :remote=>true) do |f|
.name= f.text_field :name, :placeholder=>'Name here'
.cat= f.hidden_field :category
.price= f.text_field :price,:placeholder=>'Price here'
.save
= hidden_field_tag :random,random
= f.submit "Save"
I espected that form to be answered by action create of courses_controller with JS (create.js.erb), but it is submited like a normal form, and is answered with html.
What am I doing wrong? This problem is similar to this but the only answer don't make sense to me.
Thanks
Inside