ruby on rails - Boolean attribute not being saved via check_box -
i have job model attribute of :rush boolean. used check_box form helper toggle :rush.
the check box form element:
<%= check_box_tag(:rush) %> <%= label_tag(:rush, "rush?") %>
my strong parameters method:
def job_params params.require(:job).permit(:recipient, :age, :ethnicity, :gender, :height, :weight, :hair, :eyes, :other_info, :instructions, :user_id, :company_id, :case_id, :rush, addresses_attributes:[:id, :label, :addy, :apt, :city, :state, :zip ] ) end
the create action:
def create @job = job.new(job_params) @job.user_id = current_user.id if @job.save redirect_to current_user else render 'new' end end
when form submitted, doesn't save :rush yet other attributes including nested attributes save fine. missing here?
since function says:
params.require(:job).permit(:recipient, :age, :ethnicity, :gender, :height, :weight, :hair, :eyes, :other_info, :instructions, :user_id, :company_id, :case_id, :rush, addresses_attributes:[:id, :label, :addy, :apt, :city, :state, :zip ] )
then expecting :rush
nested inside :job
, is, params[:job][:rush]
. should nest inside job
attribute in html:
<%= check_box_tag("job[rush]") %>
this should work.
Comments
Post a Comment