Skip to content

Instantly share code, notes, and snippets.

@oneawayman
oneawayman / gist:9583026
Created March 16, 2014 13:14
routes.rb
Bloccit::Application.routes.draw do
get "comments/create"
devise_for :users
resources :topics do
resources :posts, except: [:index] do
resources :comments, only: [:create, :destroy]
end
end
vagrant@rails-dev-box:~/code/bloccit$ heroku logs
2014-02-24T14:54:03.388386+00:00 app[web.1]: I, [2014-02-24T14:54:03.372808 #2]
INFO -- :
2014-02-24T14:54:03.390650+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.0.0/lib/active_support/callbacks.rb:433:in `_run__75732319911216951
7__process_action__callbacks'
2014-02-24T14:54:03.391393+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
2014-02-24T14:54:03.391677+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.0.0/lib/abstract_controller/base.rb:136:in `process'
@oneawayman
oneawayman / blocks
Last active August 29, 2015 13:56
Bloc Web Development Blocks Checkpoint
##Sorting
# This method should take an array of strings or hashes as an argument, and sort each element by its length
def sort_by_length(sort_this_array)
sort_this_array.sort { |x,y| x.length <=> y.length }
end
# Create method named filter that takes an array of numbers as an argument
# and returns an array consisting of numbers that are greater than 5.
@oneawayman
oneawayman / advancedclasses
Created February 6, 2014 13:19
Bloc Web Development Advanced Classes Checkpoint
## Inheritance ##
class Shape
attr_accessor :color
def initialize(color = nil)
@color = color || 'Red'
end
def larger_than?(shape)
@oneawayman
oneawayman / hashes
Last active August 29, 2015 13:56
Bloc Web Development Hashes Checkpoint
## Setting Attributes ##
class User
attr_accessor :name, :email, :bio, :age, :sex
def initialize(config = {})
@name = config[:name] || "n/a"
@email = config[:email] || "n/a"
@bio = config[:bio] || "n/a"
@age = config[:age] || "n/a"
@oneawayman
oneawayman / loops
Last active August 29, 2015 13:55
Bloc Web Development Loops Checkpoint
### The Each Method ###
# Add a method named sum_numbers to the Array class.
# The method should sum all of the numbers in the Array that it's called on.
class Array
def sum_numbers
start=0
self.each do |sum|
start += sum