Posts

Showing posts with the label twitter bootstrap

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’...

Module - Include or Extend? and Mixin

Multiple Inheritance – A class is suppose to show multiple inheritance when that class can inherit characteristics and features from more than one superclass(parent class).  Mixin – Since Ruby does not support multiple inheritances but has an amazing implementation of achieving the same by eliminating the need for multiple inheritances using the module, is also known as the mixin. Mixin - can be achieved by using either include or extend keywords inside a class. The difference between include and extend is: include : mixes in specified module methods as instance methods in the target class. extend : mixes in specified module methods as class methods in the target class. Here is a small code example:  Still, have a question? Feel free to contact me!!