Skip to content

Instantly share code, notes, and snippets.

@marcamillion
Created June 18, 2011 23:14
Show Gist options
  • Save marcamillion/1033582 to your computer and use it in GitHub Desktop.
Save marcamillion/1033582 to your computer and use it in GitHub Desktop.
def after_sign_in_path_for(resource)
Authorization.current_user.update_space
if resource.is_a?(User) && resource.has_trial_expired?
return url_for(:settings)
end
super
end
Started GET "/users/login" for 72.252.205.36 at Sat Jun 18 18:00:35 -0500 2011
Processing by Devise::SessionsController#new as HTML
nil
Rendered devise/shared/_links.erb (1.9ms)
Rendered devise/sessions/new.html.erb within layouts/application (10.8ms)
Completed 200 OK in 90ms (Views: 18.3ms | ActiveRecord: 1.8ms)
Started GET "/users/confirmation?confirmation_token=12O-F_JMzI-SxpIEEEAh" for 72.252.205.36 at Sat Jun 18 18:02:04 -0500 2011
Processing by Devise::ConfirmationsController#show as HTML
Parameters: {"confirmation_token"=>"12O-F_JMzI-SxpIEEEAh"}
nil
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = '12O-F_JMzI-SxpIEEEAh' LIMIT 1
Slug Load (0.2ms) SELECT "slugs".* FROM "slugs" WHERE ("slugs".sluggable_id = 3 AND "slugs".sluggable_type = 'User') ORDER BY id DESC LIMIT 1
AREL (0.2ms) UPDATE "users" SET "updated_at" = '2011-06-18 23:02:04.980588', "confirmed_at" = '2011-06-18 23:02:04.977060', "confirmation_token" = NULL WHERE "users"."id" = 3
AREL (0.3ms) UPDATE "users" SET "current_sign_in_ip" = '72.252.205.36', "last_sign_in_ip" = '72.252.205.36', "updated_at" = '2011-06-18 23:02:04.986283', "sign_in_count" = 1, "current_sign_in_at" = '2011-06-18 23:02:04.984989', "last_sign_in_at" = '2011-06-18 23:02:04.984989' WHERE "users"."id" = 3
Completed 500 Internal Server Error in 88ms
NoMethodError (undefined method `update_space' for #<Authorization::AnonymousUser:0xb611f240 @role_symbols=[:guest]>):
app/controllers/application_controller.rb:27:in `after_sign_in_path_for'
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (11.6ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (17.9ms)
Started GET "/users/login" for 127.0.0.1 at 2011-06-18 18:02:49 -0500
Processing by Devise::SessionsController#new as HTML
nil
Rendered devise/shared/_links.erb (2.1ms)
Rendered devise/sessions/new.html.erb within layouts/application (38.2ms)
Completed 200 OK in 159ms (Views: 87.9ms | ActiveRecord: 269.9ms)
Started GET "/users/confirmation?confirmation_token=35eDT14LmVL5eusrsIRH" for 127.0.0.1 at 2011-06-18 18:03:12 -0500
Processing by Devise::ConfirmationsController#show as HTML
Parameters: {"confirmation_token"=>"35eDT14LmVL5eusrsIRH"}
nil
User Load (2.2ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = '35eDT14LmVL5eusrsIRH' LIMIT 1
Slug Load (0.5ms) SELECT "slugs".* FROM "slugs" WHERE ("slugs".sluggable_id = 29 AND "slugs".sluggable_type = 'User') ORDER BY id DESC LIMIT 1
AREL (0.4ms) UPDATE "users" SET "confirmation_token" = NULL, "confirmed_at" = '2011-06-18 23:03:12.450907', "updated_at" = '2011-06-18 23:03:12.456550' WHERE "users"."id" = 29
AREL (0.4ms) UPDATE "users" SET "last_sign_in_at" = '2011-06-18 23:03:12.461899', "current_sign_in_at" = '2011-06-18 23:03:12.461899', "last_sign_in_ip" = '127.0.0.1', "current_sign_in_ip" = '127.0.0.1', "sign_in_count" = 1, "updated_at" = '2011-06-18 23:03:12.462653' WHERE "users"."id" = 29
Redirected to http://localhost:3000/home/index
Completed 302 Found in 118ms
def update_space
total_size = 0
if self.uploads.count > 0
self.uploads.each do |upload|
total_size += upload[:image_file_size]
end
end
self.space_used = total_size
self.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment