Forum: Ruby on Rails simple output string

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sebastian S. (Guest)
on 2006-03-29 02:25
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:

<title>softrockcookie</title>

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

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

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:

<title>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!
Sebastian F. (Guest)
on 2006-03-29 03:19
(Received via mailing list)
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:

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

sebastian


> <title>softrockcookie <%= page_title unless page_title ==
> "softrockcookie" %></title>
This topic is locked and can not be replied to.