Skip to content

Instantly share code, notes, and snippets.

View a-chernykh's full-sized avatar

Andrey Chernykh a-chernykh

View GitHub Profile
class CustomDevise::SessionsController < Devise::SessionsController
def create
anonymous_cart = Cart.where(:security_hash => session[:security_hash]).last unless session[:security_hash].nil?
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
set_flash_message :notice, :signed_in
if anonymous_cart && !anonymous_cart.user_id?
resource.cart.delete if resource.cart
anonymous_cart.update_attribute(:user_id, resource.id)
end
sign_in_and_redirect(resource_name, resource)
# needs the "hashie" gem in Gemfile
require 'erb'
module Movies
class Application < Rails::Application
settings = ERB.new(IO.read(File.expand_path('../settings.yml', __FILE__))).result
mash = Hashie::Mash.new(YAML::load(settings)[Rails.env.to_s])
mash.each do |key, value|