This file contains hidden or 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 is an iterator. It invokes a block of code a certain amount of times. The amount of times | |
# it will invoke the block of code depends on the size of the collection (array or hash) it is called on. | |
# for example, calling each on an array could be done like this: | |
[1,2,3].each do |num| | |
puts num | |
end | |
# this returns: | |
1 |
This file contains hidden or 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
# these all accomplish the same goal. | |
def sum(numbers=[]) | |
sum = 0 | |
numbers.each { |i| sum += i } | |
sum | |
end | |
def sum(numbers=[]) | |
numbers.inject(0) { |sum,element| sum += element } |
This file contains hidden or 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
def rollback_packages | |
self.lines.each do |l| | |
l.packages each do |p| | |
puts "INside the nested deal" | |
begin | |
ActiveRecord::Base.transaction do | |
p.update_attributes(:sold => false, :line_id => nil) | |
end | |
rescue => e | |
self.errors[:base] << e.message |
This file contains hidden or 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
$("#follow_form").html("<%= escape_javascript(render('users/unfollow')) %>") | |
$("#followers").html('<%= @user.followers.count %>') |
This file contains hidden or 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
<div class="row"> | |
<div class="span6"> | |
<% if @meeting.started && [email protected]? %> | |
<%= content_for :javascripts do %> | |
<script> | |
var count = <%= @meeting.before_time %>; | |
var cost = <%= @meeting.cost %>; | |
</script> | |
<% end %> | |
<div class="live_input"> |
This file contains hidden or 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
rails new <name of app> -d postgresql | |
rails g scaffold User name:string | |
rake db:migrate | |
Install Postgres.app | |
brew install postgresql | |
Problem: FATAL: role "<name of app/db here>" does not exist | |
Solution: | |
cd /usr/lib |
This file contains hidden or 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
meeting_comments POST /meetings/:meeting_id/comments(.:format) comments#create | |
meeting_comment DELETE /meetings/:meeting_id/comments/:id(.:format) comments#destroy | |
meeting_meeting_users POST /meetings/:meeting_id/meeting_users(.:format) meeting_users#create | |
meeting_meeting_user PUT /meetings/:meeting_id/meeting_users/:id(.:format) meeting_users#update | |
DELETE /meetings/:meeting_id/meeting_users/:id(.:format) meeting_users#destroy | |
meetings GET /meetings(.:format) meetings#index | |
POST /meetings(.:format) meetings#create | |
new_meeting GET /meetings/new(.:format) meetings#new | |
edit_meeting GET /meetings/:id/edit(.:format) meetings#edit | |
meeting GET /meetings/:id(.:format) meetings#show |
This file contains hidden or 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
new-host-2:ltp mike$ brew remove postgresql | |
Uninstalling /usr/local/Cellar/postgresql/9.1.4... | |
new-host-2:ltp mike$ brew install postgresql | |
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.4/postgresql-9.1.4.tar.bz2 | |
Already downloaded: /Library/Caches/Homebrew/postgresql-9.1.4.tar.bz2 | |
==> Patching | |
patching file src/pl/plpython/Makefile | |
patching file contrib/uuid-ossp/uuid-ossp.c | |
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.4 --datadir=/usr/local/Cellar/postgresql | |
==> make install-world |
This file contains hidden or 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
https://devcenter.heroku.com/articles/multiple-environments | |
#=> just create a new git remote for ps-staging and then push to it | |
# PS local constants | |
store in config/initializers | |
add to gitignore | |
commit something.yml.sample to show the contents that the file should have, so other devs can run their own local instance |
This file contains hidden or 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
# install Foreman | |
gem install foreman | |
#bash | |
export CONSTANT_NAME='name' | |
export CONSTANT_SOMETHING_ELSE='something_else' | |
#in app root directory create Procfile, .env and .gitignore | |
#Procfile | |
web: bundle exec rails s -p $PORT |