Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access *_path and *_url helpers in Rails 4

I was reading Rails: Check output of path helper from console and none of the solutions worked for me, presumably because they are all for Rails 2/3.

In Rails 4/5, how can I access the *_path and *_url helpers from the rails console?

like image 480
Shelvacu Avatar asked Mar 09 '16 21:03

Shelvacu


People also ask

What is path helper in Rails?

Searching For Missing Route Values Under the hood, Rails path helpers use ActionDispatch to generate paths that map to routes defined in routes.

How do I see routes in Rails?

TIP: If you ever want to list all the routes of your application you can use rails routes on your terminal and if you want to list routes of a specific resource, you can use rails routes | grep hotel . This will list all the routes of Hotel.

What is a route helper?

Helpers are responsible for assisting the driver along the route with throwing trash. Must be able to work 10 to 12 hour shifts.


1 Answers

Running Rails 4, I get at them with:

app.root_path
=> "/"

app.users_url
=> "http://www.example.com/users"
like image 128
Kimball Avatar answered Oct 13 '22 02:10

Kimball