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
#!/bin/bash | |
set -u | |
set -e | |
#change this below to your actual path. If you another environemnt like staging, fucking change N to -e staging instead. | |
APP_PATH=/youpath/to/app/root | |
PID=$APP_PATH/tmp/pids/unicorn.pid | |
OLD_PID=$APP_PATH/tmp/pids/unicorn.pid.oldbin | |
UNICORN_COMMAND="unicorn_rails -c $APP_PATH/config/unicorn.rb -D" | |
while getopts ":nsNr" opt; do |
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
;; el-get sourcing | |
(add-to-list 'load-path "~/.emacs.d/el-get") | |
(require 'el-get) | |
(setq el-get-sources | |
'(el-get | |
package | |
yasnippet | |
color-theme | |
color-theme-ir-black | |
color-theme-chocolate-rain |
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
class Post | |
has_many :comments | |
has_many :tags, :as => :taggable | |
class Comment | |
belongs_to :post | |
has_many :tags, :as => :taggable | |
class Tag | |
belongs_to :taggable, :polymorphic => true |
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
require 'test_helper' | |
class AuthenticationTest < ActionController::IntegrationTest | |
def log_and_say(user, arg) | |
login_on_admin(user.username, user.password) | |
assert_content arg | |
end | |
test "Login on admin with valid username, password and role" do | |
user = Factory.build(:user_admin) | |
log_and_say(user, "Welcome #{user.username}, logged in as #{user.role}") |
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
#Model Code | |
def self.calculate_state_revenue(state) | |
@affiliates = select_state(state) # gets all affiliates from the state | |
@orders_unpaginated = self.orders | |
#use inject to add up their order totals. | |
@state_total = @affiliates.inject {|result, affiilate| | |
result = @orders_unpaginated.calculate(:sum, "order_total", :conditions => ['affiliate_code = ?', affiliate.affiliate_code]) | |
result | |
} |
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
#controller method | |
@affiliates = @shop.affiliates.paginate(:page => params[:page], :order => "id desc", :include => :user) | |
#view trouble spot | |
<% for affiliate in @affiliates %> | |
<tr> | |
<td><%= link_to affiliate.user.email, admin_affiliate_path(affiliate) %></td> | |
</tr> | |
<% end %> |