Tag Archives: rails

Session updates During concurrent requests


So this has always been a problem with Rails SessionStore. The problem is that if your app is sending concurrent requests and one of them is updating a session then depending on which request wins in the race you might get the stale session variables instead on the updated one. The problem is better explained at other places like http://dev.rubyonrails.org/ticket/8256 and the solution is a plugin smart_session_store by Frederick Cheung.

It might not seem a very informative post to you, but I am still posting it as this has taken me quite a bit of time to find out. And after finding it, I am astonished to see why Rails still can not deal with this issue.

 

Note: I am talking about Rails 2.3.8 here. Not sure if Rails 3 has a fix for it or not.

 


Move towards optimization now…


If you are looking to do the query optimization of your rails apps, I can suggest using few tools that does it.

1. First I want to suggest BULLET- A rails plugin/gem to kill N+1 queries and unused eager loading.

Bullet helps in finding the space for eager loading. It has a beautiful way of telling where should you add the eager loading for certain association. Whenever you try to run the code in development browser, it pops up a js alert and tells you exaclty where and what includes you have to add in you finder queries. It also tells you to remove the extra unnecessary eager loading handled in you app.

To add more beauty to it flyerhzm added growl notification as well for the Mac based developers.

2. Second suggested tool will be Slim-Scrooge: SlimScrooge heavily optimises your database interactions

Slim-Scrooge works for optimizing the sql queries by monitoring the required columns for the model and changing inline the queries to fetch only selective columns. So with slim_scrooge working in background you don’t have to worry about giving the options to :select in you find. Instead slim_scrooge will itself analyze what are the columns needed to run your code for the first time and second call to the same action it itself puts the necessary column in select removing the asterisk(*).

I am still skeptical about using it. As it might make the developers lazy(just blindly putting * in queries) and increasing the processing time in slim_scrooge inline query modifier. Though I think it could be a good tool if used once in a while to analyze what are the missing selects in our code. Whatever be the case you might wanna give it a try, its kinda lucraitve.

3. Last but not the least I try to add is rack-bug: Debugging toolbar for Rack applications implemented as middleware.

Remember rails-footnotes? Well Rack-bug is kinda same but seems better and provide more. Better, because its rack based. Provides more with the toolbar giving following info:

  • Rails Info
  • Resource Usage
  • Rack Env
  • SQL
  • AR Objects
  • Memcached
  • Templates
  • Log
  • Memory Usage

I kind of loved it at first sight. So if you already have footnotes. Give it a try. If you dont, then again give it a try to optimize better. Watch the screencast by brynary for more info.

If you have tried any of those feel free to give your opinions. I will be happy to learn how everybody is approaching the technique of optimization.



Merb + Rails == Great Software


So you heard the news??? Yes, Merb and Rails are going to merge in Rails 3 If thats true it will be a great merger o all times in ruby community. The largest framework of Ruby glued with the fastest one will be cool.

One of the thing which I loved in Merb is its agnostic feature. Specially ORM to quote. As I found Datamapper to be more efficient and useful then ActiveRecord in Rails. If we can use Datamapper in Rails it will be the coolest thing.

While trying Merb I also felt like most of the things are implemented in the same way as in Rails. So the basic difference is just in the values Merb advertise or rather built on …

* Being Agnostic

* Prefer Plugin

I am just waiting for Rails to adopt those values so it could be more efficient and more lovable :)


Ruby Funday- The new beginning.


ruby funday First Barcamp now Ruby Fun Day. Seems like Delhi is becoming the hub of all the un-conference startups. After the huge success of BarcampDelhi, Delhites are now bringing Ruby Funday to India. Its the first Ruby and Rails Full Day event in India.

The Ruby/Rails lovers dream come true event is going to happen on 22nd of November 2008. So please mark the Saturday in your calender to go to Impetus Technologies at Noida, where the event is taking place.

Hoping for a day full of fun and learning as there are many Geeky speakers enrolling each day.


Basic Ruby/Rails Tutorials


I am trying to gather information about all of the basic tutorials available on net for Ruby/Rails. This initiative is for those who are trying to learn Rails but coudnt find good resources. If you know of some more resources like these please spend some time and help me in this nobel task of Rails community Expension :)

Ruby:

Rails:

Note: Please also give a look to the articles/tutorials mentioned in the comments in this post. Some of them are really good as being suggestions from other rubyist. Thanks people for the suggestions.


Follow

Get every new post delivered to your Inbox.