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
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 |
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
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' |
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
##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. |
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
## Inheritance ## | |
class Shape | |
attr_accessor :color | |
def initialize(color = nil) | |
@color = color || 'Red' | |
end | |
def larger_than?(shape) |
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
## 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" |
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
### 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 |