0

For some reason when I ran rails generate resource admin on my new Rails app, Rails generated a resource called admins. Is there any reason for it doing this? I would like the resource to be called admin, not admins.

Here is the output of running rails generate resource admin:

invoke  active_record
create    db/migrate/20130117002055_create_admins.rb
create    app/models/admin.rb
invoke    test_unit
create      test/unit/admin_test.rb
create      test/fixtures/admins.yml
invoke  controller
create    app/controllers/admins_controller.rb
invoke    erb
create      app/views/admins
invoke    test_unit
create      test/functional/admins_controller_test.rb
invoke    helper
create      app/helpers/admins_helper.rb
invoke      test_unit
create        test/unit/helpers/admins_helper_test.rb
invoke    assets
invoke      coffee
create        app/assets/javascripts/admins.js.coffee
invoke      scss
create        app/assets/stylesheets/admins.css.scss
invoke  resource_route
route    resources :admins
  • Do you actually have a resource called admin? Or is this more of an area that you plan to use to administrate the site? If it's the latter, you may want a namespace instead. – Mark Swardstrom Jan 17 '13 at 00:52
  • This is expected. By convention, Rails assumes `admin` is the name of a _single_ resource—you'll notice it created an `Admin` model (singular). It sounds to me like you don't actually want admin to be a resource, but a custom route. – pje Jan 17 '13 at 00:53

1 Answers1

2

Rails follows a plural naming convention by default if you wish to override this you can use custom inflection rules or edit the enviroment.rb file both ways can be found in "How do I override rails naming conventions?".

Community
  • 1
  • 1
Jesse Whitham
  • 824
  • 9
  • 32