Simple output string


#1

Hi!

I am new to Rails and wanted to know how I can print an easy
string-line.
I wanted to generate a dynamic title for my blog articles made with
“typo”:

The first part of the html-title stays the same:

softrockcookie

if it is not the mainpage (“softrockcookie”) it shall add the
page_title, so:

softrockcookie <%= page_title unless page_title == "softrockcookie" %>

it worked so far…

and now, to seperate the two parts i wanted a double-doublepoint ("::"),
but couldn’t implement it yet. however, I tried it that way and got an
error:

softrockcookie <%= unless page_title == "softrockcookie" print " :: " page_title end %>

no clue how to do it the right way… could you please help a poor noob?
thank you!


#2

you can never use a print or puts method in an ERB template (or
anywhere else in Rails for that matter).

To achieve what you’re asking, you could, eg, interpolate the
page_title variable like this:

softrockcookie<%= " :: #{page_title}" unless page_title == "softrockcookie" %>

sebastian

softrockcookie <%= page_title unless page_title == "softrockcookie" %>