code
stringlengths
1
1.73M
language
stringclasses
1 value
class UserController < ApplicationController require 'digest/sha1' before_filter :admin_required, :only => [:destroy] before_filter :login_required, :only => [:edit, :update] before_filter :find_user, :except => [:index, :new, :create] before_filter :confirm_user_owns_record, :only => [:edit, :update] ...
Ruby
class SessionsController < ApplicationController def new end def create @current_user = User.authenticate(params[:user_email], params[:user_password]) if @current_user session[:user] = @current_user.id redirect_to :controller => "user", :action => "show", :id => @current...
Ruby
class TicketsController < ApplicationController def index end def show end def new end def edit end end
Ruby
class EventsController < ApplicationController def index @upcoming_events = Events.upcoming_events end #new events def new @events = Events.new end #show events def show @events = Events.find(params[:id]) end #create new events def create @events = Events.new(params[:events]) if @events.save ...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base protect_from_forgery before_filter :initialize_user # make these available as ActionView helper met...
Ruby
class TeamController < ApplicationController before_filter :admin_required, :except => [:index, :show] def index @current_players = Team.current_players end def new @team = Team.new end def show @team = Team.find(params[:id]) end def create @team = Team.new(params[:team]) if @team.save ...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :user_name t.string :user_email t.string :user_password t.boolean :user_admin, :default => false t.text :profile, :text t.timestamps end end def self.down drop_table :users end end
Ruby
class AddSaltToManager < ActiveRecord::Migration def self.up rename_column :managers, :m_password, :encrypted_password add_column :managers, :salt, :string end def self.down remove_column :managers, :salt rename_column :managers, :encrypted_password, :m_password end end
Ruby
class CreateTeams < ActiveRecord::Migration def self.up create_table :teams do |t| t.string :name t.integer :number t.string :position t.integer :goals t.integer :assists t.integer :points t.timestamps end end def self.down drop_table :teams end end
Ruby
class CreateSchedules < ActiveRecord::Migration def self.up create_table :schedules do |t| t.date :game_date t.string :game_type t.string :opponent t.timestamps end end def self.down drop_table :schedules end end
Ruby
class AddSaltToUsers < ActiveRecord::Migration def self.up rename_column :users, :user_password, :encrypted_password add_column :users, :salt, :string end def self.down remove_column :users, :salt rename_column :users, :encrypted_password, :user_password end end
Ruby
class CreateTickets < ActiveRecord::Migration def self.up create_table :tickets do |t| t.float :ticket_price t.float :ticket_amount t.integer :ticket_section t.integer :ticket_row t.integer :ticket_seat t.integer :game_id t.integer :user_id t.timestamps end add_index :tickets, :game_id add_ind...
Ruby
class CreateManagers < ActiveRecord::Migration def self.up create_table :managers do |t| t.string :m_name t.string :m_password t.text :m_profile, :text t.boolean :m_admin, :default => true t.timestamps end end def self.down drop_table :managers end end
Ruby
class CreateNews < ActiveRecord::Migration def self.up create_table :news do |t| t.string :title t.text :Contents t.timestamps end end def self.down drop_table :news end end
Ruby
class CreateEvents < ActiveRecord::Migration def self.up create_table :events do |t| t.date :event_date t.string :event_location t.text :event_details t.timestamps end end def self.down drop_table :events end end
Ruby
#!/usr/bin/ruby1.8 #!/usr/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performan...
Ruby
#!/usr/bin/ruby1.8 #!/usr/local/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # i...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Be sure to restart your server when you modify this file # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.0...
Ruby
# Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? ...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module GamesHelper def no_games(games) content_tag('li', "No Games") if games.empty? end end
Ruby
module TeamHelper def no_players(teams) content_tag('li', "No Players") if teams.empty? end end
Ruby
module PracticeHelper def no_practice(practice) content_tag('li', "No Practice") if practice.empty? end end
Ruby
class Practice < ActiveRecord::Base #show new practices def self.upcoming_practice find(:all, :conditions => "practice_date > CURRENT_TIMESTAMP()", :order => "practice_date") end #show past practices def self.past_practice find(:all, :conditions => "practice_date <= CURRENT_TIMESTAMP()", :order =...
Ruby
class Team < ActiveRecord::Base #show the roster def self.current_players find(:all, :order => "name") end #validate players name validates_presence_of :name #validates players position validates_presence_of :position #validates players number validates_presence_of :number #taggable plugin acts_as_taggable belong...
Ruby
class Manager < ActiveRecord::Base end
Ruby
class Game < ActiveRecord::Base #validation for the games location has to exist validates_presence_of :game_location #validation for the games opponent has to exist validates_presence_of :game_opponent #find and show new games def self.upcoming_games find(:all, :conditions => "game_date > CURRENT_TIMESTAMP()", ...
Ruby
class GamesController < ApplicationController def index @upcoming_games = Game.upcoming_games @past_games = Game.past_games end #new game def new @game = Game.new end #show games def show @game = Game.find(params[:id]) end #create new games def create @game = Game.new(params[:game]) if @game.save ...
Ruby
class PracticeController < ApplicationController def index @upcoming_practice = Practice.upcoming_practice @past_practice = Practice.past_practice end def new @practice = Practice.new end def show @practice = Practice.find(params[:id]) end def create @practice = Practice.new(params[:practice]) i...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for details...
Ruby
class TeamController < ApplicationController def index @current_players = Team.current_players end def new @team = Team.new end def show @team = Team.find(params[:id]) @tag = @team.tag_list end def create @team = Team.new(params[:team]) if @team.save flash[:notice] = 'Player Added to Ros...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
class CreateTeams < ActiveRecord::Migration def self.up create_table :teams do |t| t.string :name t.string :position t.string :number t.timestamps end end def self.down drop_table :teams end end
Ruby
class CreateManagers < ActiveRecord::Migration def self.up create_table :managers do |t| t.string :email t.string :password t.string :name t.timestamps end end def self.down drop_table :managers end end
Ruby
class ActsAsTaggableMigration < ActiveRecord::Migration def self.up create_table :tags do |t| t.column :name, :string end create_table :taggings do |t| t.column :tag_id, :integer t.column :taggable_id, :integer # You should make sure that the column created is...
Ruby
class CreatePractices < ActiveRecord::Migration def self.up create_table :practices do |t| t.date :practice_date t.string :practice_location t.timestamps end end def self.down drop_table :practices end end
Ruby
class CreateGames < ActiveRecord::Migration def self.up create_table :games do |t| t.date :game_date t.string :game_location t.string :game_opponent t.timestamps end end def self.down drop_table :games end end
Ruby
#!/usr/bin/ruby1.8 #!/usr/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performan...
Ruby
#!/usr/bin/ruby1.8 #!/usr/local/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby