ActiveRecord finder: Now we can use hash as conditions

Published on

Earlier conditions can either be specified as a string or array now in edge rails we can specify hash also. So if we specify conditions as hash then it will generate conditions based on equality with SQL AND. Example: [source:ruby]User.find(:all, :conditions=>{:first_name => ‘akhil’, :role => ‘admin’}) [/source] will generate SQL as “where `first_name` = ‘akhil’ … Continue reading ActiveRecord finder: Now we can use hash as conditions

Delegation in rails

Published on

I don’t know why it is not mentioned any where in rails api, it could be very useful for all. This is straight from rails\activesupport\lib\active_support\core_ext\module\deligation.rb : Provides a delegate class method to easily expose contained objects’ methods as your own. Pass one or more methods (specified as symbols or strings) and the name of the … Continue reading Delegation in rails

Ruby script for creating new rails project and initial SVN import (with ignoring/removing log/other files)

Published on

Some days go I wrote a bash script for creating new rails project and initial SVN import (with ignoring/removing log/other files). And I received many comments if I could write a ruby script for this stuff. Hence here is the ruby script for creating new rails project and initial SVN import (with ignoring/removing log/other files). … Continue reading Ruby script for creating new rails project and initial SVN import (with ignoring/removing log/other files)