code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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/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/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/performance/benchmarker'
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/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module EventsHelper end
Ruby
module AccountHelper end
Ruby
module ResourcesHelper end
Ruby
module UsersHelper end
Ruby
module SeatsHelper end
Ruby
module ReservationsHelper end
Ruby
module SpacesHelper end
Ruby
module HomeHelper end
Ruby
class Reservation < ActiveRecord::Base belongs_to :space belongs_to :user end
Ruby
class Event < ActiveRecord::Base belongs_to :space def display_date self.date.strftime('%A, %B %d') end end
Ruby
class Space < ActiveRecord::Base has_many :events has_and_belongs_to_many :users has_many :reservations end
Ruby
class Seat < ActiveRecord::Base end
Ruby
require 'digest/sha1' class User < ActiveRecord::Base # Virtual attribute for the unencrypted password attr_accessor :password validates_presence_of :login, :email validates_presence_of :password, :if => :password_required? validates_presence_of :password_confirmation, :if ...
Ruby
class Resource < ActiveRecord::Base end
Ruby
class EventsController < ApplicationController def index @events = Event.find(:all, :order => 'date desc') end def new @spaces = Space.find(:all) end def view @event = Event.find(params[:id]) end def create event = Event.create!(params[:event]) Twitter.post("#{event.name} @ #{...
Ruby
class SpacesController < ApplicationController before_filter :login_required, :only => [ :join, :schedule ] def index @spaces = Space.find(:all) end def view @space = Space.find(params[:id]) end def create Space.create!(params[:space]) redirect_to :action => 'index' end def e...
Ruby
class AccountController < ApplicationController # Be sure to include AuthenticationSystem in Application Controller instead include AuthenticatedSystem # If you want "remember me" functionality, add this before_filter to Application Controller before_filter :login_from_cookie # say something nice, you goof! ...
Ruby
class SeatsController < ApplicationController end
Ruby
class HomeController < ApplicationController def index @spaces = Space.find(:all) @events = Event.find(:all) @users = User.find(:all) end end
Ruby
class UsersController < ApplicationController def view @user = User.find(params[:id]) end def approve ActiveRecord::Base.connection().execute("update spaces_users set status = 'approved' where user_id = #{params[:user]} and space_id = #{params[:space]}") redirect_to :controller => 'spaces', :action...
Ruby
class ReservationsController < ApplicationController def create space = Space.find(params[:space]) reservation = Reservation.new(params[:reservation]) reservations = Reservation.find(:all, :conditions => ["date = ? and space_id = ?", reservation.date, space.id]) member = User.find_by_sql("select * fro...
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 # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_Coworker_s...
Ruby
class ResourcesController < ApplicationController end
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
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
Ruby
# Be sure to restart your web 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 ...
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
# 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 != :false end # Accesses the current user from the session. def current_user @current_user ||= ...
Ruby
module AuthenticatedTestHelper # Sets the current user in the session from the user fixtures. def login_as(user) @request.session[:user] = user ? users(user).id : nil end def content_type(type) @request.env['Content-Type'] = type end def accept(accept) @request.env["HTTP_ACCEPT"] = accept en...
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: 'Emanuel...
Ruby
class AddAttachmentBanner1ToBanners < ActiveRecord::Migration def self.up change_table :banners do |t| t.attachment :banner1 end end def self.down drop_attached_file :banners, :banner1 end end
Ruby
class AddAttachmentBanner5ToBanners < ActiveRecord::Migration def self.up change_table :banners do |t| t.attachment :banner5 end end def self.down drop_attached_file :banners, :banner5 end end
Ruby
class AddFriendPhoneToSertificates < ActiveRecord::Migration def change add_column :sertificates, :friend_phone, :string , :default => "", :null=>false change_column :sertificates, :friend_email, :string , :default => "", :null=>false change_column :sertificates, :address, :string , :default => "", :null...
Ruby
class AddAttachmentBanner3ToBanners < ActiveRecord::Migration def self.up change_table :banners do |t| t.attachment :banner3 end end def self.down drop_attached_file :banners, :banner3 end end
Ruby
class CreateSertificates < ActiveRecord::Migration def change create_table :sertificates do |t| t.string :kind t.string :friend_name t.string :friend_email t.string :name t.string :email t.string :phone t.text :address t.text :description t.string :price ...
Ruby
class AddTitle < ActiveRecord::Migration def change add_column :banners, :title, :string end end
Ruby
class AddBgColor < ActiveRecord::Migration def change add_column :lookbooks, :bgcolor, :string end end
Ruby
class AddPaidToSertificates < ActiveRecord::Migration def change add_column :sertificates, :paid, :boolean, :default => false, :null => false add_column :sertificates, :order, :string, :default => "", :null=>false end end
Ruby
class AddColorToNews < ActiveRecord::Migration def change add_column :news, :color, :string end end
Ruby
class AddAttachmentBanner2ToBanners < ActiveRecord::Migration def self.up change_table :banners do |t| t.attachment :banner2 end end def self.down drop_attached_file :banners, :banner2 end end
Ruby
class CreateLookbooks < ActiveRecord::Migration def change create_table :lookbooks do |t| t.text :title t.text :info t.integer :sort t.timestamps end end end
Ruby
class CreateFeedbacks < ActiveRecord::Migration def change create_table :feedbacks do |t| t.string :code t.string :user_id t.integer :answer t.text :comment t.timestamps end end end
Ruby
class AddAttachmentBanner4ToBanners < ActiveRecord::Migration def self.up change_table :banners do |t| t.attachment :banner4 end end def self.down drop_attached_file :banners, :banner4 end end
Ruby
class DeviseCreateAdmins < ActiveRecord::Migration def change create_table(:admins) do |t| ## Database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" ## Recoverable t.string :reset_password_token ...
Ruby
class CreateBanners < ActiveRecord::Migration def change create_table :banners do |t| t.timestamps end end end
Ruby
class AddAttachmentBackgroundToLookbooks < ActiveRecord::Migration def self.up change_table :lookbooks do |t| t.attachment :background end end def self.down drop_attached_file :lookbooks, :background end end
Ruby
class AddAttachmentPictureToNews < ActiveRecord::Migration def self.up change_table :news do |t| t.attachment :picture end end def self.down drop_attached_file :news, :picture end end
Ruby
class CreateNews < ActiveRecord::Migration def change create_table :news do |t| t.string :title t.text :preview_text t.text :detail_text t.string :size t.date :date_from t.timestamps end end end
Ruby
class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable t.string :email, :null => false, :default => "" t.string :encrypted_password, :null => false, :default => "" ## Recoverable t.string :reset_password_to...
Ruby
class AddAttachmentPictureToLookbooks < ActiveRecord::Migration def self.up change_table :lookbooks do |t| t.attachment :picture end end def self.down drop_attached_file :lookbooks, :picture end end
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 integrati...
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__) Costumecode::Application.load_tasks
Ruby
source 'http://rubygems.org' gem 'rails', '3.2.13' gem 'mysql2' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 1.2' gem 'devise' gem 'sqlite3' gem 'execjs' gem 'therubyracer', :platform => :ruby group :development do gem 'letter_opener' gem 'better_errors'...
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
module ApplicationHelper end
Ruby
module CertificatesHelper end
Ruby
module AdminHelper end
Ruby
module SiteHelper end
Ruby
module FeedbackHelper end
Ruby
module HomeHelper end
Ruby
#encoding: utf-8 class CertificateMailer < ActionMailer::Base default from: "gift@costumecode.ru" @@to = "certificate@costumecode.ru" def self.to @@to end def new_certificate(certificate) @certificate = certificate mail to: CertificateMailer.to, subject: 'Новый сертификат' end d...
Ruby
class CCMailer < ActionMailer::Base default from: "gift@costumecode.ru" @@to = "contact@costumecode.ru" def self.to @@to end def new_order(data) @data = data mail(:to => CCMailer.to, :subject => "New call order") end def new_news(data) @data = data mail(:to => CCMailer.to, :subject =...
Ruby
class Admin < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for you...
Ruby
class Feedback < ActiveRecord::Base attr_accessible :answer, :code, :comment, :user_id end
Ruby
class Banners < ActiveRecord::Base attr_accessible :title, :banner1, :banner2, :banner3, :banner4, :banner5 has_attached_file :banner1, :styles => { :small => "300x200#", :big => "1280x850#"}, :default_url => "/images/missing.png" has_attached_file :banner2, :styles => { :small => "300x200#", :big => "1280x850#"...
Ruby
class Lookbook < ActiveRecord::Base attr_accessible :info, :sort, :title, :bgcolor, :picture, :background has_attached_file :picture, :styles => { :small => "600x570", :big => "600x570"}, :default_url => "/images/missing.png" has_attached_file :background, :styles => { :small => "600x570", :big => "1600x1400#"...
Ruby
class Sertificate < ActiveRecord::Base attr_accessible :address, :date_send, :description, :email, :friend_email, :friend_name, :kind, :name, :pay_method, :phone, :price, :receiver, :friend_phone end
Ruby
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable #devise :database_authenticatable, :registerable, # :recoverable, :rememberable, :trackable, :validatable devise :database_aut...
Ruby
class News < ActiveRecord::Base attr_accessible :date_from, :detail_text, :preview_text, :size, :title, :color, :picture has_attached_file :picture, :styles => { :small => "160x156#", :big => "359x192#"}, :default_url => "/images/missing.png" end
Ruby
class FeedbackController < ApplicationController layout 'empty' def index if !params[:SalesID].blank? && !params[:Response].blank? @feedback = Feedback.where("user_id = ? AND answer = ?", params[:SalesID], params[:Response]).first if @feedback.blank? fields = Hash.new ...
Ruby
class ApplicationController < ActionController::Base layout :layout_by_resource def layout_by_resource if devise_controller? "empty" else "application" end end protect_from_forgery end
Ruby
class HomeController < ApplicationController def index @news = News.order("date_from DESC").find(:all) end end
Ruby
class SiteController < ApplicationController def index checkParams(params) setParams(params) end def en checkParams(params) setParams(params) end def setParams(params) if (params[:landing]) @landing = true end if !params[:news].blank? @share = News.where("id = ?", pa...
Ruby
#encoding: utf-8 class CertificatesController < ApplicationController before_filter :set_certificate def set_certificate @certificate = true end def create begin @certificate = Sertificate.new(params.except(:action, :controller)) @certificate.price.gsub!(/[\sР\.]/, '') if(params[:dat...
Ruby
class AdminController < ApplicationController before_filter :authenticate_user! ###### Home Page ###### def home @banners = Banners.first if params[:banners] respond_to do |format| if @banners.update_attributes(params[:banners]) format.html { redirect_to "/admin",...
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
# Be sure to restart your server when you modify this file. Rails.application.config.action_dispatch.cookies_serializer = :json
Ruby
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails...
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. Costumecode::Application.config.session_store :cookie_store, key: '_costumecode_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 ...
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