Skip to content

Instantly share code, notes, and snippets.

@rvanlieshout
Created March 23, 2011 15:04
Show Gist options
  • Save rvanlieshout/883243 to your computer and use it in GitHub Desktop.
Save rvanlieshout/883243 to your computer and use it in GitHub Desktop.
def sign_in_and_redirect(resource_or_scope, resource=nil, skip=false)
scope = Devise::Mapping.find_scope!(resource_or_scope)
resource ||= resource_or_scope
sign_in(scope, resource) unless skip
if current_user && current_user.is_customer_contact?
session[:customer_id] = current_user.customers.first.id
end
redirect_to :controller => 'dashboard', :locale => (current_user && current_user.language.to_s != "" ? current_user.language : I18n.locale)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment