Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Iyad Horani
Courses Plus Student 6,141 Pointserb code not executing inside the div tag
Hi Guys
Trying to make the helper method working with Rails 4.1.0 and Ruby 2, so far adding anything in the class="<%= method name %>" does not get executed. any thoughts?
<% flash.each do |key, value| %>
<div class="<%= flash_class(key) %>">
<%= value %>
</div>
<% end %>
3 Answers

Iyad Horani
Courses Plus Student 6,141 PointsLooks like the problem is with the application_helper.rb, for some reason the application.html.erb doesn't have access to it. The code inside application_helper.rb is not running at all! any ideas?

Iyad Horani
Courses Plus Student 6,141 PointsHi stone,
Thanks for your reply. Here is the method:
module ApplicationHelper
def flash_class(level)
case level
when :notice then "alert alert-info"
when :success then "alert alert-success"
when :error then "alert alert-error"
when :alert then "alert alert-error"
end
end
end

Iyad Horani
Courses Plus Student 6,141 PointsAny other ideas on why this is not working from within the application_helper only? Thanks
Stone Preston
42,016 PointsStone Preston
42,016 Pointshmm any helper methods inside the application helper should automatically be available in your layout file. are you sure your method is correct? mind posting the method implementation?