code
stringlengths
1
1.73M
language
stringclasses
1 value
class ChangeToDeviseUsersTable < ActiveRecord::Migration def self.up add_column ::User.table_name, :current_sign_in_at, :datetime add_column ::User.table_name, :last_sign_in_at, :datetime add_column ::User.table_name, :current_sign_in_ip, :string add_column ::User.table_name, :last_sign_in_ip, :string...
Ruby
class RemoveCachedSlugFromPages < ActiveRecord::Migration def self.up if ::Page.column_names.map(&:to_s).include?('cached_slug') remove_column ::Page.table_name, :cached_slug end end def self.down # Don't add this column back, it breaks stuff. end end
Ruby
class TranslateCustomTitleOnPages < ActiveRecord::Migration def self.up unless ::Page::Translation.column_names.map(&:to_sym).include?(:custom_title) add_column ::Page::Translation.table_name, :custom_title, :string # Re-save custom_title ::Page.all.each do |page| page.update_attribute(...
Ruby
class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration def self.up ::Page.translated_attribute_names.map(&:to_sym).each do |column_name| remove_column ::Page.table_name, column_name if ::Page.column_names.map(&:to_sym).include?(column_name) end end def self.down ::Page.translated_attri...
Ruby
class AddMissingIndexesToRolesUsers < ActiveRecord::Migration def self.up add_index ::RolesUsers.table_name, [:role_id, :user_id] add_index ::RolesUsers.table_name, [:user_id, :role_id] end def self.down remove_index ::RolesUsers.table_name, :column => [:role_id, :user_id] remove_index ::RolesUse...
Ruby
class CreateRefinerycmsSettingsSchema < ActiveRecord::Migration def self.up create_table ::RefinerySetting.table_name, :force => true do |t| t.string "name" t.text "value" t.boolean "destroyable", :default => true t.datetime "created_at" t.datetime "updated_at" ...
Ruby
class CreateRefinerycmsImagesSchema < ActiveRecord::Migration def self.up create_table ::Image.table_name, :force => true do |t| t.string "image_mime_type" t.string "image_name" t.integer "image_size" t.integer "image_width" t.integer "image_height" t.datetime "created_a...
Ruby
class AddRememberCreatedAtToUsers < ActiveRecord::Migration def self.up add_column :users, :remember_created_at, :datetime end def self.down remove_column :users, :remember_created_at end end
Ruby
class CreateRefinerycmsCoreSchema < ActiveRecord::Migration def self.up create_table ::Slug.table_name, :force => true do |t| t.string "name" t.integer "sluggable_id" t.integer "sequence", :default => 1, :null => false t.string "sluggable_type", :limit => 40 ...
Ruby
class AddValueTypeToRefinerySettings < ActiveRecord::Migration def self.up add_column ::RefinerySetting.table_name, :form_value_type, :string end def self.down remove_column ::RefinerySetting.table_name, :form_value_type end end
Ruby
class RemovePasswordSaltFromUsers < ActiveRecord::Migration def self.up remove_column :users, :password_salt # Make the current password invalid :( User.all.each do |u| u.update_attribute(:encrypted_password, u.encrypted_password[29..-1]) end end def self.down add_column :users, :passwo...
Ruby
class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration def self.up # Postgres apparently requires the roles_users table to exist before creating the roles table. create_table ::RolesUsers.table_name, :id => false, :force => true do |t| t.integer "user_id" t.integer "role_id" end...
Ruby
class CreateRefinerycmsPagesSchema < ActiveRecord::Migration def self.up create_table ::PagePart.table_name, :force => true do |t| t.integer "page_id" t.string "title" t.text "body" t.integer "position" t.datetime "created_at" t.datetime "updated_at" end add_in...
Ruby
class AddLocaleToSlugs < ActiveRecord::Migration def self.up add_column :slugs, :locale, :string add_index :slugs, :locale end def self.down remove_column :slugs, :locale remove_index :slugs, :locale end end
Ruby
class TranslatePagePlugin < ActiveRecord::Migration def self.up PagePart.create_translation_table!({ :body => :text }, { :migrate_data => true }) Page.create_translation_table!({ :title => :string, :meta_keywords => :string, :meta_description => :text, :browser_tit...
Ruby
::Page.reset_column_information # Check whether all columns are applied yet by seo_meta. unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k| ::Page.translation_class.instance_methods.map(&:to_sym).include?(k) } # Make pages model seo_meta because not all columns are accessible. ::Page.translation_...
Ruby
source 'http://rubygems.org' # gem 'rails', '3.0.11' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby...
Ruby
### uncomment any of the following requires applicable for your system ### and then copy this to .autotest if you are using the ZenTest autotest. # require "autotest/restart" # require "test_notifier/runner/autotest" # require "redgreen/autotest" # require "autotest/timestamp" # adds exceptions from .gitignore file,...
Ruby
Autotest.add_discovery { "rails" } Autotest.add_discovery { "rspec2" }
Ruby
xml.instruct! xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do @locales.each do |locale| ::I18n.locale = locale Page.live.in_menu.includes(:parts).each do |page| # exclude sites that are external to our own domain. page_url = if page.url.is_a?(Hash) # This is how most ...
Ruby
module ApplicationHelper end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery end
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. # 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
# Be sure to restart your server when you modify this file. EllenPcPratique::Application.config.session_store :cookie_store, :key => '_ellen-pc-pratique_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the sessio...
Ruby
require 'devise' # Use this hook to configure devise mailer, warden hooks and so forth. The first # four configuration values can also be set straight in your models. ::Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in DeviseMailer. config.mailer_sender = "...
Ruby
EllenPcPratique::Application.routes.draw do # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # matc...
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 you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module EllenPcPratique class Application < Rails::Applicati...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application EllenPcPratique::Application.initialize!
Ruby
EllenPcPratique::Application.configure do # Settings specified here will take precedence over those in config/application.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 t...
Ruby
EllenPcPratique::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 t...
Ruby
EllenPcPratique::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 t...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run EllenPcPratique::Application
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.expand_path('../config/application', __FILE__) require 'rake' EllenPcPratique::Application.load_tasks
Ruby
#Here goes stuff in it
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby

Ruby
result = "<ul>"; currentPage.Children.each do |this_item| result += "<li><a href='" + this_item.NiceUrl + "'>" + this_item.Name + "</a></li>" end result += "</ul>" puts result
Ruby
Umbraco = Object.const_get("umbraco") Library = Umbraco.const_get("library") NodeFactory = Umbraco.const_get("presentation").const_get("nodeFactory") # Set the node id you would like to fetch pages from here # You can also set it as a macro property with the alias 'nodeId' instead parent = NodeFactory::Node.n...
Ruby
ActionView::Base.send :include, BetterPartials::Helpers
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the betterpartials plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the betterpartials ...
Ruby
# Uninstall hook code here
Ruby
module BetterPartials module Helpers # Renders a Partial intelligently # # Normal partial call: # <%= partial "my_partial" %> # same as... # <%= render :partial => "my_partial" %> # # Partial call with arguments: # <%= partial "my_partial", :arg1 => "test" %> # same a...
Ruby
# Get the directory that this configuration file exists in dir = File.dirname(__FILE__) # Load the sencha-touch framework automatically. load File.join(dir, '..', 'themes') # Compass configurations sass_path = dir css_path = File.join(dir, "..", "css") environment = :production output_style = :compressed
Ruby
# Get the directory that this configuration file exists in dir = File.dirname(__FILE__) # Load the sencha-touch framework automatically. load File.join(dir, '..', 'themes') # Compass configurations sass_path = dir css_path = File.join(dir, "..", "css-debug") environment = :development output_style = :expanded
Ruby
# This file registers the sencha-touch framework with compass # It's a magic name that compass knows how to find. dir = File.dirname(__FILE__) require File.join(dir, 'lib', 'theme_images.rb') # Include compass-recipes require File.join(File.dirname(__FILE__), 'vendor', 'compass-recipes', 'config') Compass::BrowserSup...
Ruby
stylesheet 'sencha-touch.scss'
Ruby
module SenchaTouch module SassExtensions module Functions module ThemeImages def theme_image(theme, path, mime_type = nil) path = path.value images_path = File.join(File.dirname(__FILE__), "..", "images", theme.value) real_path = File.join(images_path, path) i...
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end 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 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end 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 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end 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
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
module Jekyll module BugFilter def bugify(input) upstream_map = { "Bootstrap" => "https://github.com/twbs/bootstrap/issues/", "IE" => ["https://connect.microsoft.com/IE/feedback/details/", "IE bug"], "Mozilla" => ["https://bugzilla.mozilla.org/show_bug.cgi?id=", "Mozilla bug"], ...
Ruby
require 'yaml' module Bridge class Generator < Jekyll::Generator def generate(site) site.data["configBridge"] = YAML.load_file("./grunt/configBridge.json") end end end
Ruby
# Is sheet 01 (after the TOC) a left sheet or a right sheet? sheet1: right # "left" and "right" specify which page of a two-page spread a file # must start on. "left" means that a file must start on the first of # the two pages. "right" means it must start on the second of the two # pages. The file may start in eit...
Ruby
# Is sheet 01 (after the TOC) a left sheet or a right sheet? sheet1: right # "left" and "right" specify which page of a two-page spread a file # must start on. "left" means that a file must start on the first of # the two pages. "right" means it must start on the second of the two # pages. The file may start in eit...
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end 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 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
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
# Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use yo...
Ruby
Webapp::Application.config.DayOfWeek = [["Unknown/varies",nil],["Sunday",0],["Monday",1],["Tuesday",2],["Wednesday",3],["Thursday",4],["Friday",5],["Saturday",6]]
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 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. # # 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
# Be sure to restart your server when you modify this file. Webapp::Application.config.session_store :cookie_store, :key => '_webapp_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 "rails ...
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
Webapp::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.action_...
Ruby
Webapp::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 ser...
Ruby
Webapp::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 sui...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Webapp::Application.initialize!
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
Webapp::Application.routes.draw do resources :home do collection do get :welcome end end resources :assignments do collection do get :index get :assign get :knight end end resources :cell_carriers do as_routes end resources :regions do as_routes end resources :...
Ruby
module ApplicationHelper def all_admin_region_volunteer_tuples(whom) admin_rids = whom.assignments.collect{ |a| a.admin ? a.region.id : nil }.compact Volunteer.all.collect{ |v| v_rids = v.regions.collect{ |r| r.id } (admin_rids & v_rids).length > 0 ? [v.name+" ["+v.regions.collect{ |r| r.name }.j...
Ruby
module LocationsHelper end
Ruby
module CellCarriersHelper end
Ruby
module RegionsHelper def region_logo_column(record) return "" if record.logo_file_name.nil? image_tag(record.logo(:thumb)) end end
Ruby
module AssignmentsHelper end
Ruby
module HomeHelper end
Ruby
module FoodTypesHelper end
Ruby
module LogsHelper # Set to true to disable emailing and just print the emails to STDOUT DontDeliverEmails = false def log_volunteer_column(record) if record.volunteer.nil? link_to "Take Shift", "/logs/#{record.id}/take" else record.volunteer.name end end def log_volunteer_column_attributes(record) if...
Ruby
module VolunteersHelper def volunteer_photo_column(record) return "" if record.photo_file_name.nil? link_to image_tag(record.photo(:thumb)){ record.photo(:medium) } end end
Ruby
module TransportTypesHelper end
Ruby