Skip to content

Instantly share code, notes, and snippets.

@Benjmin
Last active December 12, 2015 05:18
Show Gist options
  • Save Benjmin/4720543 to your computer and use it in GitHub Desktop.
Save Benjmin/4720543 to your computer and use it in GitHub Desktop.
class Page < ActiveRecord::Base
belongs_to :book
attr_accessible :link, :summary, :title
before_save :normalize_link, :unless => :title?
def normalize_link.
@title = @link.match( /(?<=http:\/\/)(.*)(?=.com)/ )
end
scope :title?, where(@title == True)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment