Skip to content

Instantly share code, notes, and snippets.

@rolentle
Created January 20, 2014 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolentle/8514836 to your computer and use it in GitHub Desktop.
Save rolentle/8514836 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :trips
has_many :feed_sources
has_many :photos
has_many :statuses
has_many :checkins
validates :name, :presence => true
def possessive_name
name.ends_with?("s") ? name + "'" : name + "'s"
end
def self.from_omniauth(auth)
user = User.find_or_create_by(
name: auth["info"]["nickname"]
)
user.update_attributes(
uid: auth["uid"],
provider: auth["provider"],
avatar_url: auth["info"]["image"],
access_token: auth["credentials"]["token"],
access_secret: auth["credentials"]["secret"]
)
user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment