Q: Rails options for select send nil when no option selected I have the following code in my rails app:
<%= select :object,
           :id,
           options_for_select(Hash[@object_list.map { |object| [object.name, object.id] }]),
           {:include_blank => 'Please select...'},
           {} %>

If no option is selected then in my controller I receive an empty string. 

How can I make the options for select send 'nil' value instead?

A: You should use before_action callback for your controller.
class SomeController
  before_action :prepare_params

  private

  def prepare_params
    params[:your_param] = nil if params[:your_param].blank?
  end
end


A: I think you can achieve that by inserting nil in your list.
<%= select :object,
           :id,
           options_for_select(Hash[@object_list.map { |object| [object.name, object.id] }].merge({:0 => nil}), selected: 0) %>

