Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from Benjmin/gist:4720543
Last active December 12, 2015 05:18
Show Gist options
  • Save radar/4720628 to your computer and use it in GitHub Desktop.
Save radar/4720628 to your computer and use it in GitHub Desktop.
class Page < ActiveRecord::Base
belongs_to :book
attr_accessible :link, :summary, :title
before_save :set_title
scope :title, where("title is not null")
def set_title
self.title ||= URI.parse(link).host
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment