This file contains 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
Week 4 | |
>rails g migration add_completed_to_ideas completed:boolean | |
> | |
<div class="field"> | |
<%= f.label :completed %><br /> | |
<%= f.check_box :completed %> | |
</div> | |
>rails g migration add_range_to_ideas range:integer | |
< | |
<div class="field"> |
This file contains 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 'brewery_db' | |
brewery_db = BreweryDB::Client.new do |config| | |
config.api_key = 'b7a3521dc50ce9c2e6c675dd896c276a' | |
end | |
=begin | |
abv = brewery_db.beers.all(abv: '5.5') | |
abv.each do |b| | |
puts b.name |
This file contains 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
#main.rb | |
require "./include.rb" | |
@board = Array.new | |
@board = {'ul' => 'ul', 'um' => 'um', 'ur' => 'ur', | |
'ml' => 'ml', 'mm' => 'mm', 'mr' => 'mr', | |
'll' => 'll', 'lm' => 'lm', 'lr' => 'lr'} | |
puts "Enter a move in the following sequence\n |
This file contains 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
#include.rb | |
def show_board | |
count = 0 | |
@board.each { |key, value| | |
print "#{value}" + " | " | |
if count == 2 or count == 5 then print "\n______________\n" end | |
count += 1 | |
} | |
print "\n" | |
end |
This file contains 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
A big thank you to anyone who has donated already - it is very truly appreciated. | |
My brother Nate is fighting stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (unpaid FMLA), no insurance coverage, and cannot afford treatment. Nate and his family need your help. Thank you. | |
Josh Goebel, Pastie creator | |
Donate now Read Nate's story Hide this message | |
Pastie Pastie << self Blog |
This file contains 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
app/views/tags/index.html.slim | |
==heatmap(@histogram) | |
app/models/tag.rb | |
has_many :user_votes, :through => :items | |
def frequency | |
self.user_votes.count | |
end |
This file contains 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
class Product < ActiveRecord::Base | |
#serialize :data, ActiveRecord::Coders::Hstore | |
attr_accessible :name, :category, :price, :description | |
validates_numericality_of :runtime, allow_blank: true | |
%w[author rating runtime].each do |key| | |
attr_accessible key | |
scope "has_#{key}", lambda { |value| where("properties @> (? => ?)", key, value) } | |
define_method(key) do |
This file contains 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
Started POST "/products" for 127.0.0.1 at 2012-06-26 08:56:23 -0400 | |
Processing by ProductsController#create as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"bheB/PpRy3HIjAaye8vR/VlpxgIrGG22P5TQjMdnf8k=", "product"=>{"name"=>"A Few Good Men", "price"=>"13.95", "author"=>"Aarron Sorrkin", "rating"=>"PG", "runtime"=>"3"}, "commit"=>"Create Product"} | |
(0.2ms) BEGIN | |
SQL (119.1ms) INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["created_at", Tue, 26 Jun 2012 12:56:23 UTC +00:00], ["name", "A Few Good Men"], ["price", 13], ["properties", {"author"=>"Aarron Sorrkin", "rating"=>"PG", "runtime"=>"3"}], ["updated_at", Tue, 26 Jun 2012 12:56:23 UTC +00:00]] | |
PG::Error: ERROR: Syntax error near 'a' at position 4 | |
: INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" | |
(0.2ms) ROLLBACK | |
Completed 500 Internal Server Error in 125ms |
This file contains 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
ubuntu@domU-12-31:/var/www/myrailsapp$ bundle exec rake routes | |
todos GET /todos(.:format) todos#index | |
POST /todos(.:format) todos#create | |
new_todo GET /todos/new(.:format) todos#new | |
edit_todo GET /todos/:id/edit(.:format) todos#edit | |
todo GET /todos/:id(.:format) todos#show | |
PUT /todos/:id(.:format) todos#update | |
DELETE /todos/:id(.:format) todos#destroy | |
ubuntu@domU-C:/var/www/myrailsapp$ apache2ctl -t -D DUMP_MODULES |
This file contains 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
http://localhost:58888/_emulator/_ide/login.html |