Created
July 27, 2012 12:26
-
-
Save akinsgre/3187671 to your computer and use it in GitHub Desktop.
Helper methods not called synchronously
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started GET "/plugins/1" for 127.0.0.1 at 2012-07-27 08:12:13 -0400 | |
Processing by PluginsController#show as HTML | |
Parameters: {"id"=>"1"} | |
Plugin Load (0.1ms) SELECT `plugins`.* FROM `plugins` WHERE `plugins`.`id` = 1 LIMIT 1 | |
Rendered plugins/show.html.erb (0.3ms) | |
Completed 200 OK in 110ms (Views: 2.2ms | ActiveRecord: 0.1ms) | |
Private User | |
Rendering Plugin | |
Started GET "/plugins/3" for 127.0.0.1 at 2012-07-27 08:12:13 -0400 | |
Processing by PluginsController#show as HTML | |
Parameters: {"id"=>"3"} | |
Plugin Load (0.1ms) SELECT `plugins`.* FROM `plugins` WHERE `plugins`.`id` = 3 LIMIT 1 | |
Redirecting to login | |
Redirected to http://localhost:3000/login | |
CACHE (0.0ms) SELECT `plugins`.* FROM `plugins` WHERE `plugins`.`id` = 3 LIMIT 1 | |
Completed 500 Internal Server Error in 116ms | |
AbstractController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".): | |
app/controllers/plugins_controller.rb:75:in `show' | |
Rendered .rvm/gems/ruby-1.9.2-p290@rails3013/gems/actionpack-3.0.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms) | |
Rendered .rvm/gems/ruby-1.9.2-p290@rails3013/gems/actionpack-3.0.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms) | |
Rendered .rvm/gems/ruby-1.9.2-p290@rails3013/gems/actionpack-3.0.13/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (9.1ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
helper :all | |
def require_user | |
unless current_user | |
puts "Redirecting to login" | |
redirect_to :login_path and return | |
end | |
end | |
end | |
class PluginsController < ApplicationController | |
def show | |
plugin = Plugin.find(params[:id]) | |
if plugin.private? | |
puts "Private User" | |
require_user | |
end | |
puts "Rendering plugin" | |
render :text => "Display Plugin", :layout => true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment