code
stringlengths
1
1.73M
language
stringclasses
1 value
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, :on => :create validates :name,:presence => true, :length => { :within => 3..30 }, :uniqueness => true validate...
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
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 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" t.column :available,'integer unsigned', :limit => 6 t.column :buy,'integer unsigned', ...
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.date "end_day" t.text "description" t.column :available,'integer unsigned', :limit => 6 ...
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users 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, :boolean, :default =...
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.date "time" t.column :price,'integer unsigned', :limit => 10 t.timestamps end end end
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" 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 '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
module CartsHelper end
Ruby
module ProducesHelper end
Ruby
class End < ActiveRecord::Base belongs_to :cart end
Ruby
class Cart < ActiveRecord::Base has_many :produces has_many :ends belongs_to :user end
Ruby
class User < ActiveRecord::Base has_one :cart end
Ruby
class News < ActiveRecord::Base end
Ruby
class Produce < ActiveRecord::Base belongs_to :cart end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery end
Ruby
class CartsController < ApplicationController def index end def list @carts = Cart.order("carts.name ASC") end end
Ruby
class ProducesController < ApplicationController #There have admin and user actions #For Admin def list @produces = Produce.order("produces.name ASC") end def show @produce = Produce.find(params[:id]) end def new @produce = Produce.new end def create @produce = Produce.new(params[:produ...
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 'pr...
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, :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