Rails 4 flash messages using Twitter Bootstrap 3

I’ve always wondered if there’s any better way to deal with flash messages in Ruby on Rails.

In all the Ruby on Rails tutorials you see, they’ll tell you to keep the code DRY, isn’t so? Right?
So what you do?

Create partial shared/_error_messages.html.erb or shared/_flash_messages.html.erb and write your flash messages displaying code into this file and call it from all other places in your views? Wait!! While keeping your flash messages in partial is a good thing, but don’t you think you can do it in a more better way?? Yes, better way!

I found this gist. While I was reading this gist a thought triggered in my mind that why not remove a part and make a method which displays the flash messages. So, I created this gist:


Now, the application doesn’t have to load another part for just displaying the flash messages. Guess what? You saved few milliseconds of your action load time! Don’t believe? Try it yourself! You’re welcome!

Comments

  1. Spades - Titanium Art Studio
    In Spades, titanium wedding ring a partnership between the ford focus titanium hatchback two artworks are created, surgical steel vs titanium and 2014 ford focus titanium hatchback you have control titanium watch band of your cards. The art direction, design and content of

    ReplyDelete

Post a Comment

Popular posts from this blog

Why should I write tests?

How I started my career after graduation

The Observer Design Pattern in Ruby!!