Permalink
Browse files

Added validation and has-a relation

  • Loading branch information...
1 parent bbbd02d commit d31e7c53e515d1c9c0be09a00c643b743bd35132 @knshaum committed Aug 3, 2013
Showing with 3 additions and 0 deletions.
  1. +2 −0 app/models/micropost.rb
  2. +1 −0 app/models/user.rb
View
2 app/models/micropost.rb
@@ -1,3 +1,5 @@
class Micropost < ActiveRecord::Base
attr_accessible :content, :user_id
+ validates :content, :length => { :maximum => 140 }
+ belongs_to :user
end
View
1 app/models/user.rb
@@ -1,3 +1,4 @@
class User < ActiveRecord::Base
attr_accessible :email, :name
+ has_many :microposts
end

0 comments on commit d31e7c5

Please sign in to comment.