Ruby file accepts from command prompt in the form of array.Passing parametersruby input.rb TOI DH TimesNewAccessing parameters # input.rb p ARGV # => ["TOI", "DH", "TimesNew"] p ARGV[0] # => "TOI" p ARGV[1] # => "DH"Optparser : parses commandline options in more effective way using OptParser class.and we can access options as hashed parameters.Passing parametersruby … Continue reading Passing commandline parameter (arguments) to ruby file using optparser
Month: November 2009
How to get all associted models of rails model
I have Site Model and i wanted to find all associated models of Site model which are having belongs_to relationship.After doing lot headache, here is the solution i foundhas_many models of Site Model Site.reflect_on_all_associations.map{|mac| mac.class_name if mac.macro==:has_many}.compact=> ["Layout", "User", "SubmenuLink", "Snippet", "Asset"]belongs_to model of Site ModelSite.reflect_on_all_associations.map{|mac| mac.class_name if mac.macro==:belongs_to}.compact=> ["User", "Page", "User"]To get all associationsSite.reflect_on_all_associations.map{|mac| … Continue reading How to get all associted models of rails model
Cricket challenge flash game
Advanced cricket flash gamehttp://img.bollywoodsargam.com/games/files/game_4f2a798477213b30a4802e716e31a9a6.swf
