Difference between revisions of "Cs169x"

From Wiki2
Line 1: Line 1:
Inspect database schema
rakedb:schema:dump
Create a model interaction diagram automatically
gem install railroady
http://salty-castle-8378.herokuapp.com admin tv8J31j oZ1XktJ now 6j
http://salty-castle-8378.herokuapp.com admin tv8J31j oZ1XktJ now 6j



Revision as of 15:09, 27 August 2013

Inspect database schema

rakedb:schema:dump

Create a model interaction diagram automatically

gem install railroady

http://salty-castle-8378.herokuapp.com admin tv8J31j oZ1XktJ now 6j

Recall Rails Cookery #2: adding new feature == new route+new controller method+new view

"string", %Q{string}, 'string', %q{string} a=41 ; "The answer is #{a+1}"

  • match a string against a regexp:

"fox@berkeley.EDU" =~ /(.*)@(.*)\.edu$/i /(.*)@(.*)\.edu$/i =~ "fox@berkeley.EDU"

  • If no match, value is false
  • If match, value is non-false, and $1...$n capture

parenthesized groups ($1 == 'fox', $2 == 'berkeley') /(.*)$/i or %r{(.*)$}i or Regexp.new('(.*)$', Regexp::IGNORECASE)

  • a.b means: call method b on object a
  • hashes

h = {"stupid" => 1, :example=> "foo" } h.has_key?("stupid") # => true h["not a key"] # => nil h.delete(:example) # => "foo"

arrays

http://www.techotopia.com/index.php/Advanced_Ruby_Arrays