code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class CreateQuizzes < ActiveRecord::Migration
def self.up
create_table :quizzes do |t|
t.references :user
t.boolean :isquiz
t.string :title
t.text :description
t.boolean :ready
t.text :scoring
t.timestamps
end
end
def self.down
drop_table :quizzes
end
end... | Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.text :description
t.string :hashed_password
t.string :salt
t.timestamps
end
end
def self.down
drop_table :users
end
end
| 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.expand_path('../config/application', __FILE__)
require 'rake'
LoginDemo::Application.load_tasks
| Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run LoginDemo::Application
| Ruby |
LoginDemo::Application.routes.draw do
resources :answers
get "takequiz/question"
get "takequiz/complete"
get "createquiz/newquiz"
get "createquiz/newquestion"
get "createquiz/addanswer"
get "user/login"
get "user/new"
post "user/create"
post "user/validate"
get "user/choose"
get "t... | Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module LoginDemo
class Application < Rails::Application
... | Ruby |
LoginDemo::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 |
LoginDemo::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 tes... | Ruby |
LoginDemo::Application.configure do
# Settings specified here will take precedence over those in config/application.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 ... | Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gem... | 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.
LoginDemo::Application.config.session_store :cookie_store, :key => '_LoginDemo_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 |
# 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.
# 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 |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
LoginDemo::Application.initialize!
| Ruby |
environment = :production
project_type = :stand_alone
http_path = "/"
css_dir = "../styles"
sass_dir = "."
images_dir = "images"
sass_options = {
:line_numbers => false,
:debug_info => false
}
# output_style = :compressed
# output_style = :compact
output_style = :expanded
| Ruby |
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2010,
:DocumentRoot => Dir::pwd
)
s.mount('/sh/scripts', WEBrick::HTTPServlet::FileHandler, '../scripts')
s.mount('/sh/styles', WEBrick::HTTPServlet::FileHandler, '../styles')
trap('INT') { s.stop }
s.start
| Ruby |
# $ext_path: This should be the path of where the ExtJS SDK is installed
# Generally this will be in a lib/extjs folder in your applications root
# <root>/lib/extjs
$ext_path = "../../"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a resource... | Ruby |
# include the utils rb file which has extra functionality for the ext theme
dir = File.dirname(__FILE__)
require File.join(dir, 'lib', 'utils.rb')
# register ext4 as a compass framework
Compass::Frameworks.register 'ext4', dir | Ruby |
# $ext_path: This should be the path of where the ExtJS SDK is installed
# Generally this will be in a lib/extjs folder in your applications root
# <root>/lib/extjs
$ext_path = "../../lib/extjs"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a... | Ruby |
module ExtJS4
module SassExtensions
module Functions
module Utils
def parsebox(list, n)
assert_type n, :Number
if !n.int?
raise ArgumentError.new("List index #{n} must be an integer")
elsif n.to_i < 1
raise ArgumentError.new("List index #{n} must... | 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.
# 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 |
# 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 |
# 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 |
# 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 |
# 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.resources :users
map.resources :grindselects
map.resources :products
map.resources :farms
map.resources :nationals
map.resources :commoncodes
map.resources :store
map.resources :basecode
map.resource :admin
# The priority is based upon order of cr... | Ruby |
module AdminHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def javascript(*files)
content_for(:head) { javascript_include_tag(*files) }
end
#def stylesheet(*files)
# content_for(:head) { stylesheet_link_tag(*files) }
#end
end
| Ruby |
module UsersHelper
end
| Ruby |
module CommoncodesHelper
end
| Ruby |
module PricesHelper
end
| Ruby |
module ProductsHelper
def add_price_link(name)
link_to_function name do |page|
page.insert_html :bottom, :price, :partial => 'price', :object => Price.new
end
end
def add_productorigin_link(name)
link_to_function name do |page|
page.insert_html :bottom, :productorigin, :partial => 'pr... | Ruby |
module BasecodeHelper
end
| Ruby |
module NationalsHelper
end
| Ruby |
module JavascriptsHelper
end
| Ruby |
module ProductoriginsHelper
end
| Ruby |
module StoreHelper
def hidden_div_if(condition, attributes = {}, &block)
if condition
attributes["style" ] = "display: none"
end
content_tag("div" , attributes, &block)
end
end
| Ruby |
module GrindselectsHelper
end
| Ruby |
module FarmsHelper
end
| Ruby |
class CartItem
attr_reader :product, :quantity, :price, :grind, :name
def initialize(product, quantity, price, grind, name)
@product = product
@price = price
@quantity = quantity
@grind = grind
@name = name
end
def increment_quantity(quantity)
@quantity += quantity
end
def ... | Ruby |
class Cart
attr_reader :items
def initialize
@items = []
end
def add_product(product, quantity, price, grind, name)
current_item = @items.find {|item| item.product == product}
if current_item
current_item.increment_quantity(quantity)
else
current_item = CartItem.new(product, quantity, p... | Ruby |
class User < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
attr_accessor :password_confirmation
validates_confirmation_of :password
validate :password_non_blank
def password
@password
end
def password=(pwd)
@password = pwd
return if pwd.blank?
... | Ruby |
class Commoncode < ActiveRecord::Base
validates_uniqueness_of :Code, :case_sensitive => false
validates_presence_of :Code, :Name, :EName, :InUse, :CodeLevel, :Type
validates_length_of :Code, :within => 2..8
def self.find_master_codes
find(:all, :order => "code", :select => "Code, Name", :conditions =>[" ... | Ruby |
class National < ActiveRecord::Base
has_many :Farm
has_many :Product
has_many :Productorigin
validates_presence_of :NationName
validates_presence_of :EnNationName
validates_uniqueness_of :EnNationName
end
| Ruby |
class Grindselect < ActiveRecord::Base
validates_presence_of :code
validates_presence_of :name
validates_uniqueness_of :code
end
| Ruby |
class Farm < ActiveRecord::Base
belongs_to :National, :foreign_key => :national_id
has_many :Product
has_many :Productorigin
validates_presence_of :farmName,
:message => "농장이름을 입력해 주세요"
validates_presence_of :enFarmName,
:message => "농장이름을 영문으로 입력해 주세요"
validates_uniqueness_of :enFarmName,
:mess... | Ruby |
class Product < ActiveRecord::Base
#association
belongs_to :National, :foreign_key => :national_id
belongs_to :Farm, :foreign_key => :farm_id
has_many :prices, :dependent => :destroy
has_many :productorigins, :dependent=> :destroy
belongs_to :commoncodes, :foreign_key => :product_type
#validation
valid... | Ruby |
class Price < ActiveRecord::Base
belongs_to :Product, :foreign_key => :product_id
end
| Ruby |
class Productorigin < ActiveRecord::Base
has_many :National, :foreign_key => :national_id
has_many :Farm, :foreign_key => :farm_id
belongs_to :Product, :foreign_key => :product_id
end
| Ruby |
class ProductsController < ApplicationController
# GET /products
# GET /products.xml
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @products }
end
end
# GET /products/1
# GET /products/1.xml
def show
@product... | Ruby |
class UsersController < ApplicationController
# GET /users
# GET /users.xml
def index
@users = User.find(:all, :order => :name)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# GET /users/1
# GET /users/1.xml
def show
@user =... | Ruby |
class NationalsController < ApplicationController
# GET /nationals
# GET /nationals.xml
def index
@nationals = National.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @nationals }
end
end
# GET /nationals/1
# GET /nationals/1.xml
def show
... | Ruby |
class AdminController < ApplicationController
def login
if request.post?
user = User.authenticate(params[:name], params[:password])
if user
debugger
session[:user_id] = user.id
redirect_to(:action => "index")
else
flash.now[:notice] = "Invalid user/password combin... | Ruby |
class PricesController < ApplicationController
# GET /prices
# GET /prices.xml
def index
@prices = Price.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @prices }
end
end
# GET /prices/1
# GET /prices/1.xml
def show
@price = Price.find(par... | Ruby |
class FarmsController < ApplicationController
# GET /farms
# GET /farms.xml
def index
@farms = Farm.find(:all, :order=>:id)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @farms }
end
end
# GET /farms/1
# GET /farms/1.xml
def show
@far... | 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::RequestForgeryProt... | Ruby |
class JavascriptsController < ApplicationController
def dynamic_farms
@farms= Farm.find(:all)
end
def dynamic_bagsize
@products = Product.find(:all)
end
def dynamic_basecode
@basecode = Commoncode.find(:all)
end
end
| Ruby |
class BasecodeController < ApplicationController
#before_filter :login_required, :except=> [ :index, :list]
def index
@mastercode = Commoncode.find_master_codes
@basecode = Commoncode.search(params[:parentcode])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml =... | Ruby |
class GrindselectsController < ApplicationController
# GET /grindselects
# GET /grindselects.xml
def index
@grindselects = Grindselect.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @grindselects }
end
end
# GET /grindselects/1
# GET /grindsele... | Ruby |
class ProductoriginsController < ApplicationController
# GET /productorigins
# GET /productorigins.xml
def index
@productorigins = Productorigin.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @productorigins }
end
end
# GET /productorigins/1
# ... | Ruby |
# -*- coding: utf-8 -*-
class StoreController < ApplicationController
# before_filter :login_required, :except=> [ :indexg]
def index
@products = Product.find_products_for_sale
@cart = find_cart
@grind = Grindselect.find(:all)
end
def show
@product = Product.find(params[:id])
@cart = find_... | Ruby |
class UsersController < ApplicationController
# GET /users
# GET /users.xml
def index
@users = User.find(:all, :order => :name)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# GET /users/1
# GET /users/1.xml
def show
@user =... | Ruby |
class CommoncodesController < ApplicationController
# GET /commoncodes
# GET /commoncodes.xml
def index
@commoncodes = Commoncode.find(:all, :conditions => ["CodeLevel = 0"])
@mastercode = Commoncode.find_master_codes
# @basecode = Commoncode.find_detail_codes
@basecode = Commoncode.search(param... | 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 |
#!/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/runner'
| 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/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/profiler'
| 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/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/dbconsole'
| 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/console'
| 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/server'
| 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/plugin'
| Ruby |
class CreateSessions < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
end
def self.down
drop_table :sessions
end
end
| Ruby |
class CreateCommoncodes < ActiveRecord::Migration
def self.up
create_table :commoncodes do |t|
t.string :Code
t.string :Name
t.string :EName
t.string :Alias
t.text :Descriprion
t.boolean :InUse
t.string :CodeLevel
t.string :ParentCode
t.string :Type
t.t... | Ruby |
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.integer :national_id
t.integer :farm_id
t.string :level
t.text :desc1
t.text :desc2
t.integer :body
t.integer :acidity
t.string :product_yrs
t.string :image_url
t.... | Ruby |
class CreatePrices < ActiveRecord::Migration
def self.up
create_table :prices do |t|
t.integer :product_id, :null =>false
t.string :bag_size, :null=>false
t.decimal :price, :null=>false, :precision =>8, :scale=>0
t.timestamps
end
end
def self.down
drop_table :prices
end
end... | Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :hashed_password
t.string :salt
t.timestamps
end
end
def self.down
drop_table :users
end
end
| Ruby |
class CreateNationals < ActiveRecord::Migration
def self.up
create_table :nationals do |t|
t.string :NationName
t.string :EnNationName
t.string :Level1
t.string :Level2
t.string :Level3
t.string :Level4
t.string :Level5
t.timestamps
end
end
def self.down
... | Ruby |
class CreateGrindselects < ActiveRecord::Migration
def self.up
create_table :grindselects do |t|
t.string :code
t.string :name
t.string :desc
t.timestamps
end
end
def self.down
drop_table :grindselects
end
end
| Ruby |
class ChangeProduct < ActiveRecord::Migration
def self.up
remove_column :products, :national_id, :farm_id, :level, :image_url, :p200,:p500, :p1000,:p6m200,:p6m1000, :p12m200, :p12m500, :p12m1000
add_column :products, :name, :string
add_column :products, :product_type, :string
end
def self.down
remove_column ... | Ruby |
class CreateFarms < ActiveRecord::Migration
def self.up
create_table :farms do |t|
t.string :farmName
t.string :enFarmName
t.string :nationName
t.integer :national_id
t.timestamps
end
end
def self.down
drop_table :farms
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.