Rails-bestpractices - rails-bestpractices.com - Rails Best Practices
General Information:
Latest News:
default_scope is evil 15 Jun 2013 | 09:32 pm
activerecord provides default_scope to set a default scope for all operations on the model, it looks convenient at first, but will lead to some unexpected behaviors, we should avoid using it. see more...
Clever enums in rails 18 Apr 2013 | 09:33 pm
After many years of rails developing I have finally found satisfying solution to implement enums in rails. see more Related Posts Restrict auto-generated routes. Subscribe to our team blog, you wil...
monitor your backend services 28 Mar 2013 | 02:23 pm
We always have multiple processes for rails websites, if any of them crashed, your website failed, so it would be better to monitor all of the processes and automatically restart crashed processes. se...
Pay more attentions on security 22 Mar 2013 | 04:40 am
Recently we saw rails exposed some security issues, github was attacked, rubygems.org was crashed, they all remind us we must pay more attentions on our rails projects. see more Related Posts Protec...
speed up assets precompile with turbo-sprockets-rails3 23 Nov 2012 | 02:29 pm
Rails is integrated with sprockets from 3.1, which gives you the power to pre-process, compress and minify your assets. It's awesome, but it slows down deployment a lot. see more Related Posts Use a...
Check the return value of "save", otherwise use "save!" 2 Nov 2012 | 01:16 pm
The "save" method on ActiveRecord returns "false" and does nothing if the record is invalid. You should always check the return value, otherwise you may inadvertently not save the record. If you think...
Don't rescue Exception, rescue StandardError 1 Nov 2012 | 04:44 pm
In C# or Java, you can `catch (Exception)` to rescue all exception types. However, in Ruby you should almost never catch `Exception`, but only catch `StandardError`. see more Subscribe to our team b...
Tell, don't ask 29 Sep 2012 | 05:57 pm
Methods should focus on what you want done and not how you want it. see more Related Posts Move finder to named_scope Use model association Add model virtual attribute Use model callback Subscri...
split your cap tasks into different files 10 Sep 2012 | 02:57 pm
Your capistrano deploy.rb file might become complicated with the growth of your application, contain more and more cap tasks, it would be better to split these tasks into different files according to ...
rolling out with feature flags 2 Sep 2012 | 05:51 pm
Sometimes you may face the situation that some features will be released, but you are not sure if it is friendly to end user, or if it will lead to performance issues, at that time you should use what...