Jak
Jak

Reputation: 181

Create a URL from of a string (named route)

I have an action called home. I store "home_url" in the database.

I need to generate the full URL form this string.

For example,

Input: "home_url"

Desired output: "http://myhostname/home/index.html"

Upvotes: 2

Views: 843

Answers (1)

fl00r
fl00r

Reputation: 83680

Try this

self.send("home_url")

For example

<%= link_to "Home", self.send("home_url") %>

And obviously home_url should be presented in your routes.rb file

Upvotes: 5

Related Questions