code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/usr/bin/ruby1.8 #!/usr/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 performan...
Ruby
#!/usr/bin/ruby1.8 #!/usr/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/...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # RoleRequirementTestHelper must be included to test RoleRequirement include RoleRequirementTestHelper # Transactional fixtures accelerate your tests by wrapping e...
Ruby
#! /usr/bin/env ruby # # Generate a random context - used for testing. def attrs(n,f) 1.upto(n) { |i| if rand(100) < f then print "a#{i} " end } puts ";" end def table(m,n,f) 1.upto(m) { |i| print "o#{i}: " attrs(n,f) } end if $*.length != 3 then $stderr.puts "usage: ...
Ruby
#! /usr/bin/env ruby # # Generate a random context - used for testing. def attrs(n,f) 1.upto(n) { |i| if rand(100) < f then print "a#{i} " end } puts ";" end def table(m,n,f) 1.upto(m) { |i| print "o#{i}: " attrs(n,f) } end if $*.length != 3 then $stderr.puts "usage: ...
Ruby
require 'rubygems' require 'uglifier' desc "Use the Closure Compiler to compress Underscore.js" task :build do source = File.read('underscore.js') min = Uglifier.compile(source) File.open('underscore-min.js', 'w') {|f| f.write min } end desc "Build the docco documentation" task :doc do sh "docco undersco...
Ruby
require 'rubygems' require 'uglifier' desc "Use the Closure Compiler to compress Underscore.js" task :build do source = File.read('underscore.js') min = Uglifier.compile(source) File.open('underscore-min.js', 'w') {|f| f.write min } end desc "Build the docco documentation" task :doc do sh "docco undersco...
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 CreateCarts < ActiveRecord::Migration def change create_table :carts, :id => false do |t| t.column :pro_id, 'integer unsigned', :limit => 6 t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "email", :limit => 30 t.date "time" t.column :available,'integer unsigned', :lim...
Ruby
class CreateProduces < ActiveRecord::Migration def change create_table :produces, :id => false do |t| t.column :pro_id, 'integer unsigned', :limit => 6 t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "origin", :limit => 30 t.date "end_day" t.text "description" t.column :...
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users,:id => false do |t| t.string "email", :limit => 30 t.string "password", :limit => 20 t.string "name", :limit => 30 t.string "phone", :limit => 15 t.string "address", :limit => 50 t.column :admin, :boolea...
Ruby
class CreateEnds < ActiveRecord::Migration def change create_table :ends, :id => false do |t| t.column :pro_id, 'integer unsigned', :limit => 6 t.string "name", :limit => 40 t.string "email", :limit => 30 t.date "time" t.column :price,'integer unsigned', :limit => 10 t.timestamps end exe...
Ruby
class CreateNews < ActiveRecord::Migration def change create_table :news, :id => false do |t| t.column :id, 'integer unsigned', :limit => 4 t.string "image", :limit => 60 t.string "name", :limit => 40 t.text "description" t.date "time" t.timestamps end execute "ALTER TABLE news ADD PR...
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__) Coffee2go::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'rails', '3.2.1' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3....
Ruby
module ApplicationHelper end
Ruby
class End < ActiveRecord::Base set_primary_key :pro_id end
Ruby
class Cart < ActiveRecord::Base set_primary_key :pro_id end
Ruby
class User < ActiveRecord::Base end
Ruby
class News < ActiveRecord::Base set_primary_key :id end
Ruby
class Produce < ActiveRecord::Base set_primary_key :pro_id 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. # # 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. # 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. Coffee2go::Application.config.session_store :cookie_store, key: '_coffee_2go_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 "ra...
Ruby
Coffee2go::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: # match 'pro...
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
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Coffee2go::Application.initialize!
Ruby
Coffee2go::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.acti...
Ruby
Coffee2go::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 ...
Ruby
Coffee2go::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 ...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Coffee2go::Application
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__) Coffee2go::Application.load_tasks
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 CreateCarts < ActiveRecord::Migration def change create_table :carts do |t| t.references :user t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "email", :limit => 30 t.date "time_new" t.column :available,'integer unsigned', :limit => 6 t.column :buy,'integer unsigne...
Ruby
class CreateProduces < ActiveRecord::Migration def change create_table :produces do |t| t.references :cart t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "origin", :limit => 30 t.string "type_of_produce" t.string "taste" t.date "end_day" t.text "description" t.col...
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string "email", :limit => 30 t.string "hashed_password", :limit => 40 t.string "name", :limit => 30 t.string "phone", :limit => 15 t.string "address", :limit => 50 t.string "salt", :limit => 50 ...
Ruby
class CreateCartProduces < ActiveRecord::Migration def change create_table :cart_produces do |t| t.references :cart t.references :produce t.date "time_new" t.timestamps end add_index :cart_produces, ['cart_id', 'produce_id'] end end
Ruby
class CreateEnds < ActiveRecord::Migration def change create_table :ends do |t| t.references :cart t.string "name", :limit => 40 t.string "email", :limit => 30 t.column :quantity,'integer unsigned', :limit => 6 t.date "time_new" t.column :price,'integer unsigned', :limit => 10 t.timestamps...
Ruby
class CreateNews < ActiveRecord::Migration def change create_table :news do |t| t.string "image", :limit => 60 t.string "name", :limit => 40 t.text "description" t.date "time_new" t.timestamps end 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__) Coffee2go::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'will_paginate', '~>3.0' gem 'rails', '3.2.1' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3...
Ruby
module NewsHelper end
Ruby
module ApplicationHelper end
Ruby
module CartsHelper end
Ruby
module BuyProducesHelper end
Ruby
module UserHelper end
Ruby
module ProducesHelper end
Ruby
module UsersHelper end
Ruby
module HomeHelper end
Ruby
# encoding: utf-8 class Notifications < ActionMailer::Base #default from: "knight7night@gmail.com" # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: # # en.notifications.forgot_password.subject # default :from => "no_reply@gmail.com" # if from is not specifi...
Ruby
class End < ActiveRecord::Base belongs_to :cart validates :quantity,:presence => true end
Ruby
class Cart < ActiveRecord::Base has_many :cart_produces has_many :ends belongs_to :user end
Ruby
# encoding: utf-8 require 'digest/sha1' class User < ActiveRecord::Base has_one :cart EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i validates_length_of :password ,:within => 5..20, :message => "Mật khẩu không hợp lệ(phải từ 5 tới 20 kí tự).",:on => :create validates :name,:presence => { :messa...
Ruby
class News < ActiveRecord::Base end
Ruby
class Produce < ActiveRecord::Base has_many :cart_produces attr_accessible :type_of_produce, :taste, :name, :image, :origin, :add_day, :end_day, :description, :available, :buy, :price def time_now return Time.now end end
Ruby
class CartProduce < ActiveRecord::Base belongs_to :cart belongs_to :produce end
Ruby
#encoding: utf-8 class ApplicationController < ActionController::Base protect_from_forgery before_filter :check def login_required if session[:user] return true end flash[:warning]='Bạn cần đăng ký hoặc đăng nhập để tiếp tục' session[:return_to]=request.url redirect_to :controller => "u...
Ruby
# encoding: utf-8 class CartsController < ApplicationController before_filter :login_required def index end def view_cart @cart = Cart.find(:first, :conditions => ["user_id = ?", session[:user].id]) @cart_produces = CartProduce.where(:cart_id => @cart.id).order("cart_produces.time_new DESC") #@produce = ...
Ruby
# encoding: utf-8 require 'will_paginate/array' class ProducesController < ApplicationController #There have admin and user actions #For Admin def index list render('list') end def list_coffee @produces = Produce.find(:all, :conditions => ["type_of_produce = ?", "coffee"], :order => "add_day D...
Ruby
class HomeController < ApplicationController def index list render('list') end def list @produces = Produce.order("produces.add_day DESC") @news = News.order("news.name DESC") @pro_1 @pro_2 @pro_3 if session[:user] @cart = Cart.find(:first, :conditions => ["user_id = ?", session[:user].id]) i...
Ruby
# encoding: utf-8 class UsersController < ApplicationController skip_before_filter :check def signup @user = User.new(params[:user]) if request.post? if @user.save session[:user] = User.authenticate(@user.name, @user.password) cart = Cart.create(params[:cart]) @user.cart = cart ...
Ruby
class NewsController < ApplicationController def index list render('list') end def list @news = News.order("news.name ASC") end def show @produce = News.find(params[:id]) end def new @new = News.new end def create @new = News.new(params[:news]) if @new.save redirect_to(:action => 'list...
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. # 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. Coffee2go::Application.config.session_store :cookie_store, key: '_coffee_2go_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 "ra...
Ruby
Coffee2go::Application.routes.draw do get "user/signup" get "user/login" get "user/logout" get "user/delete" get "user/edit" get "user/forgot_password" # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => ...
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
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 Coffee2go::Application.initialize!
Ruby
Coffee2go::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.acti...
Ruby
Coffee2go::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 ...
Ruby
Coffee2go::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 ...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Coffee2go::Application
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__) Coffee2go::Application.load_tasks
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 CreateCarts < ActiveRecord::Migration def change create_table :carts do |t| t.references :user t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "email", :limit => 30 t.date "time_new" t.column :available,'integer unsigned', :limit => 6 t.column :buy,'integer unsigne...
Ruby
class CreateProduces < ActiveRecord::Migration def change create_table :produces do |t| t.references :cart t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "origin", :limit => 30 t.string "type_of_produce" t.string "taste" t.date "end_day" t.text "description" t.col...
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string "email", :limit => 30 t.string "hashed_password", :limit => 40 t.string "name", :limit => 30 t.string "phone", :limit => 15 t.string "address", :limit => 50 t.string "salt", :limit => 50 ...
Ruby
class CreateCartProduces < ActiveRecord::Migration def change create_table :cart_produces do |t| t.references :cart t.references :produce t.date "time_new" t.timestamps end add_index :cart_produces, ['cart_id', 'produce_id'] end end
Ruby
class CreateEnds < ActiveRecord::Migration def change create_table :ends do |t| t.references :cart t.string "name", :limit => 40 t.string "email", :limit => 30 t.column :quantity,'integer unsigned', :limit => 6 t.date "time_new" t.column :price,'integer unsigned', :limit => 10 t.timestamps...
Ruby
class CreateNews < ActiveRecord::Migration def change create_table :news do |t| t.string "image", :limit => 60 t.string "name", :limit => 40 t.text "description" t.date "time_new" t.timestamps end 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__) Coffee2go::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'will_paginate', '~>3.0' gem 'rails', '3.2.1' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3...
Ruby
module NewsHelper end
Ruby
module ApplicationHelper end
Ruby
module CartsHelper end
Ruby
module BuyProducesHelper end
Ruby
module UserHelper end
Ruby
module ProducesHelper end
Ruby