8 Tips for Ruby on Rails Developers to Save Time and Efforts
So you’ve decided to become a Rails developer, huh? Neat!
To help you get started with this rewarding task, here’s a bunch of tips and tricks that could really help you out. Some might seem obvious, and maybe they are. Remember though that those that don’t cover their basics completely, might find out later on they’re in deep trouble.
1. Use Plug-ins
The father of Rails, Mr Hansson, said at one time that for every Rails application he creates he uses 5 or 6 plug-ins. This should be recommendation enough, but in case you’re still not convinced, remember that the more time you save, the more time you’ll have to polish the final product. There’s no need to re-invent the things that have already been developed. There’s a vast library of plug-ins out there and you should use them at your convenience. Regardless of what specific function you need, there’s a good chance it’s already been written and published. Use GitHub to find the best sources of free plug-ins for you.
Even though Rails comes with a built-in test framework, what I recommend you to use is something called Rspec. Now despite what some self-proclaimed experts think and say, automated testing is not the devil. It’s actually a helper program of sorts that will improve the pace of work and make you more confident with the results of your work.
3. Make the sites you create look good
The ERbtemplating system included in Rails by default isn’t bad, but there are better alternatives out there. One of them is called Haml. Self-dubbed a “markup haiku”, Haml uses css inspired syntax. This means that, for some, this will be very intuitive, while others might struggle. Find out how it works for you, and assuming it does, you’ll be amazed at the results. Try it, the difference is huge.
4. Keep close tabs on Exceptions
Despite our best efforts, exceptions happen. To avoid having your client complain to you about problems your software causes or encounters, consider using services such as Get Exceptional or Hop Toad. These are better than your common exception notifications plug-ins as they provide everything in one place. Combined with a well-designed user interface, these services make it easier for you to notice recurring patterns you might otherwise miss.
5. Mix and match frameworks and servers
Since Rack has been introduced to Rails (from 2.3), it’s been possible to Mix and match frameworks and servers. Since Rails hosting can sometimes be quite tricky, the ability to have a wider array of servers to choose from can be a blessing.
6. Data dumping can be quick and easy
The plug-in I like to use is Yaml_db. Using this plug-in confines the data to a single yami file you can find in db/data.yml. This makes it easy to transfer and analyze, once you have to examine the data.
7. The console can be useful
The console is basically an interactive environment that lets you test and access your code by seeing immediately the way the application is actually working. This lets you see the influence of the changes you’ve made to the code on the spot. Very helpful!
8. Keep tabs on the community
Ruby as well as Rails have a robust and creative community. Whether you want to learn, you’ve hit a brick wall or you’re simply looking for a ready solution, the community is your best bet. And since it’s based around GitHub, you don’t really have to look for it either.
So here it is, a collection of my tips and tricks for beginners. I hope they will be useful to many young programmers or simply those expanding their knowledge base by learning rails.