Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
bold flash[:notice]
11 Posts
bold flash[:notice]

I agree with Chris and Marcin - but tend to take it further. I set up a shared template for flashes under shared/_flash.rhtml Then you can add appropriate styling for each flash type - if there's one present. Generally something along the lines of Marcin's example thus:


      

Then add the following to your stylesheet:

 .flash {
   font-weight: bold;
   padding: 5px;
   margin-bottom: 5px;
 }
.error {
   background-color: #FAA;
   border: solid 2px red;
 }
 .warning {
   background-color: #FFA;
   border: solid 2px yellow;
 }
 .notice {
   background-color: #AFA;
   border: solid 2px green;
 }

application.rhtml:


       
      
      
       "flash_"+type.to_s) -%> 

stylesheet.css:


#flash_error {
    border: 2px solid #8B0000;
    padding:10px;
    background-color:#CD5C5C;
    color:gold;
    font-weight:bold;
}

#flash_notice {
    border: 1px solid green;    
    padding:10px;    
    background-color:#3CB371;
    color:#FFFF00;
    font-weight:bold;
}

:)

to clarify for anyone still confused, @flash[:whatever] is deprecated, flash[:whatever] works as expected

yes, my mistake what i mean is flash declared as instance variable already deprecated. Others can be referred here :http://www.rubyonrails.org/deprecation :)

i'm afraid flash[:notice] is already deprecated in rails latest version

No, that's View code. It's largely frowned upon to put any view code in the controller. However, you will want to set the flash value in the controller.

I have to second Chris Barnes and recommend you use a CSS style to control the appearance of the tag.

Can you actually put divs in the controller?

Or use something like "Stickies":http://software.pmade.com/stickies.

Sorry, I didn't escape my code

Display your notice inside an html element like this.

Then style the element with css how ever you like.

notice {

font-weight: bold; }

11 Posts
Login to add your message