code
stringlengths
1
1.73M
language
stringclasses
1 value
module ActiveMerchant module Billing module AuthorizeNetCimAPI def self.included(base) Base.generate_all_attr_accessors! end class Base include Validateable class_inheritable_accessor :scalar_attributes, :composite_attributes self.scalar_attributes =...
Ruby
module ActiveMerchant module Billing module AuthorizeNetCimAPI ID_CONDITION = [/^\d+$/, 'must be a number'] class CreateCustomerProfile < Request self.composite_attributes << [ :profile, true, CustomerProfile] end class CreateCustomerPaymentProfile < Request s...
Ruby
class ANAPIWrapper attr_accessor :id, :data class_inheritable_accessor :wrapped GATEWAY = ActiveMerchant::Billing::AuthorizeNetCimGateway.new :login => 'xxx', :password => 'xxx' self.wrapped = nil def method_missing(method, *args, &blk) @data.send(method, *args, &blk) end def wrapped self...
Ruby
module ActiveMerchant module Billing module AuthorizeNetCimAPI module Address def self.included(base) base.scalar_attributes.concat SCALAR_ATTRIBUTES end def self.default_conditions(max=50) [false, /^.{1,#{max}}$/, "must be between 1 and #{max} characters (no sym...
Ruby
require 'active_merchant' Dir[ File.join( File.dirname(__FILE__), "/authorize_net_cim/*") ].each { |p| require p }
Ruby
require 'osx/cocoa' include OSX inPath = "/Users/aptiva/Desktop/ActiveRecord/English.lproj/irregulars.plist" outPath = "/Users/aptiva/Desktop/ActiveRecord/English.lproj/reverse irregulars.plist" original = NSArray.arrayWithContentsOfFile inPath reverseEnum = original.reverseObjectEnumerator reversed = NSMutableArray....
Ruby
# Include hook code here require 'acts_as_summarizable_japanese'
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_summarizable_japanese plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the ...
Ruby
# desc "Explaining what the task does" # task :acts_as_summarizable_japanese do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
# Install hook code here
Ruby
# ActsAsSummarizableJapanese #Copyright(c) 2007 殊海夕音( http://ame.yumenosora.net/ ) # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # # 1 Redistributions of source code must retain the above copyright notice, this l...
Ruby
# Include hook code here require 'acts_as_summarizable_japanese'
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_summarizable_japanese plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the ...
Ruby
# desc "Explaining what the task does" # task :acts_as_summarizable_japanese do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
# Install hook code here
Ruby
# ActsAsSummarizableJapanese #Copyright(c) 2007 殊海夕音( http://ame.yumenosora.net/ ) # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # # 1 Redistributions of source code must retain the above copyright notice, this l...
Ruby
class <%= migration_name %> < ActiveRecord::Migration def self.up <%= class_name %>.add_authentable_fields end def self.down <%= class_name %>.remove_authentable_fields end end
Ruby
class AuthentableGenerator < Rails::Generator::NamedBase def manifest record do |m| camelized_class_name = class_name.pluralize.gsub(/::/, '') underscored_file_path = file_path.gsub(/\//, '_').pluralize m.migration_template 'migration.rb', 'db/migrate', :assigns => { :migration_name ...
Ruby
ActiveRecord::Schema.define(:version => 0) do create_table "users", :force => true do |t| t.string "login" t.string "crypted_password" t.string "remember_token" t.datetime "remember_token_expires_at" end end
Ruby
class AddAuthentableFields < ActiveRecord::Migration def self.up Person.add_authentable_fields end def self.down Person.remove_authentable_fields end end
Ruby
class CreatePeople < ActiveRecord::Migration def self.up create_table "people" do |t| t.string :name t.timestamps end end def self.down drop_table "people" end end
Ruby
class User < ActiveRecord::Base acts_as_authentable end
Ruby
class Person < ActiveRecord::Base end
Ruby
# This controller handles the login/logout function of the site. class SessionsController < ActionController::Base # render new.rhtml def new end def create self.current_user = User.authenticate(params[:login], params[:password]) if logged_in? if params[:remember_me] == "1" self.curren...
Ruby
class UsersController < ActionController::Base # render new.rhtml def new end def create @user = User.new(params[:user]) @user.save! self.current_user = @user redirect_back_or_default('/') flash[:notice] = "Thanks for signing up!" rescue ActiveRecord::RecordInvalid render :action => ...
Ruby
ActionController::Routing::Routes.draw do |map| map.resources :users # Singleton resource. A user can only have one session. map.resource :session end
Ruby
# Rails environment configuration and loading. ENV["RAILS_ENV"] ||= "test" dir = File.dirname(__FILE__) require "#{dir}/../../../../config/environment" # Database configuration and schema loading. dbconfig = YAML::load(IO.read("#{dir}/resources/config/database.yml")) ActiveRecord::Base.configurations = {'test' => dbc...
Ruby
puts IO.read(File.join(File.dirname(__FILE__), 'README'))
Ruby
require 'rake' require 'rake/rdoctask' desc 'Generate documentation for the bcrypt_authentication plugin.' Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'BcryptAuthentication' rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_files.include('MIT-LICENSE') rdoc.rdoc_f...
Ruby
%w(acts_as_authentable authentable_entity authenticated_system).each do |file| require file end ActionController::Base.send :include, AuthenticatedSystem ActionController::Base.send :filter_parameter_logging, :password ActiveRecord::Base.send :include, ActiveRecord::Acts::Authentable
Ruby
require 'bcrypt' module AuthentableEntity include BCrypt def self.included(authentable) authentable.class_eval do # Virtual attribute for the unencrypted password. attr_accessor :password validates_presence_of :login validates_length_of :login, :within => 3..40 validates_u...
Ruby
module ActiveRecord #:nodoc: module Acts #:nodoc: module Authentable def self.included(base) # :nodoc: base.extend ClassMethods end module ClassMethods def acts_as_authentable send :include, AuthentableEntity end COLUMNS = { :login => :string, ...
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 != :false end # Accesses the current user from the session. Set it to :false if login fails # so tha...
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): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
Ruby
# Set the default text field size when input is a string. Default is 50. # Formtastic::SemanticFormBuilder.default_text_field_size = 50 # Should all fields be considered "required" by default? # Defaults to true, see ValidationReflection notes below. # Formtastic::SemanticFormBuilder.all_fields_required_by_default = t...
Ruby
# Be sure to restart your server when you modify this file. # 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. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveReco...
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
# Be sure to restart your server when you modify this file. # Your secret key for verifying cookie session data integrity. # If you change this key, all old sessions will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Act...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying do debug a probl...
Ruby
#require "#{File.dirname(__FILE__)}/../vendor/bundler_gems/environment"
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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
# Edit at your own peril - it's recommended to regenerate this file # in the future when you upgrade to a newer version of Cucumber. # IMPORTANT: Setting config.cache_classes to false is known to # break Cucumber's use_transactional_fixtures method. # For more information see https://rspec.lighthouseapp.com/projects/1...
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 # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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| map.with_options :controller => :user_sessions do |u| u.login '/login', :action => :new, :conditions => {:method => :get} u.connect '/login', :action => :create, :conditions => {:method => :post} u.logout '/logout', :action => :destroy, :conditions...
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): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
Ruby
# Set the default text field size when input is a string. Default is 50. # Formtastic::SemanticFormBuilder.default_text_field_size = 50 # Should all fields be considered "required" by default? # Defaults to true, see ValidationReflection notes below. # Formtastic::SemanticFormBuilder.all_fields_required_by_default = t...
Ruby
# Be sure to restart your server when you modify this file. # 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. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveReco...
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
# Be sure to restart your server when you modify this file. # Your secret key for verifying cookie session data integrity. # If you change this key, all old sessions will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Act...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying do debug a probl...
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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
# Edit at your own peril - it's recommended to regenerate this file # in the future when you upgrade to a newer version of Cucumber. # IMPORTANT: Setting config.cache_classes to false is known to # break Cucumber's use_transactional_fixtures method. # For more information see https://rspec.lighthouseapp.com/projects/1...
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 # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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| map.with_options :controller => :user_sessions do |m| m.login '/login', :action => :new, :conditions => {:method => :get} m.connect '/login', :action => :create, :conditions => {:method => :post} m.logout '/logout', :action => :destroy, :conditions => {:meth...
Ruby
module NavigationHelpers # Maps a name to a path. Used by the # # When /^I go to (.+)$/ do |page_name| # # step definition in web_steps.rb # def path_to(page_name) case page_name when /the home\s?page/ '/' # Add more mappings here. # Here is an example that pulls values o...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module UsersHelper end
Ruby
module UserSessionsHelper end
Ruby
module PagesHelper end
Ruby
class Status < ActiveRecord::Base has_many :users end
Ruby
class User < ActiveRecord::Base acts_as_authentic acts_as_tree belongs_to :organization belongs_to :status belongs_to :employment belongs_to :service_branch belongs_to :rank before_destroy :reassign_children named_scope :active, :conditions => "deleted_at IS NULL" named_scope :deleted, :con...
Ruby
class ServiceBranch < ActiveRecord::Base has_many :users has_many :ranks accepts_nested_attributes_for :ranks end
Ruby
class Ability include CanCan::Ability def initialize(user) can :read, User can [:read, :update], User do |other_user| user.supervises?(other_user) end if user.squadron_admin can :manage, User else if user.organization_admin # org admin's can only ma...
Ruby
class Organization < ActiveRecord::Base has_many :users end
Ruby
class UserSession < Authlogic::Session::Base end
Ruby
class Rank < ActiveRecord::Base belongs_to :service_branch has_many :users end
Ruby
class Employment < ActiveRecord::Base has_many :users end
Ruby
class UserSessionsController < ApplicationController before_filter :login_required, :only => :destroy def new @user_session = UserSession.new end def create @user_session = UserSession.new(params[:user_session]) if @user_session.save flash[:notice] = "Logged in successfully" redire...
Ruby
class PagesController < ApplicationController def home end end
Ruby
# When an error happens in a rails created form field, it normally gets # surrounded by a <div> tag, but this changes it to a <span>. ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag| "<span class='field_error'>#{html_tag}</span>" end # Don't colorize logging, because it creates a mess in wind...
Ruby
class UsersController < ApplicationController before_filter :login_required def index @users = User.active.all end def show @user = User.active.find(params[:id]) end def new @user = User.new end def create @user = User.new(params[:user]) unless @user.manually_set_password?...
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.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)} require 'rubygems' unless ENV['NO_RUBYGEMS'] else gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 ENV["RAILS_ENV"] ||= 'test' require File.expand_path(File.dirname(__FILE__) + "/../config/enviro...
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first if vendored_cucumber_bin load File.expand_path(vendored_cucumber_bin) else require 'rubygems' unless ENV['NO_RUBYGEMS'] require 'cucumber' load Cucumber::BINARY end
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 ENV['RSPEC'] = 'true' # allows autotest to discover rspec ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) || $stderr.puts("Unable to find auto...
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby