Q:

Rails Form Helper not reading question mark for object attribute

Ruby Version: 2.0
Rails Version: 4.0
I have a controller Question, which has an embedded form for a model Answer.
question.rb
class Question < ActiveRecord::Base
    has_many :answers, :dependent => :destroy
    accepts_nested_attributes_for :answers, :allow_destroy => true
end

answer.rb
class Answer < ActiveRecord::Base
    belongs_to :question
end

answers migration
class CreateAnswers < ActiveRecord::Migration
  def change
    create_table :answers do |t|
      t.string :text
      t.integer :question_id
      t.boolean :correct?

      t.timestamps
    end
  end
end

in the form, when editing or creating a new question - the user may enter up to 4 possible answers, and mark a check box for the "correct" answer(s).
/views/questions/_form.html.erb
<%= form_for(@question) do |f| %>
  <div class="field">
    <%= f.label :text %><br>
    <%= f.text_area :text %>
  </div>

  <p>Enter up to 4 posisble answer choices.</p>
  <%= f.fields_for :answers do |answer| %>
    <div class="field">
      <%= answer.text_field :text %>
      <%= answer.check_box :correct? %>
    </div>
  <% end %>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

relevant snippets from questions_controller.rb
def new
    @question = Question.new
    4.times { @question.answers.build }
  end

private
    # Use callbacks to share common setup or constraints between actions.
    def set_question
      @question = Question.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def question_params
      params.require(:question).permit(:text, :quiz_id, answers_attributes: [:id, :text, :correct?])
    end

Finally - on to my problem
Everything listed above worked perfectly until I added the checkboxes for answer.correct?. When I submit the form as is I get this message in my logs:
Unpermitted parameters: correct
Unpermitted parameters: correct
Unpermitted parameters: correct
Unpermitted parameters: correct

Weird... there is definitely a question mark at the end of that parameter. Allowing this to pass through without the question mark be editing the allowed parameters in the controller gets me this error message:
unknown attribute: correct (this one actually throws an error message, I don't have to go digging in the logs to find this.)
How do I get the form helper to read the question mark?

A:

? is not a valid character for inclusion within a column name. First, create a new database migration:
# from command line
rails generate migration ChangeCorrectInAnswers

Rename your column from correct? to correct:
# in the resulting migration
class ChangeCorrectInAnswers < ActiveRecord::Migration
  def up
    rename_column :answers, :correct?, :correct
  end
end

Run the migration:
# from command line
rake db:migrate

Finally, remove the ? from your field in the view:
# app/views/questions/_form.html.erb
<%= answer.check_box :correct %>

