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 SessionsController < ApplicationController | |
def new | |
if member = Member.find_by_password_digest(cookies[:digest]) | |
session[:member_id] = member.id | |
redirect_to (session[:ref] || root_path), :notice => "Welcome back #{member.first_name}" | |
end | |
end | |
def create |
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
<h2>Log In</h2> | |
<%= form_tag sessions_path do %> | |
<div class="field"> | |
<%= label_tag :user_name %><br> | |
<%= text_field_tag :user_name, params['user_name'] %> | |
</div> | |
<p></p> | |
<div class="field"> | |
<%= label_tag :password %><br/> |
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/recipes/index.html.erb | |
#ERROR: undefined method `each' for #<Recipe:0x00000102e88a20> | |
<% @recipes.each do |recipe| %> | |
<tr> | |
<td>0001</td> | |
<td><%= recipe.name %></td> | |
<td><%= recipe.status %></td> | |
<td><%= recipe.due_on.strftime('%d %B') %></td> | |
<td><%= link_to "Show", user_recipe_path(recipe) %></td> |
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 CartController < ApplicationController | |
before_filter :login_required | |
before_filter :find_cart | |
def add | |
@cart.save if @cart.new_record? | |
session[:cart_id] = @cart.id | |
recipe = Recipe.find(params[:id]) | |
LineItem.create! :order => @cart, :recipe => recipe, :price => recipe.price | |
@cart.recalculate_price! |
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 Order < ActiveRecord::Base | |
has_many :line_items, :dependent => :destroy | |
belongs_to :user | |
attr_accessor :card_number, :card_type, :card_verification, :card_expires_on, :first_name, :last_name, :name, :address1,:city, :county, :country, :post_code | |
#VALIDATIONS | |
validate :validate_card, :on => :create | |
validate :card_verification, :presence => true |
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 'test/unit/assertions' | |
module Test | |
module Unit | |
# remove silly TestCase class | |
remove_const(:TestCase) if defined?(self::TestCase) | |
class TestCase < MiniTest::Unit::TestCase | |
include Assertions | |
def self.test_order |
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
Nelsons-MacBook-Pro:triplexxx the-crab$ ruby xxx.rb | |
> 1 + 1 | |
/Users/the-crab/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- term/ansicolor (LoadError) | |
from /Users/the-crab/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' | |
from /var/folders/vl/th7n8fdx6yv7npscx0qsvyhh0000gn/T/irb320120727-1310-18zk341:3 | |
1.8.7 => | |
1.9.2 => 2 | |
/Users/the-crab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- term/ansicolor (LoadError) | |
from /Users/the-crab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' | |
from /var/folders/vl/th7n8fdx6yv7npscx0qsvyhh0000gn/T/irb320120727-1310-18zk341:3:in `<main>' |
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
# encoding: utf-8 | |
# | |
# The job here was to seed the database with | |
# A mega list of business directory | |
# the directories have subdirectories | |
# The result is found on http://enterprisesthelena.com/directories | |
# What do you think? Is there a better way to do it? | |
require 'ap' | |
require 'csv' |
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
# encoding: utf-8 | |
# and afetr he had created everything and saw it was good | |
# ..."On the 6th day he made man and rested on the 7th day" | |
# so lets make some babies | |
class Person | |
def initialize(names, age, gender, status, job = 'Jobless for now') | |
@names = names | |
@age = age |
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 "application_responder" | |
class ApplicationController < ActionController::Base | |
# ... | |
def self.acts_as_magical | |
around_filter :magic_new, :only => :new | |
around_filter :magic_show, :only => :show | |
around_filter :magic_edit, :only => :edit |