Unless I'm misunderstanding something, script/runner could be used instead of script/console. Then the whole Rails environment is properly loaded but in a manner that's actually meant to be used for prewritten scripts instead of in an interactive environment.
Comments
Unless I'm misunderstanding something, script/runner could be used instead of script/console. Then the whole Rails environment is properly loaded but in a manner that's actually meant to be used for prewritten scripts instead of in an interactive environment.
script/runner does not have the app.get facility. That's only available in script/console.
app.get is using the same facility as integration testing (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/rail...
I needed this in a rake task under Rails 2 a while back; I ended up doing the following:
Now you can make authenticated requests in rake tasks and presumably in script/runner.