Search code examples
ruby-on-railsrails-activerecordplural

Rails 3: Routing and pluralization issue for has_one


I created a scaffold for Etho, where I am attempting to have a User get 1 single "ethos" to edit. Ethos was working but on the User model it was only working with has_many :ethos

The user should only get 1 so I can create better associations. But now when I change in the model, it creates quite the spider effect that I can't track down.

User model:

class User < ActiveRecord::Base
  has_many :jobs
  has_one  :ethos #used to be has_many :ethos

On all the pages now I get uninitialized constant User::Ethos on EthosController#edit

Please help, how do I fix this?


Solution

  • Have you tried?

    class User < ActiveRecord::Base
      has_many :jobs
      has_one  :etho 
    

    has_one should be singular: http://guides.rubyonrails.org/association_basics.html#the-has_one-association