Ruby hacks/tricks

Get pry

Its like irb with super powers
gem install pry pry-doc

finding where require seeks scripts

ruby -e 'puts $:'

where gem files installed

gem environment or bundle show [gemname] inside your rails application

View all available rake tasks

rake --tasks

Showing rails routes in your browser

rake routes or http://localhost:3000/rails/info/routes during development in your browser

use gem in ruby script

I wanted to generate some random data for an app I was testing so I opted to use the ffaker gem. I found out it was easier than I expected. All you have to do is to include the gem, possibly the version and then require the gem afterwards.

gem 'ffaker' # You don't need this line to use in pry/irb 

require 'ffaker'

#### profit

10.times do
	puts  FFaker::Name.first_name
end 

Use better_errors gem

Its a lot nicer than the default error display in rails


group :development do
  gem "better_errors"
end

End of story