Error in if statement

Hi,

The below code is my global layout…code I would like to include a if
statement in it.

Languages: <%= controller.action_name %> <%= stylesheet_link_tag 'scaffold' %>

<% if flash[:notice].empty? then puts flash[:message]%>

<%= yield %>

whats wrong with the if statement here…?

Thanks in advance,
Sharma

<% if flash[:notice].empty? then puts flash[:message]%>

whats wrong with the if statement here…?

puts won’t work in rhtml. You can try this:
<%= flash[:message] if flash[:notice].empty? %>

Regards,
Rimantas

http://rimantas.com/

think i read somewhere that “puts” should not be used in templates.

use

<%= flash[:message] if flash[:notice].empty? %>

On 1 Mrz., 11:15, Sharma C. [email protected]

On Mar 1, 2007, at 5:15 AM, Sharma C. wrote:

Languages: <%= controller.action_name %> <%= stylesheet_link_tag 'scaffold' %>

<% if flash[:notice].empty? %> <%= flash[:message] %> <% end %>

<%= yield %>

whats wrong with the if statement here…?

Thanks in advance,
Sharma

You need to use <%= %> to get output from ERb and (as others have
said) you don’t use puts in templates.

You’re Welcome,
-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Thanks for the help.

Thorsten wrote:

think i read somewhere that “puts” should not be used in templates.

use

<%= flash[:message] if flash[:notice].empty? %>

On 1 Mrz., 11:15, Sharma C. [email protected]

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