jendiamond / railsgirls-signup

https://railsgirls-signup.herokuapp.com
3 stars 3 forks source link

Fix Coaches show page #77

Closed jendiamond closed 7 years ago

jendiamond commented 7 years ago

Pull Request #78

I should have made the questions about coaching booleans not strings.

Adding new fields.

$ rails g migration AddCoachedToCoaches coach_april_13:boolean

class AddCoachedToCoaches < ActiveRecord::Migration[5.0]
  def change
    add_column :coaches, :coach_april_13_pivotal, :boolean
    add_column :coaches, :coach_march_14_invpasadena, :boolean
    add_column :coaches, :coach_april_15_pivotal, :boolean
    add_column :coaches, :coach_august_15_spokeo, :boolean
    add_column :coaches, :coach_march_16_zest, :boolean
    add_column :coaches, :work_at_sponsoring_company, :boolean
  end
end

Neither the check boxes nor the radio buttons save. I tried it these ways and the responses did not save so I deleted them for now.

<%= f.input :coached_april_13, label: "I coached RailsGirlsLA on April 2013 at Pivotal", as: :radio_buttons %>
<%= f.input :coached_april_13, label: "I coached RailsGirlsLA on April 2013 at Pivotal", required: true, as: :radio_buttons %>
<%= f.input :coached_april_13, label: "I coached RailsGirlsLA on April 2013 at Pivotal" %>


The solution

I needed to add the new params to the whitelist in the coach_controller

http://stackoverflow.com/questions/32362039/checkbox-items-not-saving-simple-form

    def coach_params
      params.require(:coach).permit(:first_name, :last_name, :email, :twitter, 
        :github, :job, :student1, :student2, :attended_as_student, :coached_april_13, 
        :coached_march_14, :coached_april_15, :coached_august_15, :coached_march_16, :notes,
        :days, :operating_system, :phone, :spokeo)
    end