code
stringlengths
1
1.73M
language
stringclasses
1 value
module HomelessHelper end
Ruby
module ReportsHelper end
Ruby
module HomeHelper end
Ruby
module MapHelper end
Ruby
require 'geocoder' class Homeless < ActiveRecord::Base attr_accessible :address, :district, :email, :latitude, :longitude, :representative, :nearby, :gender, :office, :twitter, :phone reverse_geocoded_by :latitude, :longitude after_validation :fetch_address end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery end
Ruby
class MapController < ApplicationController def index @json = Homeless.all.to_gmaps4rails end end
Ruby
class HomeController < ApplicationController def index end end
Ruby
require 'sunlight' class HomelessesController < ApplicationController def show homeless = Homeless.find(params[:id]) homeless.nearby = homeless.nearbys(5).count homeless.save @homeless = homeless end def nearby homeless = Homeless.find(params[:id]) @homelesses = homeless.nearbys(params...
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
# 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 to debug a probl...
Ruby
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters ...
Ruby
require 'rubygems' require 'sunlight' Sunlight::Base.api_key = '9cff91d60f004d8e9137cabd5230fc9f'
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies 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 attac...
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
Geocoder.configure( # geocoding service (see below for supported options): :lookup => :google, # to use an API key: #:api_key => "AIzaSyDL7sXPDxLVFbu74x7lwMPPeQoGPaal76w", # geocoding service request timeout, in seconds (default 3): #:timeout => 5, )
Ruby
# Be sure to restart your server when you modify this file. GrumpyCat::Application.config.session_store :cookie_store, key: '_GrumpyCat_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rai...
Ruby
GrumpyCat::Application.routes.draw do get "home/index" resources :map resources :homelesses match 'homeless/:lat/:long/:count' => 'homelesses#create' match 'homeless/:id/:distance' => 'homelesses#nearby' # The priority is based upon order of creation: # first created -> highest priority. # Sample of...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.requi...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application GrumpyCat::Application.initialize!
Ruby
GrumpyCat::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.acti...
Ruby
GrumpyCat::Application.configure do # Settings specified here will take precedence over those in config/application.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 web ...
Ruby
GrumpyCat::Application.configure do # Settings specified here will take precedence over those in config/application.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 ...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run GrumpyCat::Application
Ruby
#!/usr/bin/env rake # 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.expand_path('../config/application', __FILE__) GrumpyCat::Application.load_tasks
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' end
Ruby
# Chipmunk Game Dynamics. Provides fast, easy to use, robust physics. module CP # The bias coefficient used for resolving penetrations. Setting 0.0 effectively disables # penetration resolution. Setting 1.0 will try to resolve the penetration in a single step. # (not recommended) attr_accessor :bias_coef ...
Ruby
require 'rubygems' require_gem 'RedCloth' cdocs = 'chipmunk-docs' rc_cdocs = RedCloth.new(File.read(cdocs + '.textile')) html_cdocs = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="e...
Ruby
require 'mkmf' system 'cp ../src/* ./' $CFLAGS.gsub!('-O2', '-O3') $CFLAGS += ' -std=gnu99' create_makefile('chipmunk')
Ruby
# Chipmunk Game Dynamics. Provides fast, easy to use, robust physics. module CP # The bias coefficient used for resolving penetrations. Setting 0.0 effectively disables # penetration resolution. Setting 1.0 will try to resolve the penetration in a single step. # (not recommended) attr_accessor :bias_coef ...
Ruby
require 'rubygems' require_gem 'RedCloth' cdocs = 'chipmunk-docs' rc_cdocs = RedCloth.new(File.read(cdocs + '.textile')) html_cdocs = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="e...
Ruby
require 'mkmf' system 'cp ../src/* ./' $CFLAGS.gsub!('-O2', '-O3') $CFLAGS += ' -std=gnu99' create_makefile('chipmunk')
Ruby
# Chipmunk Game Dynamics. Provides fast, easy to use, robust physics. module CP # Get the bias coefficient used for penetration resolution. def bias_coef; end # Set the bias coefficient used for penetration resolution. def bias_coef=(coef); end # Calculate the moment of inertia for a circle with the giv...
Ruby
require 'rubygems' require_gem 'RedCloth' cdocs = 'chipmunk-docs' rc_cdocs = RedCloth.new(File.read(cdocs + '.textile')) html_cdocs = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="e...
Ruby
require 'mkmf' create_makefile('chipmunk')
Ruby
# Chipmunk Game Dynamics. Provides fast, easy to use, robust physics. module CP # Get the bias coefficient used for penetration resolution. def bias_coef; end # Set the bias coefficient used for penetration resolution. def bias_coef=(coef); end # Calculate the moment of inertia for a circle with the giv...
Ruby
require 'rubygems' require_gem 'RedCloth' cdocs = 'chipmunk-docs' rc_cdocs = RedCloth.new(File.read(cdocs + '.textile')) html_cdocs = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="e...
Ruby
require 'mkmf' create_makefile('chipmunk')
Ruby
# Chipmunk Game Dynamics. Provides fast, easy to use, robust physics. module CP # The bias coefficient used for resolving penetrations. Setting 0.0 effectively disables # penetration resolution. Setting 1.0 will try to resolve the penetration in a single step. # (not recommended) attr_accessor :bias_coef ...
Ruby
require 'rubygems' require_gem 'RedCloth' cdocs = 'chipmunk-docs' rc_cdocs = RedCloth.new(File.read(cdocs + '.textile')) html_cdocs = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="e...
Ruby
require 'mkmf' system 'cp ../src/* ./' $CFLAGS.gsub!('-O2', '-O3') $CFLAGS += ' -std=gnu99' create_makefile('chipmunk')
Ruby
require 'mkmf' create_makefile('chipmunk')
Ruby
# Chipmunk Game Dynamics. Provides fast, easy to use, robust physics. module CP # The bias coefficient used for resolving penetrations. Setting 0.0 effectively disables # penetration resolution. Setting 1.0 will try to resolve the penetration in a single step. # (not recommended) attr_accessor :bias_coef ...
Ruby
require 'rubygems' require_gem 'RedCloth' cdocs = 'chipmunk-docs' rc_cdocs = RedCloth.new(File.read(cdocs + '.textile')) html_cdocs = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="e...
Ruby
require 'mkmf' system 'cp ../src/* ./' $CFLAGS.gsub!('-O2', '-O3') $CFLAGS += ' -std=gnu99' create_makefile('chipmunk')
Ruby
puts 'this is a test starter'
Ruby
#AS::LIB_DIR = File.expand_path('../../Aerosol') $: << '../starters' puts "init.rb (#{Dir.pwd})" puts "do nothing yay!" p ARGV
Ruby
require 'chipmunk_object' require 'photon' class Float def deg2unit_vect CP::Vec2.for_angle(self*Math::PI/180.0) end end AS.open_screen(640, 480, :vbl_sync => false) Width, Height = AS.screen_w, AS.screen_h ScreenBB = CP::BB.new(-30, -30, Width + 30, Height + 30) class AeroidSprite < Photon::Node::Matrix attr_a...
Ruby
class AS::Font # gx/gy glyph offsets, tx/ty texture offsets Metrics = Struct.new(:gx, :gy, :tx, :ty, :w, :h, :advance) attr_reader :tex, :line_skp, :ascent, :descent attr_reader :packed_indices def self.open(filename) tex = AS::RectTexture.open(filename + '.png') new(tex, filename + '.metrics') end def ...
Ruby
class AS::Font font_tex = AS::MIPTexture.new(AS::Image.load_png_rgba_premult(AS::LIB_DIR + '/base/font/monofont.png')) DefaultFont = AS::Font.new(font_tex, AS::LIB_DIR + '/base/font/monofont.metrics') end
Ruby
AS::Image = Struct.new(:data, :w, :h, :format) class AS::Image # Load an image file. Accepts either PNG or JPEG files. PNG files are # loaded with pre-multiplied alpha. def self.load_img(filename) case extension = File.extname(filename) when '.png': AS::Image.load_png_rgba_premult(filename) when '.jpg': AS::...
Ruby
# TickTimers keep a constant amount of time between ticks, calling a # block of code if there is time before the tick ends. class AS::TickTimer # The current tick count. attr_reader :ticks # The timestep for each tick. 1.0/(ticks per second) attr_reader :step # False if the timer is behind this tick. ...
Ruby
AS::SoundStruct = Struct.new(:data, :rate, :format) # Simple WAV file loader. *NOTE:* Due to the simplicity of it's # implementation, it may raise an execption on a WAV with extra tags. # Run the WAV file through an editor to remove the extraneous tags. class AS::WavFile < AS::SoundStruct Error = Class.new(Exceptio...
Ruby
module AS end require 'aerosol/gamestate.rb' require 'aerosol/deprecated/as_sound.rb' require 'aerosol/timer.rb' require 'aerosol/canvas.rb' require 'aerosol/image.rb' #require 'aerosol/font/font.rb' require 'aerosol/events/events.rb' require 'aerosol/events/input_pad.rb' require 'aerosol/events/stringinput.rb'
Ruby
require 'aerosol/aerosol.rb' module AS::Event class BaseEvent attr_reader :source_id def any_key? false end end class KeyboardEvent < BaseEvent attr_reader :key, :modifiers, :state def self.source_id(key) (key << 3) | 1 end def inspect "KeyEvent:(#{Keynames[@key]})...
Ruby
# Handles inputing strings using Aerosol events. class StringInput # Becomes the return value when the user presses enter, nil # otherwise. attr_reader :final # Current user input. attr_accessor :str BACKSPACE = AS::Event::KeyboardEvent::Keysyms[:Key_BACKSPACE] RETURN = AS::Event::KeyboardEvent::Keysyms[:Key_...
Ruby
# Convenient event handler. Once controls are defined, their values # can be read like a hash. Controls can be stacked so a joystick axis # or key pair axis can use the same control name. To trigger an action, # use the provided call method, passing it the event that occured. The # appropriate code will be executed. ...
Ruby
AL.Listenerfv(AL::POSITION, [0,0,0]) AL.Listenerfv(AL::VELOCITY, [0,0,0]) AL.Listenerfv(AL::ORIENTATION, [0,1,0,0,0,1]) AS::GameState.event_source = AS::Event # start the main loop of the game code. Here we handle any exceptions # that would crash the game code, and we shut down aerosol gracefully. begin require((AR...
Ruby
# A class for manipulating the viewport. # Using a Canvas object you can easily have the view follow a character or rotate or scale the view. class AS::Canvas # Create a new Canvas object. # kx and ky are the key point (origin offset). def initialize(kx, ky, w, h) @kx, @ky, @w, @h = kx, ky, w, h @pos = ve...
Ruby
require 'aerosol/aerosol.rb' class AS::GameState # class accessors def self.event_source; @@event_source; end def self.event_source=(source); @@event_source = source; end @@should_draw = true def self.should_draw=(bool) @@should_draw = bool end def initialize(delegate = nil) @delegate = ...
Ruby
puts "Running Resources/init.rb (#{Dir.pwd})" AS::LIB_DIR = File.expand_path "." Dir.chdir '../../../Resources' puts "Changing working directory to #{Dir.pwd}" load 'src/init.rb' if File.exists? 'src/init.rb'
Ruby
AS.open_screen(512, 512) #GL.Enable(GL::TEXTURE_RECTANGLE_EXT) #GL.Enable(GL::BLEND) #GL.BlendFunc(GL::ONE, GL::ONE) font = AS::Font.open(AS::LIB_DIR + '/extras/font/bitstream') AS.clear_screen GL.Translate(10, 150, 0) #GL.Scale(0.25, 0.25, 0) GL.Translate(0, 300, 0) str = "This is a sweet message?\nYou bet it is!!...
Ruby
puts CFLAGS = "#{ENV['CFLAGS'] || ""} #{`sdl-config --cflags`.strip} -I#{Config::CONFIG['archdir']} -IChipmunk" puts LDFLAGS = "#{ENV['LDFLAGS'] || ""} #{`sdl-config --libs`.strip} -lpng -ljpeg -lGL -lGLU -lruby -logg -lopenal -lvorbis -lvorbisfile" aerosol_files = FileList['*.c'].ext('.o') - ['AS_rigid.o'] rule '.o'...
Ruby
require 'rbconfig' ASsources = Dir.glob("native/base/*.c") + Dir.glob("native/scenegraph/*.c") BINDsources = Dir.glob("native/opengl/*.c") + Dir.glob("native/openal/*.c") CPsources = Dir.glob("Chipmunk/src/*.c") + Dir.glob("Chipmunk/ruby/*.c") MISCsources = Dir.glob("oggstreamer/*.c") + %w"main.c" ALLsources =...
Ruby
# Main module for Aerosol module AS # List of attached joysticks as AS::Joysticks. Joysticks = nil # List of all available fullscreen resolutions. Entries are a two # element Array. _[w,h]_ Resolutions = nil # TODO image loading/saving funcs # Swap the OpenGL buffers. (draw the screen) def self.s...
Ruby
require 'mkmf' $CFLAGS += ' -std=gnu99 -I../../macosx/universal_libs/include' $LDFLAGS += ' ../../macosx/universal_libs/lib/libpng.a -lz ../../macosx/universal_libs/lib/libjpeg.a' create_makefile('AS_Image')
Ruby
puts AS::LIB_DIR = File.expand_path('../Aerosol') AS::GAME_MAIN = 'demoList.rb'
Ruby
# Copyright:: Copyright (c) 2008 Howling Moon Software class PreMultAlphaBlendNode < AS::Scene::BlendNode def initialize(child) super(nil, GL::ONE, GL::ONE_MINUS_SRC_ALPHA, child) end end class FancyTextNode < AS::Scene::ColorNode attr_reader :x, :y, :width, :height def initialize(xoffset, yoffset, font_s...
Ruby
# Copyright:: Copyright (c) 2008 Howling Moon Software class TextDemo def initialize super listNode = AS::Scene::DisplayListNode.from_render_block(GL::LINE_LOOP) do GL.Vertex(100, 100) GL.Vertex(200, 100) GL.Vertex(200, 200) GL.Vertex(100, 200) end var = VertexArray.new(2, 3, 0) var.color...
Ruby
# Copyright:: Copyright (c) 2008 Howling Moon Software WIDTH = 800 HEIGHT = 600 AS.open_screen(WIDTH, HEIGHT, :vbl_sync => true) AS.clear_color(1, 0, 0, 0) AS.clear_screen AS.clear_color(0, 0, 0, 0) class DemoState < AS::GameState::TickLimitedState def switch_state(state) DemoState.new(state).run end def ...
Ruby
# Copyright:: Copyright (c) 2008 Howling Moon Software class PreMultAlphaBlendNode < AS::Scene::BlendNode def initialize(child) super(nil, GL::ONE, GL::ONE_MINUS_SRC_ALPHA, child) end end class FancyTextNode < AS::Scene::ColorNode attr_reader :x, :y, :width, :height def initialize(xoffset, yoffset, font_sc...
Ruby
require 'test/unit' $: << 'aerosol' require 'aerosol/base/gamestate.rb' class TestEventSource def initialize(*events) @events = events end def dequeue_events @events.each{|event| yield(event)} @events.clear end def push_events(*events) @events += events end end class GameStateTest < Test::Unit::Tes...
Ruby
require 'test/unit' $: << 'aerosol' require 'aerosol/base/events/events.rb' class EventTest < Test::Unit::TestCase def test_create_action_listener listener = AS::Event::ActionListener.new assert_not_nil(listener) #not like this would fail, but it's useful to me. end def test_action_listener_hears_keys...
Ruby
require 'test/unit' $: << 'aerosol' require 'aerosol/base/events/events.rb' require 'aerosol/base/events/input_pad.rb' class InputPadTest < Test::Unit::TestCase def test_create_input_pad input_pad = AS::Event::InputPad.new input_pad.key(:fire, :Key_SPACE){|pressed| puts 'lawl'} assert_not_nil(input_pad) ...
Ruby
require 'test/unit' require 'test/gamestate/gamestate.rb' require 'test/event/events.rb' require 'test/event/input_pad.rb' suite = Test::Unit::TestSuite.new('Aerosol Tests') suite << GameStateTest suite << EventTest
Ruby
# Uninstall hook code here
Ruby
class AeUsersGenerator < Rails::Generator::Base def manifest record do |m| m.directory "public/images/ae_users" %w{add admin group logout remove user}.each do |img| m.file "#{img}.png", "public/images/ae_users/#{img}.png" end m.file "openid.gif", "public/images/ae_users/openid.gif"...
Ruby
class PeoplePermissions < ActiveRecord::Migration def self.up add_column "permissions", "person_id", :integer end def self.down remove_column "permissions", "person_id" end end
Ruby
class SimplifySignup < ActiveRecord::Migration def self.up ActiveRecord::Base.establish_connection :users rename_column "people", "home_phone", "phone" remove_column "people", "work_phone" remove_column "people", "address" end def self.down ActiveRecord::Base.establish_connection :users r...
Ruby
class CreateEmailAddresses < ActiveRecord::Migration def self.up ActiveRecord::Base.establish_connection :users create_table :email_addresses do |t| t.column :address, :string, :null => false t.column :primary, :boolean t.column :account_id, :integer, :null => false t.column :created_a...
Ruby
class RefactorPeople < ActiveRecord::Migration def self.up ActiveRecord::Base.establish_connection :users create_table :procon_profiles do |t| t.column :person_id, :integer, :null => false t.column :nickname, :string t.column :phone, :string t.column :best_call_time, :string end ...
Ruby
class CreateAccounts < ActiveRecord::Migration def self.up ActiveRecord::Base.establish_connection :users create_table :accounts do |t| t.column :password, :string, :null => false t.column :active, :boolean t.column :activation_key, :string t.column :created_at, :datetime t.colum...
Ruby
class CreatePeople < ActiveRecord::Migration def self.up ActiveRecord::Base.establish_connection :users create_table :people do |t| t.column :firstname, :string t.column :lastname, :string t.column :gender, :string t.column :nickname, :string t.column :address, :string t.co...
Ruby
class CreateRoles < ActiveRecord::Migration def self.up ActiveRecord::Base.establish_connection :users create_table :roles do |t| t.column :name, :string, :null => false end create_table :people_roles, :id => false do |t| t.column :person_id, :integer, :null => false t.column :role_i...
Ruby
class CreatePermissions < ActiveRecord::Migration def self.up ActiveRecord::Base.establish_connection :users create_table :permissions do |t| t.column :role_id, :integer, :null => false t.column :permission, :string t.column :permissioned_id, :integer t.column :permissioned_type, :stri...
Ruby
# Install hook code here
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the ae_users plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the ae_users plugin.' Rak...
Ruby
# desc "Explaining what the task does" #task :ae_users do # # Task goes here # end
Ruby
require 'digest/sha1' class AuthTicket < ActiveRecord::Base belongs_to :person validates_uniqueness_of :secret before_save do |record| record.secret end def self.find_ticket(secret) AuthTicket.find(:first, :conditions => ["secret = ? and (expires_at is null or expires_at > current_timestamp())"...
Ruby
class EmailAddress < ActiveRecord::Base establish_connection :users belongs_to :person validates_uniqueness_of :address def primary=(value) if value and not person.nil? person.email_addresses.each do |addr| if addr != self addr.primary = false addr.save end ...
Ruby
class PermissionCache < ActiveRecord::Base belongs_to :person belongs_to :permissioned, :polymorphic => true end
Ruby
class Person < ActiveRecord::Base establish_connection :users has_one :account has_many :open_id_identities has_and_belongs_to_many :roles has_many :permissions, :dependent => :destroy has_many :email_addresses, :dependent => :destroy if AeUsers.cache_permissions? has_many :permission_caches, :depende...
Ruby
class AuthNotifier < ActionMailer::Base def account_activation(account, address=nil) if address.nil? address = account.person.primary_email_address elsif address.kind_of? EmailAddress address = address.address end @recipients = address @from = "noreply@#{default_url_options[:host...
Ruby
class Role < ActiveRecord::Base acts_as_permissioned :permission_names => ['edit'] establish_connection :users has_and_belongs_to_many :people has_many :permissions, :dependent => :destroy end
Ruby
class Permission < ActiveRecord::Base belongs_to :role belongs_to :person belongs_to :permissioned, :polymorphic => true def object return permissioned end def grantee if not role.nil? return role else return person end end def cache_conds cond_sql = "permission_...
Ruby
require 'digest/md5' class Account < ActiveRecord::Base establish_connection :users belongs_to :person def self.find_by_email_address(address) p = Person.find_by_email_address(address) if not p.nil? return p.account end end def password=(password) if not password.nil? write_...
Ruby