| ⌘T | go to file |
| ⌘⌃P | go to project |
| ⌘R | go to methods |
| ⌃G | go to line |
| ⌘KB | toggle side bar |
| ⌘⇧P | command prompt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'goliath' | |
| require 'http_router' | |
| # https://github.com/joshbuddy/http_router | |
| HttpRouter::Rack.override_rack_builder! | |
| class RackRoutes < Goliath::API | |
| map('/get/:id') do |env| | |
| [200, {'Content-type' => 'text/plain'}, ["My id is #{env['router.params'][:id]}\n"]] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def reify_has_manys(model, lookback) | |
| model.class.reflect_on_all_associations(:has_many).each do |assoc| | |
| # Get live children. | |
| children = model.send assoc.name | |
| # Ensure child models are using PaperTrail. | |
| if children.first.respond_to? :version_at | |
| # Handle updated children, and children created since the parent's version. | |
| children_then = [] | |
| children.each do |child| | |
| if (child_as_it_was = child.version_at(created_at - lookback.seconds)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') | |
| rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) | |
| rvm_lib_path = File.join(rvm_path, 'lib') | |
| # Differentiate between new and old passenger versions | |
| if File.exist?(File.join(rvm_lib_path, "rvm", "environment.rb")) | |
| $LOAD_PATH.unshift rvm_lib_path | |
| require 'rvm' | |
| RVM.use_from_path! Dir.pwd # Passenger starts in the app root | |
| end | |
| end |