Sha256: 3b039c199bb82e8846c11ca73d7fd40ab68dd1afd3fa55bdede2fd98f6ae3d84
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
class NinshoController < Ninsho.parent_controller.constantize # Sets the flash message with :key, using I18n. # Example (i18n locale file): # # en: # ninsho: # :sessions # signed_in: "Signed in successfully" # def flash_message(key, action) message = I18n.t("ninsho.sessions.#{action}") flash[key] = message if message.present? end # Gets the actual resource stored in the instance variable def resource instance_variable_get(:"@#{resource_name}") end # Omniauth hash for creating the records def resource_params env['omniauth.auth'] end # Proxy to ninsho map name def resource_name Ninsho.resource_name #authentication end # Class name for the ninsho model # commonly Authentication def resource_class Ninsho.resource_class end # Sets the resource creating an instance variable def resource=(new_resource) instance_variable_set(:"@#{resource_name}", new_resource) end # Parent resource, commonly user def parent_resource resource_class.reflect_on_all_associations(:belongs_to).first.name.to_s end # Build a ninsho resource, from the omniauth hash def build_resource_from_omniauth self.resource = resource_class.from_omniauth(resource_params) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ninsho-0.0.3 | app/controllers/ninsho_controller.rb |