Reputation: 5009
I have a link_to
that produces <a href="#" id="login">Log in</a>
.
I'd like to change that to <a href="/signup">Sign up</a>
when the url is on my log in page (as opposed to my homepage).
Is there a way to do this with Rails? I know I could use JavaScript but it was pointed out to me that it would make more sense to do this on the server-side.
I tried a <% if request.url == "/login" %>
but that didn't do anything.
Upvotes: 0
Views: 155
Reputation: 24236
I think request.url
will return the entire URL so it won't match '/login'. You could either parse the '/login' value from the request.url
string or use request.path
.
Here's a link that gives more info on getting parts of the current URL - http://programming-tut.blogspot.com/2010/06/ruby-on-rails-request-url.html
Upvotes: 2