title: rails 3.2 NoMethodError undefined method `slice' for nil:NilClass
body: <p>i am getting this error end have no clue how to fix it. the weird thing is, it was working before. i think after i run annotate, it is broken, but not sure.
  the error comes from confs.controller index and own methods.
  it also rejects something like this: conf.machine_brand[0,1].upcase as NoMethodError [ ] bla bla 
  this is my conf model:</p>
  
  <pre><code># == Schema Information
  #
  # Table name: confs
  #
  #  id                 :integer          not null, primary key
  #  machine_brand      :string(255)
  #  machine_model      :string(255)
  #  control_unit_brand :string(255)
  #  control_unit_model :string(255)
  #  tool_axis_x        :decimal(, )
  #  tool_axis_y        :decimal(, )
  #  tool_axis_z        :decimal(, )
  #  rotary_axis_number :integer
  #  linear_axis_number :integer
  #  turning_mode       :boolean
  #  milling_mode       :boolean
  #  description        :text
  #  xml                :text
  #  user_id            :integer
  #  developer_id       :integer
  #  created_at         :datetime         not null
  #  updated_at         :datetime         not null
  #
  
  class Conf &lt; ActiveRecord::Base
     attr_accessible :linear_axis_number, :control_unit_brand, :control_unit_model, :description, :developer_id, :machine_brand, :machine_model, :milling_mode, :rotary_axis_number, :tool_axis_x, :tool_axis_y, :tool_axis_z, :turning_mode, :user_id, :xml 
  
     belongs_to :developer, :class_name =&gt; 'User', :foreign_key =&gt; 'developer_id'
     belongs_to :receiver, :class_name =&gt; 'User', :foreign_key =&gt; 'user_id'
  
     validates :user_id, presence: true
     validates :developer_id, presence: true
  end
  </code></pre>
  
  <p>this is confs.controller:</p>
  
  <pre><code>class ConfsController &lt; ApplicationController
  before_filter  :signed_in_user, only:[:index, :edit, :update, :destroy]
  before_filter  :developer_user, only: :destroy
  
  def new
    @conf = Conf.new
  end
  
  def index
    @grouped = {}
    Conf.all.each do |conf|
      letter = conf.machine_brand.slice(0,1).upcase
      @grouped[letter] ||= []
      @grouped[letter] &lt;&lt; conf
  end
  end
  
  def show
  @conf = Conf.find(params[:id])
  
  respond_to do |format|
      format.html #index.html.erb
      format.json { render json: @conf }
      format.xml { render xml: @conf }  
    end
  end
  
  def own
    @grouped = {}
    Conf.where(:developer_id =&gt; current_user.id).each do |conf|
      letter = conf.machine_brand.slice(0,1).upcase
      @grouped[letter] ||= []
      @grouped[letter] &lt;&lt; conf
    end
  end
  
  def create
  @conf = Conf.new(conf_params)
  
    if @conf.save
      flash[:success] = "New Configuration uploaded!"
      redirect_to conf_show_path
    else
      flash[:error] = "There is a problem!"
      render 'new'
    end
  end
  
  def destroy
    @conf = Conf.find(params[:id]).destroy
    redirect_to conf_show_own_path
  end
  
  def update
    @conf.update_attributes(params[:conf])  
  end
  
  private
  
  def signed_in_user
    unless signed_in?
      store_location
      redirect_to signin_url, notice: "Please sign in"    
    end
  end
  
  def admin_user
    redirect_to(root_path) unless current_user.admin?
  end
  
  def developer_user
    redirect_to(root_path) unless current_user.developer?
  end
  
  def conf_params
    params.require(:conf).permit(:xml, :user_id, :developer_id) if params[:conf]
  end
  
  end
  </code></pre>
  
  <p>and this is conf.new if you wish:</p>
  
  <pre><code>&lt;% provide(:title, 'New Configuration')%&gt;
  &lt;h1&gt; Upload new configuration &lt;/h1&gt;
  
  &lt;div class="row"&gt;
    &lt;div class="span6 offset3"&gt;
  
       &lt;%= form_for @conf, :html =&gt; {:multipart =&gt; true} do |f| %&gt;
  
      &lt;%= f.label :machine_brand %&gt;
      &lt;%= f.text_field :machine_brand %&gt;
  
      &lt;%= f.label :machine_model %&gt;
      &lt;%= f.text_field :machine_model %&gt;
  
      &lt;%= f.label :control_unit_brand %&gt;
      &lt;%= f.text_field :control_unit_brand %&gt;
  
      &lt;%= f.label :control_unit_model %&gt;
      &lt;%= f.text_field :control_unit_model %&gt;
  
      &lt;%= f.label :tool_axis_x %&gt;
      &lt;%= f.text_field :tool_axis_x %&gt;
  
      &lt;%= f.label :tool_axis_y %&gt;
      &lt;%= f.text_field :tool_axis_y %&gt;
  
      &lt;%= f.label :tool_axis_z %&gt;
      &lt;%= f.text_field :tool_axis_z %&gt;
  
      &lt;%= f.label :rotary_axis_number %&gt;
      &lt;%= f.text_field :rotary_axis_number %&gt;
  
      &lt;%= f.label :linear_axis_number %&gt;
      &lt;%= f.text_field :linear_axis_number %&gt;
  
      &lt;%= f.label :turning_mode %&gt;
      &lt;%= f.text_field :turning_mode %&gt;
  
      &lt;%= f.label :milling_mode %&gt;
      &lt;%= f.text_field :milling_mode %&gt;
  
      &lt;%= f.label :description %&gt;
      &lt;%= f.text_field :description %&gt;
  
      &lt;%= f.label :xml %&gt;
      &lt;%= f.text_field :xml %&gt;
  
      &lt;%= f.label :client %&gt;
      &lt;%= f.collection_select :user_id, User.where(:admin =&gt; false, :developer =&gt; false), :id, :name, options ={:prompt =&gt; "Select a client"}, :class =&gt;"user" %&gt;
  
      &lt;%= f.label :me %&gt;
      &lt;%= f.collection_select :developer_id, User.where(:id =&gt; current_user.id), :id, :name, options ={:prompt =&gt; "Select me"}, :class =&gt;"user" %&gt;
  
  &lt;br /&gt;
      &lt;%= f.submit "Upload", class: "btn btn-large btn-primary" %&gt;
  &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>