small medium large xlarge

04 Mar 2012, 12:46
Xavier John (21 posts)

Hi, What does <% if notice %>

<%= notice %>

<% end %>


Thanks, Xavier

05 Mar 2012, 02:11
Michael Ryan Soileau (5 posts)

I’m pretty sure that’s an error detection script. When you put in your validations like validates_presence_of, it either generates its own error message like “you did not enter anything for this box”, or you can customize it to print out your own error messages, which is one of the exercises at the end of the chapter.

05 Mar 2012, 03:21
Xavier John (21 posts)

You are correct.


05 Mar 2012, 12:48
Xavier John (21 posts)

As an experiment, I changed notice to random_variable but it does not work, why?

The code is <% if random_variable %> <p id="notice"><%= random_variable %></p> <% end %>

format.html { redirect_to store_url, random_variable: ‘Your cart is currently empty’}

now I get error undefined local variable or method `random_variable’ for #<#:0x69e0970>

You must be logged in to comment