0

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>

1 Answer 1

1

Replace

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

with

<h1>Icons matching <%= tag_path.split("/").last %></h1>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.