RoR tricks

# HOW TO RUN A RAILS CONSOLE bundle exec rails c # HOW TO DISPLAY MODEL NAMES ActiveRecord::Base.connection.tables # HOW TO DISPLAY MODEL COLUMN NAMES [model_name].column_names # HOW TO DISPLAY ALL MODEL & MODEL COLUMN NAMES ActiveRecord::Base.connection.tables.each do |table_name| puts « \n » + table_name ActiveRecord::Base.connection.columns(table_name).each { |c| puts « –  » + c.name + « :  » +…

Ruby Tricks

## AVERAGE OF ARRAY a = [1,0,2,.,.,.,n] a.instance_eval { reduce(:+) / size.to_f } # HOW TO REMOVE NULL VALUES FROM ARRAY arr = [‘foo’, 0, nil, ‘bar’, 7, ‘baz’, nil] arr.compact arr.compact! arr #=> [‘foo’, 0, ‘bar’, 7, ‘baz’]

RVM Installation

# HOW TO SEE THE CURRENT RUBY VERSION ruby -v # HOW TO INSTALL RVM STABLE VERSION \curl -sSL https://get.rvm.io | bash -s stable –ruby source ~/.rvm/scripts/rvm # HOW TO INSTALL REQUIRE ELEMENTS rvm requirements # HOW TO LIST VERSION KNOWN rvm list known # HOW TO INSTALL RUBY rvm install ruby # HOW TO…