code
stringlengths
1
1.73M
language
stringclasses
1 value
class UserMailer < ActionMailer::Base def signup_notification(user) setup_email(user) @subject += 'Please activate your new account' @body[:url] = "http://YOURSITE/activate/#{user.activation_code}" end def activation(user) setup_email(user) @subject += 'Your account has been ac...
Ruby
class Manufacturer < ActiveRecord::Base end
Ruby
class UserObserver < ActiveRecord::Observer def after_create(user) UserMailer.deliver_signup_notification(user) end def after_save(user) UserMailer.deliver_activation(user) if user.recently_activated? end end
Ruby
require 'digest/sha1' class User < ActiveRecord::Base # Virtual attribute for the unencrypted password attr_accessor :password validates_presence_of :login, :email validates_presence_of :password, :if => :password_required? validates_presence_of :password_confirmation, :if ...
Ruby
class TriageNote < ActiveRecord::Base belongs_to :user belongs_to :repair_state belongs_to :assigned_to, :class_name => "User" end
Ruby
class CustomerRecord < ActiveRecord::Base belongs_to :user end
Ruby
class TemplatePart < ActiveRecord::Base end
Ruby
class RepairRecordsController < ApplicationController layout "backend" include PdfHelper def repair_list_partial if params[:list_name] == "rfp" @title = "Ready for Pickup" @records = RepairRecord.find(:all, :conditions => { :repair_state_id => "1" }) elsif params[:list_name] ==...
Ruby
class CmodelsController < ApplicationController layout "backend" def index @cmodels = Cmodel.find(:all) end def show @cmodel = Cmodel.find(params[:id]) end def new @cmodel = Cmodel.new @manufacturers = Manufacturer.find(:all) end def edit @cmodel = Cmodel.find(params[:id]) end de...
Ruby
class TemplatePartsController < ApplicationController # GET /template_parts # GET /template_parts.xml layout "backend" def index @template_parts = TemplatePart.find(:all) end # GET /template_parts/1 # GET /template_parts/1.xml def show @template_part = TemplatePart.find(params[:id]) respon...
Ruby
class TriageNotesController < ApplicationController # GET /triage_notes # GET /triage_notes.xml layout "backend" def index @triage_notes = TriageNote.find(:all) end # GET /triage_notes/1 # GET /triage_notes/1.xml def show @triage_note = TriageNote.find(params[:id]) respond_to do |format| ...
Ruby
class CustomerRecordsController < ApplicationController layout "backend" def index @customer_records = CustomerRecord.find(:all) end def show @customer_record = CustomerRecord.find(params[:id]) end def new @customer_record = CustomerRecord.new end def edit @customer_record = CustomerReco...
Ruby
class IssuesContainersController < ApplicationController # GET /issues_containers # GET /issues_containers.xml layout "backend" def index @issues_containers = IssuesContainer.find(:all) end # GET /issues_containers/1 # GET /issues_containers/1.xml def show @issues_container = IssuesContainer.fi...
Ruby
class UsersController < ApplicationController # render new.rhtml # skip_before_filter :login_required # uncomment here to add users to the system layout "backend" def new end def create cookies.delete :auth_token # protects against session fixation attacks, wreaks havoc with # request forgery ...
Ruby
class IssuesController < ApplicationController # GET /issues # GET /issues.xml layout "backend" def index @issues = Issue.find(:all) end # GET /issues/1 # GET /issues/1.xml def show @issue = Issue.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml ...
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 uses_tiny_mce helper :all # include all helpers, all the time include AuthenticatedSystem before_filter :...
Ruby
class ManufacturersController < ApplicationController # GET /manufacturers # GET /manufacturers.xml layout "backend" def index @manufacturers = Manufacturer.find(:all) end # GET /manufacturers/1 # GET /manufacturers/1.xml def show @manufacturer = Manufacturer.find(params[:id]) respond_to d...
Ruby
class RepairStatesController < ApplicationController # GET /repair_states # GET /repair_states.xml layout "backend" def index @repair_states = RepairState.find(:all) end # GET /repair_states/1 # GET /repair_states/1.xml def show @repair_state = RepairState.find(params[:id]) respond_to do |...
Ruby
class CustomerStatesController < ApplicationController # GET /customer_states # GET /customer_states.xml layout "backend" def index @customer_states = CustomerState.find(:all) end # GET /customer_states/1 # GET /customer_states/1.xml def show @customer_state = CustomerState.find(params[:id]) ...
Ruby
class PartStatesController < ApplicationController # GET /part_states # GET /part_states.xml layout "backend" def index @part_states = PartState.find(:all) end # GET /part_states/1 # GET /part_states/1.xml def show @part_state = PartState.find(params[:id]) respond_to do |format| form...
Ruby
class PartRecordsController < ApplicationController # GET /part_records # GET /part_records.xml layout "backend" def index @part_records = PartRecord.find(:all) end # GET /part_records/1 # GET /part_records/1.xml def show @part_record = PartRecord.find(params[:id]) respond_to do |format| ...
Ruby
# This controller handles the login/logout function of the site. class SessionsController < ApplicationController skip_before_filter :login_required # render new.rhtml def new end def create self.current_user = User.authenticate(params[:login], params[:password]) if logged_in? if params[:reme...
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
# These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full class name (including module namespa...
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
ActionController::Routing::Routes.draw do |map| map.resources :users map.resource :session map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil map.signup '/signup', :controller => 'users', :action => 'new' map.login '/login', :controller => 'se...
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
# 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.1...
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
# 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
module AuthenticatedSystem protected # Returns true or false if the user is logged in. # Preloads @current_user with the user model if they're logged in. def logged_in? !!current_user end # Accesses the current user from the session. # Future calls avoid the database because nil is not...
Ruby
# We use this chunk of controller code all over to generate PDF files. # # To stay DRY we placed it here instead of repeating it all over the place. # module PdfHelper require 'prince' private # Makes a pdf, returns it as data... def make_pdf(template_path, pdf_name, landscape=false) prince = Prince....
Ruby
module AuthenticatedTestHelper # Sets the current user in the session from the user fixtures. def login_as(user) @request.session[:user_id] = user ? users(user).id : nil end def authorize_as(user) @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials...
Ruby
# Prince XML Ruby interface. # http://www.princexml.com # # Library by Subimage Interactive - http://www.subimage.com # # # USAGE # ----------------------------------------------------------------------------- # prince = Prince.new() # html_string = render_to_string(:template => 'some_document') # send_data( # ...
Ruby
#!/usr/bin/ruby # MIT license # generate_xib_strings.rb # This script creates/clobbers a *.strings file for every XIB file in path argument. require 'FileUtils' # Check for arguments. if ARGV.length != 1 puts "Usage: ruby generate_xib_strings.rb path_to_lproj" exit end # Get path argument and 'cd' to that path. ...
Ruby
#!/usr/bin/ruby # MIT license # localize_xibs.rb # This script takes a set of localized strings and creates/clobbers existing localized XIBs # using the current English.lproj XIBs. require 'FileUtils' # Check for arguments. if ARGV.length != 2 puts "Usage: ruby localize_xibs.rb path_to_project path_to_strings" ex...
Ruby
#!/usr/bin/ruby # MIT license # localize_xibs_incremental.rb # This script takes a set of localized strings, a set of old and new English XIBs, and a set of current # localized XIBs and incrementally localizes the localized XIBs with the localized strings and the diff between # the old English XIBs and the new Engli...
Ruby
#!/usr/local/bin/ruby # encoding: UTF-8 # NOTE: requires ruby 1.9 # MIT license # validate_strings_files.rb # This script reads through the .strings files in a directory and identifies any bad characters inside, # both those that ibtool would catch and those that ibtool would miss. # * ibtool verbal errors: " ' : . /...
Ruby
#!/usr/local/bin/ruby # encoding: UTF-8 # NOTE: requires ruby 1.9 # MIT license # validate_strings_files.rb # This script reads through the .strings files in a directory and identifies any bad characters inside, # both those that ibtool would catch and those that ibtool would miss. # * ibtool verbal errors: " ' : . /...
Ruby
#!/usr/bin/ruby # MIT license # generate_xib_strings.rb # This script creates/clobbers a *.strings file for every XIB file in path argument. require 'FileUtils' # Check for arguments. if ARGV.length != 1 puts "Usage: ruby generate_xib_strings.rb path_to_lproj" exit end # Get path argument and 'cd' to that path. ...
Ruby
#!/usr/bin/ruby # MIT license # localize_xibs.rb # This script takes a set of localized strings and creates/clobbers existing localized XIBs # using the current English.lproj XIBs. require 'FileUtils' # Check for arguments. if ARGV.length != 2 puts "Usage: ruby localize_xibs.rb path_to_project path_to_strings" ex...
Ruby
#!/usr/bin/ruby # MIT license # localize_xibs_incremental.rb # This script takes a set of localized strings, a set of old and new English XIBs, and a set of current # localized XIBs and incrementally localizes the localized XIBs with the localized strings and the diff between # the old English XIBs and the new Engli...
Ruby
class CreateMembers < ActiveRecord::Migration def self.up create_table :members do |t| t.integer :person_id t.string :legitimacy_number t.timestamps end end def self.down drop_table :members end end
Ruby
class CreateCities < ActiveRecord::Migration def self.up create_table :cities do |t| t.string :name t.integer :country_id t.timestamps end end def self.down drop_table :cities end end
Ruby
class CreateLicenses < ActiveRecord::Migration def self.up create_table :licenses do |t| t.string :kind t.string :name t.timestamps end end def self.down drop_table :licenses end end
Ruby
class CreatePeopleLicenses < ActiveRecord::Migration def self.up create_table :people_licenses do |t| t.integer :person_id t.integer :license_id t.integer :year t.text :comment t.boolean :is_valid, :default => 1 t.timestamps end end def self.down drop_table :people...
Ruby
require 'active_record/fixtures' class LoadCitiesData < ActiveRecord::Migration def self.up down directory = File.join(File.dirname(__FILE__), "dev_data") Fixtures.create_fixtures(directory,"cities") end def self.down City.delete_all end end
Ruby
class CreatePeople < ActiveRecord::Migration def self.up create_table :people do |t| t.string :first_name t.string :last_name t.string :street t.string :house_number t.string :postcode t.integer :city_id t.string :personal_number t.string :phone t.string :emai...
Ruby
require 'active_record/fixtures' class LoadPeopleData < ActiveRecord::Migration def self.up down directory = File.join(File.dirname(__FILE__), "dev_data") Fixtures.create_fixtures(directory,"people") end def self.down Person.delete_all end end
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
#!D:/cmp/ruby/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 performance is severely impa...
Ruby
#!D:/cmp/ruby/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/log/fastcgi.crash.l...
Ruby
#!D:/cmp/ruby/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 performance is severely impa...
Ruby
#!D:/cmp/ruby/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 performance is severely impa...
Ruby
#!D:/cmp/ruby/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/log/fastcgi.crash.l...
Ruby
#!D:/cmp/ruby/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 performance is severely impa...
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' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" 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/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/destroy'
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/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
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/dbconsole'
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/plugin'
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/spawner'
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/reaper'
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/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/benchmarker'
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/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module Admin::PeopleHelper end
Ruby
module Admin::RallyLicencesHelper end
Ruby
module Admin::PeopleRallyLicencesHelper end
Ruby
module Admin::LicenseTypeHelper end
Ruby
module Admin::MembersHelper end
Ruby
module Admin::RefereeLicencesHelper end
Ruby
module Admin::PeopleRefereeLicencesHelper end
Ruby
class License < ActiveRecord::Base #zeby moc odczytac z klasy licencji dane o licencji kolesia has_one :people_license has_many :people_licenses has_many :people, :through => :people_licenses validates_presence_of :name, :message => "Musisz podać nazwę licencji!", :on => :save validates_presence_o...
Ruby
class Person < ActiveRecord::Base belongs_to :city has_one :member has_one :people_license has_one :license, :through => :people_license has_many :people_licenses has_many :licenses, :through => :people_licenses #wykorzystywane przy edycji osoby (pozwala operowac na person.rally_license): h...
Ruby
class Member < ActiveRecord::Base belongs_to :person validates_presence_of :legitimacy_number validates_numericality_of :legitimacy_number end
Ruby
class PeopleLicense < ActiveRecord::Base belongs_to :person belongs_to :license #nie dublowac polaczen #validates_uniqueness_of :year, :scope => ["person_id", "license_id"] end
Ruby
class City < ActiveRecord::Base has_many :people, :dependent => :nullify has_one :person #wykorzystywane przy zapisie osoby przypisanej do miasta validates_presence_of :name end
Ruby
class Admin::LicensesController < ApplicationController # GET /admin_licenses def index @rally_licenses = License.find(:all, :conditions => ['kind = ?', 'rajdowa']) @referee_licenses = License.find(:all, :conditions => ['kind = ?', 'sędziowska']) end # GET /admin_licenses/1 def show @l...
Ruby