Denny Mueller
Denny Mueller

Reputation: 3615

Using erb inside erb at Ruby on Rails

Using modified version of http://railscasts.com/episodes/30-pretty-page-title for easier page heading and title.

Every page gets a <% title "insert heading here" %>. Via a helper

def title(page_title)
  content_for(:title) { page_title }
end

I can use it for page title and the headings of the single pages.

Also want to modify the view of my devise setup, but got stuck at the user edit page. The standard heading is <h2>Edit <%= resource_name.to_s.humanize %> </h2>.

Tried the obvious

<% title "Edit <%= resource_name.to_s.humanize %>" %>

But this dont work.

Any idea or suggestions? thanks in advance dennym

Upvotes: 1

Views: 1120

Answers (1)

GracelessROB
GracelessROB

Reputation: 1048

How about

<% title "Edit #{resource_name.to_s.humanize}" %>?

when using double quotes you can parse ruby inside #{} blocks inside of a string. This won't work when using a string with single quotes (') only double (").

Upvotes: 4

Related Questions