$ rails g model User
belongs_to
has_one
| # Here's a contrived example of a LEFT JOIN using ARel. This is an example of | |
| # the mechanics, not a real-world use case. | |
| # NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord | |
| # extension that works for any named association. That's what I really wanted! | |
| # Go use that! Go: https://gist.github.com/ozydingo/70de96ad57ab69003446 | |
| # == DEFINITIONS | |
| # - A Taxi is a car for hire. A taxi has_many :passengers. | |
| # - A Passenger records one person riding in one taxi one time. It belongs_to :taxi. |
| global_variables.sort.each do |name| | |
| puts "#{name}: #{eval "#{name}.inspect"}" | |
| end |
| ## Prepare ################################################################### | |
| # Remove RVM | |
| rvm implode | |
| # Ensure your homebrew is working properly and up to date | |
| brew doctor | |
| brew update | |
| ## Install ################################################################### |
| #!/usr/bin/env ruby | |
| require 'spreadsheet' | |
| # Begin Test | |
| print "Spreadsheet Test\n" | |
| # Create the rows to be inserted | |
| row_1 = ['A1', 'B1'] | |
| row_2 = ['A2', 'B2'] |
| # Clone rbenv into ~/.rbenv | |
| git clone [email protected]:sstephenson/rbenv.git ~/.rbenv | |
| # Add rbenv to your PATH | |
| # NOTE: rbenv is *NOT* compatible with rvm, so you'll need to | |
| # remove rvm from your profile if it's present. (This is because | |
| # rvm overrides the `gem` command.) | |
| echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile | |
| exec $SHELL |
| curl localhost:9200/_search -d '{ | |
| "query" : { | |
| "filtered" : { | |
| "query" : {"match_all" : {}}, | |
| "filter" : { | |
| "or" : [ | |
| { | |
| "range" : { | |
| "file_size" : {"from" : 10, "to" : 10000} | |
| } |
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
| def easter | |
| y = Time.now.year | |
| c = y / 100 | |
| n = y - 19 * ( y / 19 ) | |
| k = ( c - 17 ) / 25 | |
| i = c - c / 4 - ( c - k ) / 3 + 19 * n + 15 | |
| i = i - 30 * ( i / 30 ) | |
| i = i - ( i / 28 ) * ( 1 - ( i / 28 ) * ( 29 / ( i + 1 ) ) * ( ( 21 - n ) / 11 ) ) | |
| j = y + y / 4 + i + 2 - c + c / 4 | |
| j = j - 7 * ( j / 7 ) |