Created
February 26, 2009 23:03
-
-
Save avk/71187 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Site < ActiveRecord::Base | |
has_many :pages | |
belongs_to :account | |
validates_presence_of :url | |
validates_format_of :url, :with => URI.regexp(['http', 'https']) | |
validates_presence_of :account_id | |
validates_associated :account | |
after_save :create_home_page | |
def home_page | |
# url | |
self.pages.first.url | |
end | |
protected | |
def create_home_page | |
self.pages << Page.new(:url => url) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment