Learning Rails

I hit a little snag today with Flash Messages and Bootstrap styling. I’m working through the beginner Rails course on Treehouse, and unfortunately the course was created back before Rails 4. At one point in the course, we use a Flash Message Helper, where we clean up ¬†and minimize our code some.

There was just a slight difference in how to define the helper in Rails 4 compared to Rails 3. I went ahead and put the full code in a Github Gist here.

Basically it came down to using strings instead:

 

module ApplicationHelper

def flash_class(type)

case type

when 'alert' then "alert alert-danger"

when 'notice' then "alert alert-success"

else

""

end

end

end

You’ll notice the ‘alert’ and ‘notice’ in strings instead of :alert and :notice like you would have done in Rails 3.

Just wanted to share this!

filed under:

Read More Posts Here →