title: Ruby class 'split' not working
body: <p>I'm trying to use the split class to split up an array. I keep getting this error:</p>
  
  <pre><code>MethodError (undefined method `split' for nil:NilClass):
  </code></pre>
  
  <p>This is what I'm trying to do:
   def create</p>
  
  <pre><code>    @listing.landlord = current_landlord
      if @listing.save
        photo_id_array = params[:images].split(/,/)
        photo_id_array.each do |image|
          @image = Photo.find_by_id("photo.id")
          @image.listing_id = @listing.id
        end
        render :show, :status =&gt; 200
      else
        render :status =&gt; 403, :json =&gt; {:errors =&gt; @listing.errors}
      end
    end
  </code></pre>
  
  <p>I'm running Rails 3.2.9. Any ideas into what may be causing this?</p>
  
  <p>Edit: </p>
  
  <p>Here is the full post:</p>
  
  <pre><code>Started POST "/listings" for 127.0.0.1 at 2012-12-12 01:04:52 -0800
  Processing by ListingsController#create as application/json; charset=utf-8
    Parameters: {"listing"=&gt;{"street_address"=&gt;"123 main st", "city"=&gt;"los angeles", "state"=&gt;"ca", "availability"=&gt;"12 Dec 2012", "price"=&gt;"2000", "period"=&gt;"2", "category"=&gt;"1", "cats"=&gt;"false", "dogs"=&gt;"false", "square_footage"=&gt;"0", "bedrooms"=&gt;"3", "bathrooms"=&gt;"2", "short_description"=&gt;"tree-lined street", "long_description"=&gt;"big yard", "images"=&gt;["70621", "70622", "70620"]}, "auth_token"=&gt;"6489Cn7KeTmejSxaWsws"}
  WARNING: Can't verify CSRF token authenticity
    User Load (1.6ms)  SELECT "users".* FROM "users" WHERE "users"."authentication_token" = '6489Cn7KeTmejSxaWsws' LIMIT 1
    Landlord Load (0.6ms)  SELECT "landlords".* FROM "landlords" WHERE "landlords"."authentication_token" = '6489Cn7KeTmejSxaWsws' LIMIT 1
    Role Load (0.5ms)  SELECT "roles".* FROM "roles" WHERE "roles"."name" = 'admin' LIMIT 1
    Role Exists (0.7ms)  SELECT 1 AS one FROM "roles" INNER JOIN "landlords_roles" ON "roles"."id" = "landlords_roles"."role_id" WHERE "landlords_roles"."landlord_id" = 5867 AND "roles"."id" = 1 LIMIT 1
  Completed 500 Internal Server Error in 275ms
  
  NoMethodError (undefined method `split' for nil:NilClass):
    app/controllers/listings_controller.rb:8:in `create'
  
  
    Rendered /Users/rigelstpierre/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.9ms)
    Rendered /Users/rigelstpierre/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.1ms)
    Rendered /Users/rigelstpierre/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (16.9ms)
  </code></pre>