twitter bootstrap - How to achieve Rails close button -
i'm have close button on rails application messages.
i've read integrating rails flash messages twitter bootstrap, i'm stuck.
this kind of messages bootstrap alerts. check bootstrap documentation, , in rails make sure have app integrated boottrap.
in order integrate flash messages bootstrap i'll suggest follow this approach:
create partial _flash_messages.html.erb
<% flash.each |type, message| %> <div class="alert <%= bootstrap_class_for(type) %> fade in"> <button class="close" data-dismiss="alert">×</button> <%= message %> </div> <% end %>
then in application.html.erb
add:
<%= render partial: "shared/flash_messages", flash: flash %>
in application_helper.rb
:
module applicationhelper def bootstrap_class_for flash_type case flash_type when :success "alert-success" when :error "alert-error" when :alert "alert-block" when :notice "alert-info" else flash_type.to_s end end end
Comments
Post a Comment