code
stringlengths
1
1.73M
language
stringclasses
1 value
# 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 protect_from_forgery # See ActionController::RequestForgeryPr...
Ruby
class ArticlesController < ApplicationController # GET /articles # GET /articles.xml uses_tiny_mce :options => { :width => '620', :height => '400', :theme => "advanced", :plugins => "paste,preview,insertdatetime,media", :theme_advanced_buttons1 => "formatselect,fontselect,fontsizeselect,|,fo...
Ruby
class DisplayController < ApplicationController caches_page :index def index @tag="index" @articles=Article.find(:all,:limit => 13) end end
Ruby
class NewsController < ApplicationController layout 'display' caches_page :index,:show def index @title="明珠动态" @tag = "news" @news=Article.paginate(:per_page => 12,:page => params[:page],:select => "id,title,short_des,created_at",:order => 'created_at desc') end def show @news = Article.find...
Ruby
class NavigationsController < ApplicationController # GET /navigations # GET /navigations.xml def index @navigations = Navigation.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @navigations } end end # GET /navigations/1 # GET /navigations/1.xm...
Ruby
class WebConfigsController < ApplicationController # GET /web_configs # GET /web_configs.xml uses_tiny_mce :options => { :width => '620', :height => '400', :theme => "advanced", :plugins => "paste,preview,insertdatetime,media", :theme_advanced_buttons1 => "formatselect,fontselect,fontsizese...
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
# 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
# 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
ActionController::Routing::Routes.draw do |map| map.resources :web_configs map.resources :articles map.resources :news,:only => [:index,:show] map.resources :company,:controller => 'web_configs',:only => :show map.resources :navigations # The priority is based upon order of creation: first created -> h...
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.2' 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
class CreateWebConfigs < ActiveRecord::Migration def self.up create_table :web_configs do |t| t.string :name t.string :description t.integer :style t.text :content end end def self.down drop_table :web_configs end end
Ruby
class AddShortDesToArticles < ActiveRecord::Migration def self.up add_column(:articles,:short_des,:string) end def self.down remove_column(:articles,:short_des) end end
Ruby
class CreateArticles < ActiveRecord::Migration def self.up create_table :articles do |t| t.string :title t.text :content t.timestamps end end def self.down drop_table :articles end end
Ruby
class CreateNavigations < ActiveRecord::Migration def self.up create_table :navigations do |t| t.string :name t.string :display_name t.string :link_address t.integer :ord t.integer :level t.integer :parent_id end end def self.down drop_table :navigations 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.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
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/runner'
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/generate'
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/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" 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/dbconsole'
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
#!/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
module NewsHelper end
Ruby
module WebConfigsHelper end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def page_title @title ? @title+"--北京掌上明珠信息技术有限公司":"北京掌上明珠信息技术有限公司" end end
Ruby
module NavigationsHelper end
Ruby
module ArticlesHelper end
Ruby
module DisplayHelper end
Ruby
class WebConfig < ActiveRecord::Base end
Ruby
class Navigation < ActiveRecord::Base end
Ruby
class Article < ActiveRecord::Base 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 protect_from_forgery # See ActionController::RequestForgeryPr...
Ruby
class ArticlesController < ApplicationController # GET /articles # GET /articles.xml uses_tiny_mce :options => { :width => '620', :height => '400', :theme => "advanced", :plugins => "paste,preview,insertdatetime,media", :theme_advanced_buttons1 => "formatselect,fontselect,fontsizeselect,|,fo...
Ruby
class DisplayController < ApplicationController caches_page :index def index @tag="index" @articles=Article.find(:all,:limit => 13) end end
Ruby
class NewsController < ApplicationController layout 'display' caches_page :index,:show def index @title="明珠动态" @tag = "news" @news=Article.paginate(:per_page => 12,:page => params[:page],:select => "id,title,short_des,created_at",:order => 'created_at desc') end def show @news = Article.find...
Ruby
class NavigationsController < ApplicationController # GET /navigations # GET /navigations.xml def index @navigations = Navigation.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @navigations } end end # GET /navigations/1 # GET /navigations/1.xm...
Ruby
class WebConfigsController < ApplicationController # GET /web_configs # GET /web_configs.xml uses_tiny_mce :options => { :width => '620', :height => '400', :theme => "advanced", :plugins => "paste,preview,insertdatetime,media", :theme_advanced_buttons1 => "formatselect,fontselect,fontsizese...
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
# 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
# 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
ActionController::Routing::Routes.draw do |map| map.resources :web_configs map.resources :articles map.resources :news,:only => [:index,:show] map.resources :company,:controller => 'web_configs',:only => :show map.resources :navigations # The priority is based upon order of creation: first created -> h...
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.2' 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
# 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
# encoding: utf-8 # Set the default text field size when input is a string. Default is nil. # Formtastic::FormBuilder.default_text_field_size = 50 # Set the default text area height when input is a text. Default is 20. # Formtastic::FormBuilder.default_text_area_height = 5 # Set the default text area width when inpu...
Ruby
I18n.default_locale = :en LANGUAGES = [ ['English', 'en'], ["Vienamese".html_safe, 'vi'] ]
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. Library::Application.config.session_store :cookie_store, key: '_library_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 g...
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
Sunspot.config.pagination.default_per_page = 3000
Ruby
Library::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
MAILER_CONFIG = YAML.load_file("#{Rails.root}/config/mailer_config.yml")[Rails.env] Library::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 respons...
Ruby
Library::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 su...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Library::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
Library::Application.routes.draw do scope '(:locale)' do devise_for :users resources :categories resources :books do resources :transactions controller :transactions do put 'update_status' => 'transactions#update_status', as: :update_status put 'remind' => 'transaction...
Ruby
module ApplicationHelper def sortable(path, column, title = nil) title ||= column.to_s.titleize direction = (column.to_s == sort_column && sort_direction == 'asc') ? 'desc' : 'asc' link_to title, path.call(column, direction) end end
Ruby
module BookInfosHelper end
Ruby
module UsersHelper end
Ruby
module SessionsHelper end
Ruby
module CategoriesHelper end
Ruby
module BookInfoHelper end
Ruby
module SearchHelper def search_path_proc Proc.new do |column, direction| search_path(sort: column, direction: direction) end end end
Ruby
module TransactionHelper def transactions_path_proc Proc.new do |column, direction| book_transactions_path(sort: column, direction: direction) end end def all_transactions_path_proc Proc.new do |column, direction| all_transactions_path(sort: column, direction: direction) end end ...
Ruby
module BooksHelper def book_path_proc Proc.new do |column, direction| books_path(sort: column, direction: direction) end end end
Ruby
class Category < ActiveRecord::Base has_many :book validates :name, presence: true validates_uniqueness_of :name attr_accessible :name, :description end
Ruby
class Rate < ActiveRecord::Base belongs_to :rater, :class_name => "User" belongs_to :rateable, :polymorphic => true validates_numericality_of :stars, :minimum => 1 attr_accessible :rate, :dimension end
Ruby
class BookInfo < ActiveRecord::Base belongs_to :category attr_accessible :author, :isbn, :name, :numOfVote, :publishDate, :publisher, :vote, :category_id #Added by Son Nguyen - 11/08/2012 - 11:48pm attr_accessible :numberOfVote, :category #Added by Son Nguyen - 11/08/2012 - 11:48pm validates :isbn, :...
Ruby
class Book < ActiveRecord::Base validates :isbn, :name, presence: true validates_uniqueness_of :isbn belongs_to :category has_one :attachment has_many :transactions, dependent: :destroy acts_as_commentable ajaxful_rateable :stars => 10, :dimensions => [:quality] mount_uploader :image, ImageUploader ...
Ruby