Sha256: 1a0c358e5d89079061d5509f9143ebdd90daeafe617930abeebca03590f89e04

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

<% module_namespacing do -%>
class <%= class_name %>Authentication < ActiveRecord::Base
  belongs_to :<%= class_name.downcase %>
  belongs_to :authentication_provider

  serialize :params

<% if Rails::VERSION::MAJOR < 4 -%>
  attr_accessible :user_id, :authentication_provider_id, :uid, :token, :token_expires_at, :params

<% end -%>
  def self.create_from_omniauth(params, <%= class_name.downcase %>, provider)
    create(
      <%= class_name.downcase %>: <%= class_name.downcase %>,
      authentication_provider: provider,
      uid: params['uid'],
      token: params['credentials']['token'],
      token_expires_at: params['credentials']['expires_at'],
      params: params,
    )
  end
end
<% end -%>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
domp-0.0.2 lib/generators/domp/templates/model_authentication.rb
domp-0.0.1 lib/generators/domp/templates/model_authentication.rb