Skip to content

Instantly share code, notes, and snippets.

@igaiga
Last active August 29, 2015 14:00
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 igaiga/11360639 to your computer and use it in GitHub Desktop.
Save igaiga/11360639 to your computer and use it in GitHub Desktop.
factory.rb
class Account
def self.create(params, provider)
case provider
when "facebook"
Facebook.new(params)
when "google_oauth2"
Google.new(params)
end
end
end
# facebookのとき
account = Account.create(param,"facebook")
account.find_by_email_and_provider(email, provider) #この行がgoogleと同じになる
# googleのとき
account = Account.create(param,"google_oauth2")
account.find_by_email_and_provider(email, provider) #この行がfbと同じになる
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment