When I try to use url_for in the rails console, I see:
url_for(User.first.images.first)
NoMethodError: undefined method `url_for' for main:Object
How can I use that method in the rails console?
When I try to use url_for in the rails console, I see:
url_for(User.first.images.first)
NoMethodError: undefined method `url_for' for main:Object
How can I use that method in the rails console?
you can use the following to check route helper methods in the console.
app.url_for(User.first.images.first)
the app would give you a view context. But beware if you are using it in the application.
app. when it's required so I can run the same code between rails console and in the application? (I find the console invaluable for quickly testing bits of code, but painful to deal with it behaving differently to the application). Just thought of this while writing this, but perhaps I should be using a debugging session for quick code tests because it will already have everything it needs..