LLong
LLong

Reputation: 157

Rails - Output view path to view

I have a view generated by acts-as-taggable-on where I would like to output the name of the tag to the view inside an <h1> tag.

So far I'm able to output the name to the view using:

<h1>Icons matching <%= tag_path %></h1>

However when I do this it outputs both the tag name but also the root path of the application. So for instance if the tag is "notification" the browser outputs "Icons matching icons/notification".

How can I tell the browser to only output the second part of the path, ie. <h1>Icons matching notifications</h1>

Upvotes: 0

Views: 61

Answers (1)

Kirti Thorat
Kirti Thorat

Reputation: 53048

Replace

<h1>Icons matching <%= tag_path %></h1>

with

<h1>Icons matching <%= tag_path.split("/").last %></h1>

Upvotes: 1

Related Questions