Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
pat saunders
6,636 PointsRefactoring the Flash Code
Hey folks,
Following the "Refactoring the Flash Code" video I was unable to get the alert classes to show correctly, Its one of those frustrating ones that doesn't give you an error to fix it just isn't showing the colors assigned to classes (green for -success etc).
I have been through this video several times and have the exact code that Jim uses, It may be one of the little rails 4 issues but im wondering if anyone has a solution for this?
The correct :alerts & :notice text are displaying, just with no bootstrap classes to color them??
Here is the code I have...
module ApplicationHelper
def flash_class(type)
case type
when :alert
"alert-danger"
when :notice
"alert-success"
else
""
end
end
end
cheers!
6 Answers
Todd Nestor
10,689 PointsYou could also do it this way in Rails 4 to avoid the "then"s I originally used:
module ApplicationHelper
def flash_class(type)
case type
when "alert"
"alert-danger"
when "notice"
"alert-success"
else
""
end
end
end
Todd Nestor
10,689 PointsFor Rails 4 I did it this way and it worked:
module ApplicationHelper
def flash_class(type)
case type
when "alert" then "alert-danger"
when "notice" then "alert-success"
else
end
end
end
Hope this helps.
Sean Perryman
13,810 PointsIs there any particular way the passing of the object doesn't work in Rails 4 like it seems to in Rails 3?
Anthony Gonzales
5,522 PointsAwesome, thanks for the post Todd Nestor. Totally worked.
Todd Nestor
10,689 PointsNo problem Anthony Gonzales , good luck with the rest of the tutorial.
pat saunders
6,636 PointsThanks Todd Nestor! So simple, but i never would have got it without your help.
pat saunders
6,636 Pointspat saunders
6,636 Pointsapplication.html.erb
<div class="container">
</div>