bundle open gem_name
bundle open activesupport
control + l
command + k (mac)
Rails.app<tab> show all possible methods
ActiveRecord::Base.connection.tables
bundle show gem_name
bundle open gem_name
rake db:schema:dump
rake db:schema:load
rake -T
rake -T assets
rake -T db
bundle update gem_name
rails dbconsole
"".methods.grep(/case/).sort
ClassName.instance_methods
app
app.host
app.class
app.methods
app.method(:get).source_location
app.main_app
app.main_app.methods
app.root_path
app.root_url
app.user_path(3, sort: "yo yo") #=> "/users/3?sort=yo+yo"
app.name_path
app.project_path(Project.first)
app.get "/users/1"
app.response
app.response.header
app.response.body
app.response.redirect_url
app.session[:user_id]
app.cookies
app.flash
ApplicationController.allow_forgery_protection = false
app.post "/users/sign_in", email: "[email protected]", password: "foobar"
helper.methods.sort
helper.title_tag "Testing!"
helper.submit_tag
helper.link_to("Movies", app.movies_path)
helper.instance_variable_set :@project, Project.first
helper.pluralize 2, "story"
helper.javascript_debugging_options
helper.image_tag('test.png')
rails _4.0.0_ new app_name
Rails.application
Rails.application.config
reload!
rails console production --sandbox
rails server -p 3001
location = ModelName.instance_method(:method_name).source_location
subl #{location[0]}:#{location[1]}
User.where(:email => "[email protected]")
User.where("email" => "[email protected]")
User.where("email = '[email protected]'")
User.where("email = ?", "[email protected]")
User.where("users.email" => "[email protected]")
Rails.application.routes.routes
Rails.application.routes.named_routes.helpers
Rails.application.routes.recognize_path "/station/index/42.html"
=> {:controller=>"station", :action=>"index", :format=>"html", :id=>"42"}
Rails.application.generate(:controller => :station, :action=> :index, :id=>42)
=> /station/index/42
jobs
computer = OpenStruct.new(ram: '4 MB', hard_disk: '500 GB')
computer.ram ### => '4 MB'
computer[:hard_disk] ### => "500 GB"
### attributes can be created 'on the fly'
computer.screen = "1024x768"
computer.screen ### => "1024x768"
computer[:screen] ### => "1024x768"
>> helper.controller = OpenStruct.new(params: {})
=> #<OpenStruct params={}>
>> helper.javascript_debugging_options
=> {}
>> helper.controller = OpenStruct.new(params: {javascript_debugging: "enabled"})
=> #<OpenStruct params={:javascript_debugging=>"enabled"}>
>> helper.javascript_debugging_options
=> {:debug=>true, :digest=>false}
>> 1 + 1
=> 2
>> _
=> 2
>> _ * _
=> 4
ri File
ri Fil
ri File.directory?
ri Socket#accept
ri ActiveRecord::Base.touch
gem rdoc --all --ri --no-rdocs
sql = "Select * from ... your sql query here"
records_array = ActiveRecord::Base.connection.execute(sql)
#=> returns PostgreSQLG/MySQL result object
records_array.to_a
rake db:migrate VERSION=0
Dir.pwd
Dir["your-directory/**/*"].length
###Resources:
http://pragmaticstudio.com/blog/2014/3/11/console-shortcuts-tips-tricks
https://signalvnoise.com/posts/3176-three-quick-rails-console-tips
http://api.rubyonrails.org/classes/ActionDispatch/Integration/RequestHelpers.html
http://api.rubyonrails.org/classes/Rails/ConsoleMethods.html
http://errtheblog.com/posts/24-irb-mix-tape
http://errtheblog.com/posts/41-real-console-helpers
http://www.happybearsoftware.com/assorted-ruby-tips-and-tricks.html
http://www.blackbytes.info/2015/06/using-struct-and-openstruct/
http://ruby-doc.org/stdlib-2.0.0/libdoc/ostruct/rdoc/OpenStruct.html
http://stackoverflow.com/questions/4929078/how-to-sign-in-a-user-using-devise-from-a-rails-console
http://jacopretorius.net/2014/02/all-rails-db-rake-tasks-and-what-they-do.html
Also
User.where(email: "[email protected]")