Simple output string


I am new to Rails and wanted to know how I can print an easy
I wanted to generate a dynamic title for my blog articles made with

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


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

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!

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" %>


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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs