Question

I created this form using the following scaffold

rails generate scaffold Adminlocations city:string state:string zip:integer long:integer lat:integer

when i go to enter a new location into the form i get the following error: (i dont see a "join" anywhere in the coding)

2014-04-30 08:15:21 INFO -- Processing by AdminlocationsController#create as HTML
2014-04-30 08:15:21 INFO --   Parameters: {"utf8"=>"✓", "authenticity_token"=>"U27TufEFF9UYznNMB/OzkEIEPSSBScKqPH/MOdzC9kQ=", "adminlocation"=>{"city"=>"Springfield", "state"=>"Mo", "zip"=>"65803", "long"=>"123", "lat"=>"123"}, "commit"=>"Create Adminlocation"}
2014-04-30 08:15:21 INFO -- Redirected to 
2014-04-30 08:15:21 INFO -- Completed 500 Internal Server Error in 539ms
2014-04-30 08:15:21 FATAL -- 
NoMethodError (undefined method `join' for nil:NilClass):
  app/controllers/adminlocations_controller.rb:40:in `block (2 levels) in create'
  app/controllers/adminlocations_controller.rb:38:in `create'


2014-04-30 08:15:21 INFO -- Processing by InfoController#error as HTML
2014-04-30 08:15:21 INFO --   Parameters: {"utf8"=>"✓", "authenticity_token"=>"U27TufEFF9UYznNMB/OzkEIEPSSBScKqPH/MOdzC9kQ=", "adminlocation"=>{"city"=>"Springfield", "state"=>"Mo", "zip"=>"65803", "long"=>"123", "lat"=>"123"}, "commit"=>"Create Adminlocation"}
2014-04-30 08:15:21 INFO --   Rendered info/error.html.haml within layouts/application (0.3ms)
2014-04-30 08:15:22 INFO --   Rendered shared/_navbar.html.haml (300.7ms)
2014-04-30 08:15:22 INFO --   Rendered shared/_footer.html.haml (0.3ms)
2014-04-30 08:15:22 INFO -- Completed 200 OK in 617ms (Views: 30.5ms | ActiveRecord: 575.7ms)
2014-04-30 08:15:22 INFO --

this is the corrisponding block in controller

  def create
    @adminlocation = Adminlocation.new(params[:adminlocation])
    respond_to do |format|
      if @adminlocation.save
        format.html { redirect_to @adminlocation, notice: 'Adminlocation was successfully created.' }
        format.json { render json: @adminlocation, status: :created, location: @adminlocation }
      else
        format.html { render action: "new" }
        format.json { render json: @adminlocation.errors, status: :unprocessable_entity }
      end
    end
  end

this is the output from generating the form:

[root@digihaul3-pc current]# rails generate scaffold Adminlocations city:string state:string zip:integer long:integer lat:integer
        SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
        This poses a security threat. It is strongly recommended that you
        provide a secret to prevent exploits that may be possible from crafted
        cookies. This will not be supported in future versions of Rack, and
        future versions will even invalidate your existing user cookies.

        Called from: /home/deployer/loadmax/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

Plural version of the model detected, using singularized version. Override with --force-plural.
      invoke  active_record
      create    db/migrate/20140429172723_create_adminlocations.rb
      create    app/models/adminlocation.rb
      invoke    test_unit
      create      test/unit/adminlocation_test.rb
      create      test/fixtures/adminlocations.yml
       route  resources :adminlocations
      invoke  scaffold_controller
      create    app/controllers/adminlocations_controller.rb
      invoke    erb
      create      app/views/adminlocations
      create      app/views/adminlocations/index.html.erb
      create      app/views/adminlocations/edit.html.erb
      create      app/views/adminlocations/show.html.erb
      create      app/views/adminlocations/new.html.erb
      create      app/views/adminlocations/_form.html.erb
      invoke    test_unit
      create      test/functional/adminlocations_controller_test.rb
      invoke    helper
      create      app/helpers/adminlocations_helper.rb
      invoke      test_unit
      create        test/unit/helpers/adminlocations_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/adminlocations.js.coffee
      invoke    scss
      create      app/assets/stylesheets/adminlocations.css.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.css.scss

I had to make the database manually and give it the right permissions

Requested Info

class Adminlocation < ActiveRecord::Base
  attr_accessible :city, :lat, :long, :state, :zip
end
Was it helpful?

Solution

try:

rails generate scaffold Adminlocation city:string state:string zip:integer long:integer lat:integer

in rails generate scaffold you give the model name. The model name should be always singular! (look at your error msg)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top