You can always debug your application and get it back on the rails if ever it something goes wrong. You have to check the application log files. See to it that “tail –f” commands are running on the server.log and development.log. Rails will then show debugging and runtime information to these files and debugging information …
Category: Ruby On Rails
Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language.
Permanent link to this article: https://blog.openshell.in/2010/11/debugging-rails/
Nov 28
Finders are great but be careful
Finders are very pleasant to use, enable you to write readable code and they don’t require in-depth SQL knowledge. But the nice high level abstraction come with a computational cost. Follow these rules of thumb: Retrieve only the information that you need. A lot of execution time can be wasted by running selects for data …
Permanent link to this article: https://blog.openshell.in/2010/11/finders-are-great-but-be-careful/
Nov 28
Optimize your Ruby code
This may seem obvious, but a Rails application is essentially ruby code that will have to be run. Make sure your code is efficient from a Ruby standpoint. Take a look at your code and ask yourself if some refactoring is in order, keeping in mind performance considerations and algorithmic efficiency. Profiling tools are, of …
Permanent link to this article: https://blog.openshell.in/2010/11/optimize-your-ruby-code/
Nov 28
Group operations in a transaction
ActiveRecord wraps the creation or update of a record in a single transaction. Multiple inserts will then generate many transactions (one for each insert). Grouping multiple inserts in one single transaction will speed things up. Insead of: my_collection.each do |q| Report.create({:phrase => q}) end Use: Report.transaction do my_collection.each do |q| Report.create({:phrase => q}) end end …
Permanent link to this article: https://blog.openshell.in/2010/11/group-operations-in-a-transaction/
Nov 22
Refresh / Redirection
When you need your web page automatic refresh in 5 second or any second, use this meta tag. It’s a simple code, put it between HEAD tag in your web page. This script easy but powerful. <HEAD> <meta http-equiv=’refresh’ content=’2;url=’file_name or URL’> </HEAD> // content = time (second) // file_name = name of file you …
Permanent link to this article: https://blog.openshell.in/2010/11/refresh-redirection/