4 ms·
script/runner does not have the app.get facility. That's only available in script/console.
by agius 15y ago
script/runner does not have the app.get facility. That's only available in script/console.
- wycats 15y agoapp.get is using the same facility as integration testing (https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/testing/integration.rb https://github.com/rails/rails/blob/master/actionpack/lib/ac...). Check out the code that instantiates it at https://github.com/rails/rails/blob/master/railties/lib/rails/console/app.rb https://github.com/rails/rails/blob/master/railties/lib/rail...
- jz 15y agoI needed this in a rake task under Rails 2 a while back; I ended up doing the following: require 'action_controller/integration' app = ActionController::Integration::Session.new module CurrentUserHack def current_user @user ||= User.look_up_my_user_here end end ApplicationController.send :include, CurrentUserHack Now you can make authenticated requests in rake tasks and presumably in script/runner.