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 Client < User | |
# Authorization plugin | |
acts_as_authorized_user | |
acts_as_authorizable | |
has_and_belongs_to_many :appointments | |
has_and_belongs_to_many :roles, :join_table => 'roles_users', :foreign_key => 'user_id' | |
validates_presence_of :name |
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 Appointment < ActiveRecord::Base | |
... | |
attr_reader :availability | |
def self.availability | |
if availablity < 1 | |
puts 'class is full' | |
else | |
availability # return the current instance's availability | |
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
class Appointment < ActiveRecord::Base | |
attr_reader :availability | |
def full? | |
availability < 1 | |
end | |
end | |
# And then in your view | |
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
def join_link | |
return if @appointment.full? | |
return "#{link_to 'register', new_client_path} or #{link_to 'log in', '/login'} to join this class" if !current_user | |
return 'Incorrect role, must be a client to sign up for a class' if !current_user.has_role?('client') | |
return 'You are already signed up for this class' if current_user.appointments.include?(@appointment) | |
link_to 'join class', add_client_to_appointment | |
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
@products = Product.find(:all) | |
@products.each do |product| | |
product.update_attributes(params[:shipping_method]) | |
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
>> array = ["a", "b", "c", "d"] | |
=> ["a", "b", "c", "d"] | |
>> array.each do |el| array.shift end | |
=> ["c", "d"] |
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
--- | |
title: Lorem Ipsum | |
created_at: Wed Aug 29 08:57:00 -0600 2007 | |
filter: | |
- erb | |
- textile | |
--- | |
h2. <%= @page.title %> | |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum |
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
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__)) | |
gem 'activesupport' | |
require 'zlib' | |
require 'curb' | |
require 'sax-machine' | |
require 'dryopteris' | |
require 'uri' | |
require 'active_support/basic_object' |
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
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__)) | |
gem 'activesupport' | |
require 'zlib' | |
require 'curb' | |
require 'sax-machine' | |
require 'dryopteris' | |
require 'uri' | |
require 'active_support/basic_object' |
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
-- Starting monitor_rack -- | |
>> Writing PID to /var/run/stats_monitor.pid | |
>> Exiting! | |
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- /usr/lib/ruby/gems/1.8/gems/adamwiggins-rest-client-1.0/lib/restclient/mixin/response (LoadError) |
OlderNewer