- bullet
- bullet 2
##page 2
- Some Ruby code examples
['a', 'b'].map { |x| x.uppercase }| If we have nils for taggable_id in tag_items, then when I go to | |
| http://localhost:3000/collection_items/b | |
| the server log looks OK, like this (hey I only put this in for comparison, | |
| no need to read it (yet?)), skip on below | |
| ~/01rails/social-museum 0 $ rails s | |
| => Booting Puma | |
| => Rails 4.1.4 application starting in development on http://0.0.0.0:3000 | |
| => Run `rails server -h` for more startup options |
| current code https://github.com/markfeedly/social-museum/tree/update-mail | |
| rake routes | |
| user_session POST /users/sign_in(.:format) devise/sessions#create | |
| devise sessions controller | |
| # POST /resource/sign_in | |
| def create |
| OK Ive created a Subscription model, and expect somewhat to hang stuff off there | |
| class Subscription < ActiveRecord::Base | |
| belongs_to :user | |
| belongs_to :page | |
| end | |
| There is an indexed id in the table cause I created it thus | |
| class CreateSubscriptionsTable < ActiveRecord::Migration |
| # so I want to dry up this kind of method, which occurs only four times, but since I anticipate using this construct a few more times, and page.rb is looking long, the effort of metaprogramming seems worthwhile | |
| # with I guess moving the defn of spec attr acessor out into an included module | |
| # so here is the code to dry, shown for categories | |
| def categories=(c) | |
| if history.last.try(:new_record?) | |
| history.last.categories = c | |
| else |
| For someone who denies being able to see into the future, Sutherland has a remarkable record of helping to create it. In the late 1960s, the Bell Helicopter Company used low-light cameras to help pilots land at night, and devised a system which turned the camera when the pilot turned his head. Sutherland, by then a professor at the University of Utah, wondered why the camera couldn’t be replaced with a computer. With the assistance of Bob Sproull, he created a gizmo — with the wonderful name The Sword of Damocles — which let a user peer into a computer-generated graphical display which, like Bell’s remote camera, adjusted automatically to head turns. | |
| [http://timenerdworld.files.wordpress.com/2013/04/image2.jpg 640] |
| require 'rspec/autorun' | |
| class WareHouse | |
| attr_reader :quantity | |
| def initialize | |
| @quantity = 0 | |
| end | |
| end |
| mark@T410s-a:~/01rails/virtual-museum$ cucumber | |
| WARN: Unresolved specs during Gem::Specification.reset: | |
| tzinfo (~> 0.3.37) | |
| minitest (~> 4.2) | |
| arel (~> 4.0.0) | |
| polyglot (>= 0.3.1) | |
| rake (>= 0.8.7) | |
| sprockets (~> 2.8) | |
| atomic (< 2, >= 1.1.7) | |
| WARN: Clearing out unresolved specs. |
| require 'sinatra' | |
| require 'open-uri' | |
| get '/' do | |
| @result = open("http://whatthecommit.com/index.txt").read | |
| erb :index | |
| end | |
| __END__ |
| rake db:drop | |
| rake db:setup | |
| rake db:test:prepare |