Ruby on Rails Saturday, March 31, 2012

On 29 March 2012 17:17, bingo bob <lists@ruby-forum.com> wrote:
> Schema attached..
>
> model summaries...
>
> class Name < ActiveRecord::Base
>
>  attr_accessible :given, :gender, :position
>
>  has_many :user_names
>  has_many :users, :through => :user_names
>
>
> class UserNames < ActiveRecord::Base
>  belongs_to :user
>  belongs_to :name
>
>
> class User < ActiveRecord::Base
>  # Include default devise modules. Others available are:
>  # :token_authenticatable, :encryptable, :confirmable, :lockable,
> :timeoutable and :omniauthable
>  devise :database_authenticatable, :registerable,
>         :recoverable, :rememberable, :trackable, :validatable
>
>  has_many :user_names
>  has_many :names, :through => :user_names
> ...
> So with all that in place and data mover run console gives me errors...
>
> ruby-1.9.2-p290 :006 > User.first.names
>  User Load (1.4ms)  SELECT "users".* FROM "users" ORDER BY
> lower(username) ASC LIMIT 1
> NameError: uninitialized constant User::UserName

What is that ORDER BY lower(username) doing? I don't see where that
is coming from in your code.

What happens if you do User.first

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment