On 22 September 2010 21:54, Al Rowan <[email protected]> wrote:
> class User < ActiveRecord::Base
>  attr_accessor :password
>
>  validates :email, :uniqueness => true,
>                    :length => { :within => 5..50 },
>                    :format => { :with =>
> /^...@][\w.-]+@[\w.-]+[.][a-z]{2,4}$/i }
>  validates :password, :confirmation => true,
>                       :length => { :within => 4..20 },
>                       :presence => true,
>                       :if => :password_required?
>
>  has_and_belongs_to_many :subjects
>  has_one :profile
>  has_many :classes, :dependent => :nullify
>  has_many :courses, :dependent => :nullify
>  has_many :works
>  has_many :units
>  has_many :groups
>  before_save :encrypt_new_password
> .....
> end
>
> ---------------------------------------------------
>
> class Group < ActiveRecord::Base
>
>  validates :groupname, :presence => true
>
>  belongs_to :user
>  has_many :students
> end
>
> ---------------------------------------------------
>
> user = User.new
> => #<User id: nil, email: nil, hashed_password: nil, subject_id: nil,
> created_at: nil, updated_at: nil>
>
> ---------------------------------------------------
>
>>> group = Group.new
> => #<Group id: nil, groupname: nil, user_id: nil, course_id: nil,
> created_at: nil, updated_at: nil>
>
> ---------------------------------------------------
>
>
> WHAT THE HELL. i just did user.groups and it worked...i didnt change
> anything! now im even more confused.
> --

Were you running it from the console when it failed, or from code?  If
from the console I wonder whether the group model was not loaded or
something along those lines.  Perhaps by doing Group.new you loaded it
so all is well.  I suggest pressing on with some code (preceded by
writing tests of course) and see how it goes.

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to