code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :body
t.string :author
t.timestamps
end
end
end
| Ruby |
class CreatePages < ActiveRecord::Migration
def change
create_table :pages do |t|
t.string :title
t.text :content
t.timestamps
end
end
end
| Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'E... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Company::Application
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in in... | Ruby |
#!/usr/bin/env ruby
#==============================================================================
#
# iGoat Server
#
# Authors:
# Sean Eidemiller (sean@krvw.com)
#
# Ports:
# 8080/HTTP
# 8443/HTTPS (SSL)
#
# Endpoints:
# POST /igoat/user
# GET /igoat/token?username=<username>&password=<password>
#
# Exampl... | Ruby |
#!/usr/bin/env ruby
#==============================================================================
#
# iGoat Server
#
# Authors:
# Sean Eidemiller (sean@krvw.com)
# Jonathan Carter (jcarter@arxan.com)
#
# Ports:
# 8080/HTTP
# 8443/HTTPS (SSL)
#
# Endpoints:
# POST /igoat/user
# POST /igoat/exercise/certif... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name... | Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string, :limit => 40
t.column :name, :string, :limit => 100, :default => '', :null => true
t.column :email, :string, ... | Ruby |
class CreateExtensions < ActiveRecord::Migration
def self.up
create_table :extensions do |t|
t.string :number
t.string :forward_to
t.belongs_to :phone_number
t.belongs_to :user
t.has_many :message
t.timestamps
end
end
def self.down
drop_table :extensions
end
end... | Ruby |
class CreateMessages < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.belongs_to :extension
t.string :guid
t.string :from
t.string :url
t.integer :duration
t.timestamps
end
end
def self.down
drop_table :messages
end
end
| Ruby |
class CreateOauthConsumerTokens < ActiveRecord::Migration
def self.up
create_table :consumer_tokens do |t|
t.integer :user_id
t.string :type, :limit => 30
t.string :token, :limit => 1024 # This has to be huge because of Yahoo's excessively large tokens
t.string :secret
t.timesta... | Ruby |
class CreateInvitations < ActiveRecord::Migration
def self.up
create_table :invitations do |t|
t.references :organization
t.string :email
t.boolean :expired
t.timestamps
end
end
def self.down
drop_table :invitations
end
end
| Ruby |
class AddUserOpenid < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :openid
end
end
def self.down
change_table :users do |t|
t.remove :openid
end
end
end
| Ruby |
class CreatePhoneNumbers < ActiveRecord::Migration
def self.up
create_table :phone_numbers do |t|
t.string :number
t.references :organization
t.has_many :extensions
t.timestamps
end
end
def self.down
drop_table :phone_numbers
end
end
| Ruby |
class AddOrganizaton2lo < ActiveRecord::Migration
def self.up
change_table :organizations do |t|
t.boolean :from_marketplace
end
end
def self.down
change_table :organizations do |t|
t.remove :from_marketplace
end
end
end
| Ruby |
class CreateOrganizations < ActiveRecord::Migration
def self.up
create_table :organizations do |t|
t.string :name
t.string :domain
t.boolean :enabled
t.timestamps
end
end
def self.down
drop_table :organizations
end
end
| Ruby |
class AddUsersToOrg < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.references :organization
end
end
def self.down
change_table :users do |t|
t.remove_references :organization
end
end
end
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::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 da... | 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
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| 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/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/plugin'
| 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/generate'
| Ruby |
module ExtensionsHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
require 'phone'
module ApplicationHelper
def format_phone(phone)
Phone.parse(phone).format(:us) rescue phone
end
def has_integration?
ENV['GOOG'].present?
end
def has_oauth?
@user.organization.from_marketp... | Ruby |
module OrganizationsHelper
end
| Ruby |
module SessionsHelper
end | Ruby |
module UsersHelper
#
# Use this to wrap view elements that the user can't access.
# !! Note: this is an *interface*, not *security* feature !!
# You need to do all access control at the controller level.
#
# Example:
# <%= if_authorized?(:index, User) do link_to('List all users', users_path) end %> ... | Ruby |
module MessagesHelper
end
| Ruby |
class UserMailer < ActionMailer::Base
def signup_notification(user)
setup_email(user)
@subject += 'Please activate your new account'
@body[:url] = "http://localhost:3000/activate/#{user.activation_code}"
end
def activation(user)
setup_email(user)
@subject += 'Your account has be... | 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 |
class PhoneNumber < ActiveRecord::Base
belongs_to :organization
has_many :extensions, :autosave=>true
validates_presence_of :number
#validates_uniqueness_of :number
def next_extension
ext = Extension.maximum(:number, :conditions => ['phone_number_id = ?', id])
ext.to_i + 1
end
end
| Ruby |
class Invitation < ActiveRecord::Base
belongs_to :organization
validates_presence_of :email
validates_length_of :email, :within => 6..100 #r@a.wk
validates_uniqueness_of :email
end
| Ruby |
require 'digest/sha1'
require 'oauth/consumer'
class User < ActiveRecord::Base
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken
belongs_to :organization
has_one :extension
has_one :google_oauth_token, :class_name=>"GoogleToken", :dependent=>:destroy
#val... | Ruby |
class Extension < ActiveRecord::Base
has_many :messages
belongs_to :phone_number
belongs_to :user
validates_uniqueness_of :number, :scope => :phone_number_id
attr_accessible :forward_to
end
| Ruby |
class Organization < ActiveRecord::Base
include TwilioClient
include AuthenticatedSystem
has_many :users, :autosave =>true
has_one :phone_number
validates_presence_of :name
validates_length_of :name, :within => 3..40
validates_length_of :domain, :within => 3..255, :allow_blank =>... | Ruby |
class Message < ActiveRecord::Base
belongs_to :extension
end
| Ruby |
require 'oauth/models/consumers/token'
class ConsumerToken < ActiveRecord::Base
include Oauth::Models::Consumers::Token
end | Ruby |
require 'twiliolib'
class TwilioController < ApplicationController
skip_before_filter :verify_authenticity_token
#before_filter :verify_signature
before_filter :lookup_phone
def start
@response = Twilio::Response.new
@response.addSay("Please enter your extension followed by pound.", :voice => "woman... | Ruby |
class MessagesController < ApplicationController
before_filter :ensure_setup
before_filter :require_authentication
# GET /messages
# GET /messages.xml
def index
@user = current_user
@messages = current_user.extension.messages
respond_to do |format|
format.html # index.html.erb
format... | 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
include AuthenticatedSystem
ActionView::Base.default_form_builder = MyFormBuilder
ActionView::Base.field_e... | Ruby |
class ExtensionsController < ApplicationController
before_filter :require_authentication
before_filter :check_extension, :only=>[:new, :create]
# GET /extensions
# GET /extensions.xml
def index
@organization = current_user.organization
@extensions = @organization.phone_number.extensions
respon... | Ruby |
class OrganizationsController < ApplicationController
include TwilioClient
before_filter :require_authentication
before_filter :ensure_setup, :except=>[:new, :create]
# GET /organizations
# GET /organizations.xml
def index
@organizations = Organization.all
respond_to do |format|
fo... | Ruby |
class HomeController < ApplicationController
before_filter :ensure_setup
def index
end
end | Ruby |
class UsersController < ApplicationController
before_filter :require_authentication, :except=>[:new, :create, :activate]
before_filter :ensure_setup, :except=>[:new, :create, :activate]
def index
@organization = current_user.organization
@users = @organization.users
end
def show
end
# render ... | Ruby |
require 'oauth/controllers/consumer_controller'
class OauthConsumersController < ApplicationController
include Oauth::Controllers::ConsumerController
def index
@consumer_tokens=ConsumerToken.all :conditions=>{:user_id=>current_user.id}
@services=OAUTH_CREDENTIALS.keys-@consumer_tokens.collect{|c| c.class... | Ruby |
class InvitationsController < ApplicationController
before_filter :require_authentication
# render new.rhtml
def new
@organization = current_user.organization
logger.info("Org = #{@organization}")
@invitation = Invitation.new
respond_to do |format|
format.html # new.html.erb
format.xm... | Ruby |
require "openid"
require 'openid/extensions/ax'
require 'openid/store/railscache'
require 'gapps_openid'
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
before_filter :require_authentication, :only => [:destroy]
# render new.rhtml
def new
... | 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 do debug a probl... | Ruby |
# A Site key gives additional protection against a dictionary attack if your
# DB is ever compromised. With no site key, we store
# DB_password = hash(user_password, DB_user_salt)
# If your database were to be compromised you'd be vulnerable to a dictionary
# attack on all your stupid users' passwords. With a site... | 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 |
# edit this file to contain credentials for the OAuth services you support.
# each entry needs a corresponding token model.
#
# eg. :twitter => TwitterToken, :hour_feed => HourFeedToken etc.
#
# OAUTH_CREDENTIALS={
# :twitter=>{
# :key=>"",
# :secret=>""
# },
# :google=>{
# :key=>"",
# :secret=>""... | Ruby |
ActionMailer::Base.delivery_method = :sendmail
| 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 |
TWILIO_SID = ENV['TWILIO_SID']
TWILIO_TOKEN = ENV['TWILIO_TOKEN']
TWILIO_VERSION = '2008-08-01' | Ruby |
ActionController::Routing::Routes.draw do |map|
map.resources :users
map.resources :messages
map.resources :organizations
map.resources :extensions
map.resources :invitations
map.resource :session
map.resources :oauth_consumers,:member=>{:callback=>:get}
map.logout '/logout', :controller => 'session... | 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
# 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 |
# 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 |
# 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 |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user_id] = user ? (user.is_a?(User) ? user.id : users(user).id) : nil
end
def authorize_as(user)
@request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentic... | Ruby |
require 'openid/util'
require 'openid/store/interface'
require 'openid/store/nonce'
require 'time'
module OpenID
module Store
class RailsCache < Interface
attr_accessor :key_prefix
def initialize(cache_client = Rails.cache, key_prefix='openid-store:')
@cache_client = cache_client
sel... | Ruby |
class MyFormBuilder < ActionView::Helpers::FormBuilder
helpers = field_helpers +
%w{date_select datetime_select time_select} +
%w{collection_select select country_select time_zone_select} -
%w{hidden_field label fields_for submit} #Not decorated
helpers.each do |name|
defin... | Ruby |
require 'rubygems'
require 'twiliolib'
require 'rexml/document'
require 'phone'
module TwilioClient
FIXED_NUM = "+18776601798"
def allocateNumber(company)
return FIXED_NUM unless FIXED_NUM.nil?
twilio_api = Twilio::RestAccount.new(TWILIO_SID, TWILIO_TOKEN)
params = {
'FriendlyName' => com... | Ruby |
require 'rubygems'
require 'rexml/document'
require 'rexml/element'
require 'rexml/xpath'
require 'oauth'
require 'phone'
module Google
class Contact < Struct.new(:name, :phones, :emails)
end
class ContactProperty < Struct.new(:rel, :value)
end
class GoogleClient
def initialize(token, base_url)
... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name... | Ruby |
class CreateBlockDocuments < ActiveRecord::Migration
def self.up
create_table :block_documents do |t|
t.integer :block_id
t.integer :category_id
t.date :expiry_date
#t.date :before_build_date
t.string :name
t.timestamps
end
add_index :block_documents, :block_id
... | Ruby |
class CreateBlocks < ActiveRecord::Migration
def self.up
create_table :blocks do |t|
t.string :name
t.string :postcode
t.date :build_date
t.timestamps
end
Block.create(:name => 'Parks Polas', :postcode =>'AH1 7HB', :build_date=> '01/08/1984')
Block.create(:name => 'Crow... | Ruby |
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :description
t.boolean :expiry_date_required
t.boolean :build_date_depended
t.date :before_build_date
t.timestamps
end
Category.create(:description => 'Management Agreement... | Ruby |
class AddAttachmentsDocumentToBlockDocument < ActiveRecord::Migration
def self.up
add_column :block_documents, :document_file_name, :string
add_column :block_documents, :document_content_type, :string
add_column :block_documents, :document_file_size, :integer
add_column :block_documents, :document_upd... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::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 da... | 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
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| 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/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/destroy'
| 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/console'
| 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__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| 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/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/plugin'
| 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/benchmarker'
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.