code
stringlengths
1
1.73M
language
stringclasses
1 value
class CalendarDateSelect FORMATS = { :natural => { :date => "%B %d, %Y", :time => " %I:%M %p" }, :hyphen_ampm => { :date => "%Y-%m-%d", :time => " %I:%M %p", :javascript_include => "format_hyphen_ampm" }, :finnish => { :date => "%d.%m.%Y", :ti...
Ruby
class CalendarDateSelect module IncludesHelper def calendar_date_select_includes(*args) return "" if @cds_already_included @cds_already_included=true options = (Hash === args.last) ? args.pop : {} options.assert_valid_keys(:style, :format, :locale) style = opti...
Ruby
require "rubygems" require 'test/unit' require 'active_support' require 'action_pack' require 'action_controller' require 'action_view' require 'ostruct' for file in ["../lib/calendar_date_select.rb", "../lib/includes_helper.rb"] require File.expand_path(File.join(File.dirname(__FILE__), file)) end def dbg req...
Ruby
%w[calendar_date_select includes_helper].each { |file| require File.join( File.dirname(__FILE__), "lib",file) } ActionView::Helpers::FormHelper.send(:include, CalendarDateSelect::FormHelper) ActionView::Base.send(:include, CalendarDateSelect::FormHelper) ActionView::Base.send(:include, CalendarDateSelect::In...
Ruby
class CalendarDateSelect FORMATS = { :natural => { :date => "%B %d, %Y", :time => " %I:%M %p" }, :hyphen_ampm => { :date => "%Y-%m-%d", :time => " %I:%M %p", :javascript_include => "format_hyphen_ampm" }, :finnish => { :date => "%d.%m.%Y", :ti...
Ruby
class CalendarDateSelect module IncludesHelper def calendar_date_select_includes(*args) options = (Hash === args.last) ? args.pop : {} options.assert_valid_keys(:style, :format, :locale) style = options[:style] || args.shift locale = options[:locale] cds_css_file = sty...
Ruby
require "rubygems" require 'test/unit' require 'active_support' require 'action_pack' require 'action_controller' require 'action_view' require 'ostruct' for file in ["../lib/calendar_date_select.rb", "../lib/includes_helper.rb"] require File.expand_path(File.join(File.dirname(__FILE__), file)) end def dbg req...
Ruby
%w[calendar_date_select includes_helper].each { |file| require File.join( File.dirname(__FILE__), "lib",file) } ActionView::Helpers::FormHelper.send(:include, CalendarDateSelect::FormHelper) ActionView::Base.send(:include, CalendarDateSelect::FormHelper) ActionView::Base.send(:include, CalendarDateSelect::In...
Ruby
class CalendarDateSelect FORMATS = { :natural => { :date => "%B %d, %Y", :time => " %I:%M %p" }, :hyphen_ampm => { :date => "%Y-%m-%d", :time => " %I:%M %p", :javascript_include => "format_hyphen_ampm" }, :iso_date => { :date => "%Y-%m-%d", :...
Ruby
class CalendarDateSelect module IncludesHelper def calendar_date_select_includes(*args) return "" if @cds_already_included @cds_already_included=true options = (Hash === args.last) ? args.pop : {} options.assert_valid_keys(:style, :format, :locale) style = opti...
Ruby
require "rubygems" require 'test/unit' require 'active_support' require 'action_pack' require 'action_controller' require 'action_view' require 'ostruct' for file in ["../lib/calendar_date_select.rb", "../lib/includes_helper.rb"] require File.expand_path(File.join(File.dirname(__FILE__), file)) end def dbg req...
Ruby
%w[calendar_date_select includes_helper].each { |file| require File.join( File.dirname(__FILE__), "lib",file) } ActionView::Helpers::FormHelper.send(:include, CalendarDateSelect::FormHelper) ActionView::Base.send(:include, CalendarDateSelect::FormHelper) ActionView::Base.send(:include, CalendarDateSelect::In...
Ruby
class CalendarDateSelect FORMATS = { :natural => { :date => "%B %d, %Y", :time => " %I:%M %p" }, :hyphen_ampm => { :date => "%Y-%m-%d", :time => " %I:%M %p", :javascript_include => "format_hyphen_ampm" }, :iso_date => { :date => "%Y-%m-%d", :...
Ruby
class CalendarDateSelect module IncludesHelper def calendar_date_select_includes(*args) return "" if @cds_already_included @cds_already_included=true options = (Hash === args.last) ? args.pop : {} options.assert_valid_keys(:style, :format, :locale) style = opti...
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/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/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/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
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/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/request'
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/generate'
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/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' 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/runner'
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/generate'
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
class CreateListings < ActiveRecord::Migration def self.up create_table :listings do |t| t.string :name t.datetime :created_on t.datetime :last_follow_up_at t.timestamps end end def self.down drop_table :listings end end
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 helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for details...
Ruby
class CalendarController < ApplicationController def index end def redirect redirect_to "/calendar/" end end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module CalendarHelper end
Ruby
class Listing < ActiveRecord::Base 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
#!/opt/local/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 impai...
Ruby
#!/opt/local/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 impai...
Ruby
#!/opt/local/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 impai...
Ruby
#!/opt/local/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.lo...
Ruby
#!/opt/local/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 impai...
Ruby
#!/opt/local/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.lo...
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| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
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
# 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 # 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.0...
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 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 # 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
# 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
# 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. ActiveRecord::Base.include_root_in_json = true # Store the full clas...
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
# 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
# replace with the name of your application set :application, "hearsay" # replace with the HTTP (NOT HTTPS) read-only URL of your Google Code SVN set :repository, "http://calhearsay.googlecode.com/svn/trunk/" # directory for deployment on remote machine set :deploy_to, "/mnt/app" # If you aren't using Subversion to ...
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
# 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
# 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.connect '/archive', :controller => 'entries', :action => 'archive' map.connect '/categories', :controller => 'entries', :action => 'categories' map.connect '/contact', :controller => 'infos', :action => 'contact' map.connect '/faq', :controller => 'infos', :...
Ruby
load 'deploy' if respond_to?(:namespace) # cap2 differentiator Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } Dir['lib/recipes/*.rb'].each { |plugin| load(plugin) } load 'config/deploy'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module EntryHelper 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 UserHelper end
Ruby
module EntriesHelper def get_user(user_id) User.find(user_id) end end
Ruby
module TagHelper end
Ruby
module TagsHelper end
Ruby
module SessionsHelper end
Ruby
module RatingHelper end
Ruby
module CommentHelper end
Ruby
module InfosHelper end
Ruby
module CommentsHelper end
Ruby
class Info < ActiveRecord::Base end
Ruby
class Pic < ActiveRecord::Base belongs_to:entry validates_presence_of :entry has_attachment :content_type => :image, :storage => :file_system, :processor => 'Rmagick', :max_size => 6.megabytes, :resize_to => '400x400>', ...
Ruby
class Userpic < ActiveRecord::Base belongs_to:user #validates_presence_of :user has_attachment :content_type => :image, :storage => :file_system, :processor => 'Rmagick', :size => 0.megabyte..6.megabytes, :resize_to => '400x40...
Ruby
require 'digest/sha1' class User < ActiveRecord::Base has_one :userpic has_many:entries include Authentication include Authentication::ByPassword include Authentication::ByCookieToken validates_presence_of :login validates_length_of :login, :within => 3..40 validates_uniqueness_of ...
Ruby
class Tag < ActiveRecord::Base belongs_to:entry belongs_to:user validates_presence_of :tag #validates_presence_of :user #validates_presence_of :entry end
Ruby
class Entry < ActiveRecord::Base acts_as_rateable has_one:pic has_many:comments has_many:tags belongs_to:user #validations validates_presence_of :user validates_presence_of :title validates_presence_of :state validates_length_of :title, :maximum => 100, :if => Proc.new{|x| !(x.title.bla...
Ruby
class Comment < ActiveRecord::Base belongs_to:entry belongs_to:user validates_presence_of :comment #validates_presence_of :user #validates_presence_of :entry end
Ruby
class Rating < ActiveRecord::Base end
Ruby
class PicsController < ApplicationController def index @pics = Pic.find(:all) end def new @pic = Pic.new end def create @pic = Pic.new(params[:pic]) if @pic.save flash[:notice] = 'Pic was successfully created.' redirect_to pic_url(@pic) else render :action => :new end end def sh...
Ruby
class RatingController < ApplicationController def rate @entry = Entry.find(params[:id]) Rating.delete_all(["rateable_type = 'Entry' AND rateable_id = ? AND user_id = ?", @entry.id, current_user.id]) @entry.add_rating Rating.new(:rating => params[:rating], :user_id => current_user.id) ...
Ruby
class CommentsController < ApplicationController before_filter :login_required, :only=> [:destroy, :update, :edit, :create, :new, :show, :index] #before_filter :check_user, :only => [:destroy, :update, :edit] # GET /comments # GET /comments.xml def index @entry = Entry.find(params[:entry_id]) @comments...
Ruby
# This controller handles the login/logout function of the site. class SessionsController < ApplicationController # Be sure to include AuthenticationSystem in Application Controller instead include AuthenticatedSystem # render new.rhtml def new end def create logout_keeping_session! user = User....
Ruby
class UserpicsController < ApplicationController def index @userpics = Userpic.find(:all) end def new @userpic = Userpic.new end def create @userpic = Userpic.new(params[:userpic]) if @userpic.save flash[:notice] = 'Userpic was successfully created.' redirect_to userpic_url(@userpic) e...
Ruby
class InfosController < ApplicationController # GET /infos # GET /infos.xml def index @infos = Info.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @infos } end end # GET /infos/1 # GET /infos/1.xml def show @info = Info.find(params...
Ruby