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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -