I have two models:- a) A b) B
model A looks like this:-
class A < ActiveRecord::Base
has_many :bs ,:dependent => :destroy
validates :name, :presence=>true
accepts_nested_attributes_for :bs
attr_accessible :bs_attributes
end
model B looks like this
class PlanDay < ActiveRecord::Base
belongs_to :a
attr_accessible :a_attributes
end
In my view I have used form_for and fields_for, but I am confused in the parameter that I am getting:-
Parameters: {"a"=>{"name"=>"swsdw" , "bs_attributes"=>{"0"=>{"friday"=>"true", "wednesday"=>"", "tuesday"=>"", "sunday"=>"true", "saturday"=>"true", "monday"=>"", "thursday"=>""}}
What is this 0 I am getting in bs_attributes? Is this the reason that I am not able to save the values of my days in 'bs' table?
I am saving this as follow:- @a = A.new(params[:a])
and this is saving my both the models are getting saved , but the all the days that are present in parameters are getting saved with null.