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.
--
Posted via http://www.ruby-forum.com/.
--
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.