Hi,
I am new to rails. Any support from your side would be very helpful.
I have a model called child and another model called childcategory. I
have given the code in app/views/children/show.html.erb of child.
<% remote_form_for [@child, Childcategory.new] do |f| %>
<%= f.label :body, " Allowed Categories " %>
<% for category in @cat do %>
<%= check_box 'checkbox', category.categoryname %> <%=
category.categoryname %>
<% end %>
<%= f.submit "Update Settings" %>
<% end %>NOw the check boxes are displayed from another model called
Filtercategory. When the user checks a check box in the above view, i
want the check box value to be inserted in a model called Childcategory.
The controller code is as follows.
app/controllers/childcategories_controller.rb
class ChildcategoriesController < ApplicationController
def create
@child = Child.find(params[:child_id])
@catlist = @child.childcategories.create!(params[:childcategory])
respond_to do |format|
format.html { redirect_to @child }
format.js
end
end
end
But when i submit the “Update Settings” button, a new record is created
with childid but the category name in the check box is not saved in the
table.
Can you say whats the issue. I couldnt solve this.
Any suggestion would be really supportive.