code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
module CagesHelper
end
| Ruby |
module EmployeesHelper
end
| Ruby |
class Message < ActiveRecord::Base
attr_accessible :employee_id, :message
belongs_to :employee
end
| Ruby |
class Employee < ActiveRecord::Base
attr_accessible :cage_id, :employee_id, :name
belongs_to :cage
has_many :messages, :dependent => :destroy
end
| Ruby |
class Door < ActiveRecord::Base
attr_accessible :entrance_id, :open, :locked
belongs_to :entrance
end
| Ruby |
class Animal < ActiveRecord::Base
attr_accessible :cage_id, :animal_id, :name
belongs_to :cage
end
| Ruby |
class Entrance < ActiveRecord::Base
attr_accessible :cage_id
belongs_to :cage
has_many :doors, :dependent => :destroy
# Is the entrance open
def open?
open = false
# if any door is open, consider the entrance open
self.doors.each do |door|
if door.open?
open = true
end
e... | Ruby |
class Cage < ActiveRecord::Base
attr_accessible :description, :name, :size, :category, :longitude, :latitude,
:date_last_fed, :date_last_cleaned, :lights_on
validates :name, :presence => true
validates :name, :length => { :minimum => 1 }
validates :size, :numericality => { :greater_than_or_equal_to => 5 }
... | Ruby |
class Exhibit < ActiveRecord::Base
attr_accessible :description
has_many :cages, :dependent => :destroy
end
| Ruby |
class EmployeesController < ApplicationController
# GET /employees
# GET /employees.json
def index
@employees = Employee.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @employees }
end
end
# GET /employees/1
# GET /employees/1.json
def show
... | Ruby |
class HomeController < ApplicationController
def index
@cages = Cage.all
@mode = params[:mode]
respond_to do |format|
format.html # index.html.erb
end
end
end
| Ruby |
class ZooSetupUiController < ApplicationController
def index
@cages = Cage.all
@employees = Employee.all
respond_to do |format|
format.html # index.html.erb
end
end
end
| Ruby |
class AnimalsController < ApplicationController
# GET /animals
# GET /animals.json
def index
@animals = Animal.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @animals }
end
end
# GET /animals/1
# GET /animals/1.json
def show
@animal = Anima... | Ruby |
class CagesController < ApplicationController
# GET /cages
# GET /cages.json
def index
@cages = Cage.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @cages }
end
end
# GET /cages/1
# GET /cages/1.json
def show
@cage = Cage.find(params[:id])
... | Ruby |
class EntrancesController < ApplicationController
# GET /entrances
# GET /entrances.json
def index
@cage = Cage.find(params[:cage_id])
@entrances = @cage.entrances
respond_to do |format|
format.html # index.html.erb
format.json { render json: @entrances }
end
end
# GET /entrances... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
class DoorsController < ApplicationController
# GET /doors
# GET /doors.json
def index
@entrance = Entrance.find(params[:entrance_id])
@doors = @entrance.doors
@cage = @entrance.cage
respond_to do |format|
format.html # index.html.erb
format.json { render json: @doors }
end
end
... | Ruby |
class MessagesController < ApplicationController
# GET /messages
# GET /messages.json
def index
@employee = Employee.find(params[:employee_id])
@messages = @employee.messages
respond_to do |format|
format.html # index.html.erb
format.json { render json: @messages }
end
end
# GET ... | 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__)
WebCp2013Zoo::Application.load_tasks
| 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__)
WebCp2013Zoo::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
#gem 'pg'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rai... | Ruby |
class CreateAnimals < ActiveRecord::Migration
def change
create_table :animals do |t|
t.string :animal_id
t.string :name
t.integer :cage_id
end
end
end
| Ruby |
class AddCleanedAndFedDatesToCage < ActiveRecord::Migration
def change
add_column :cages, :date_last_fed, :datetime
add_column :cages, :date_last_cleaned, :datetime
end
end
| Ruby |
class CreateEmployees < ActiveRecord::Migration
def change
create_table :employees do |t|
t.string :employee_id
t.string :name
t.integer :cage_id
end
end
end
| Ruby |
class CreateDoors < ActiveRecord::Migration
def change
create_table :doors do |t|
t.boolean :open
t.boolean :locked
t.integer :entrance_id
end
end
end
| Ruby |
class CreateMessages < ActiveRecord::Migration
def change
create_table :messages do |t|
t.integer :employee_id
t.text :message
end
end
end
| Ruby |
class CreateEntrances < ActiveRecord::Migration
def change
create_table :entrances do |t|
t.integer :cage_id
end
end
end
| Ruby |
class CreateCages < ActiveRecord::Migration
def change
create_table :cages do |t|
t.float :size
t.string :category
t.string :name
t.boolean :lights_on
end
end
end
| Ruby |
class AddLatitudeAndLongitudeToCage < ActiveRecord::Migration
def change
add_column :cages, :latitude, :float
add_column :cages, :longitude, :float
end
end
| 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 |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run WebCp2013Zoo::Application
| 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 |
# 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' }])
# Major.create(:name... | Ruby |
class CreateDesignerWorkItems < ActiveRecord::Migration
def self.up
create_table :designer_work_items do |t|
t.integer :work_item_id,
:designer_id,
:work_item_type_id,
:stage_id
t.decimal :billing_area,
:precision => 8,
:scale => 2
t.integer :work_load, :d... | Ruby |
class CreateProjects < ActiveRecord::Migration
def self.up
create_table :projects do |t|
t.string :name
t.text :remark
t.integer :paused_stages_count,
:paying_stages_count,
:payed_stages_count
t.decimal :payed_total_amount, :precision => 8, :scale => 2, :default => 0
... | Ruby |
class CreateDesigners < ActiveRecord::Migration
def self.up
create_table :designers do |t|
t.integer :department_id
t.string :full_name,
:cell_phone,
:office_phone
t.text :remark
t.timestamps
end
end
def self.down
drop_table :designers
end
end
| Ruby |
class CreateWorkItemTypes < ActiveRecord::Migration
def self.up
create_table :work_item_types do |t|
t.string :name
t.integer :position
t.text :remark
t.timestamps
end
create_table :stages_work_item_types, :id => false do |t|
t.integer :work_item_type_id,
:stage_id
... | Ruby |
class ShouldBePayedKeepScaleTo0 < ActiveRecord::Migration
def self.up
change_column :designer_work_items, :should_be_payed, :decimal, :precision => 8, :scale => 0, :default => 0
change_column :stages, :should_be_payed, :decimal, :precision => 8, :scale => 0, :default => 0
change_column :projects, :payed_t... | Ruby |
class ShouldBePayedKeepScaleTo4 < ActiveRecord::Migration
def self.up
change_column :designer_work_items, :should_be_payed, :decimal, :precision => 8, :scale => 4, :default => 0
change_column :stages, :should_be_payed, :decimal, :precision => 8, :scale => 4, :default => 0
change_column :projects, :payed_t... | Ruby |
class CreateWorkItems < ActiveRecord::Migration
def self.up
create_table :work_items do |t|
t.integer :work_item_type_id,
:stage_id
t.string :name
t.decimal :pay_unit,
:precision => 8,
:scale => 2
t.text :remark
t.timestamps
end
end
def self.down
... | Ruby |
class WorkLoadKeepScaleTo2 < ActiveRecord::Migration
def self.up
change_column :designer_work_items, :work_load, :decimal, :precision => 8, :scale => 2, :default => 100
end
def self.down
change_column :designer_work_items, :work_load, :integer, :default => 100
end
end
| Ruby |
class AddTypeNumAndMotifyNumToDesignerWorkItems < ActiveRecord::Migration
def self.up
add_column :designer_work_items, :type_num, :integer, :default => 100
add_column :designer_work_items, :motify_num, :integer, :default => 100
end
def self.down
remove_column :designer_work_items, :type_num, :motify_... | Ruby |
class AddPayedOnToStages < ActiveRecord::Migration
def self.up
add_column :stages, :payed_on, :date
end
def self.down
remove_column :stages, :payed_on
end
end
| Ruby |
class CreateDepartments < ActiveRecord::Migration
def self.up
create_table :departments do |t|
t.string :name
t.integer :position
t.timestamps
end
end
def self.down
drop_table :departments
end
end
| Ruby |
class AddSignedOnToProjects < ActiveRecord::Migration
def self.up
add_column :projects, :signed_on, :date
Project.all.each do |project|
project.signed_on = Date.today
project.save(false)
end
end
def self.down
remove_column :projects, :signed_on
end
end
| Ruby |
class CreateStages < ActiveRecord::Migration
def self.up
create_table :stages do |t|
t.integer :project_id
t.string :name
t.date :started_on,
:ended_on
t.string :pay_status, :default => 'paying'
t.text :remark
t.decimal :should_be_payed,
:precision => 8,
... | Ruby |
line_codes = ['A','B','C','D']
#source_feeds = [
# '0','1','2','3','4','5','6','7','8','9',
# 'A','B','C','D','E','F','G','H','I','J','K','L','M',
# 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
#]
password_card = [
['G','U','H','B','2','1'],
['Q','M','Q','G','I','W'],
['T','J','B','N','S',... | 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.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def accessed_by?(args = {})
request.env['HTTP_USER_AGENT'].downcase.index(args[:browser_version])
end
def no_accessed_by?(args = {})
!accessed_by?(args)
end
def loggined?
session[:cur... | Ruby |
module SessionsHelper
end
| Ruby |
module ProjectsHelper
end
| Ruby |
module FetionsHelper
def fetion_verify_image_tag(fetion_verify_image,args = {})
args[:title] ||= '飞信验证码'
args[:alt] ||= args[:title]
image_tag "#{ Rails.env.production? ? "http://#{request.subdomains.join('.')}#{request.subdomains.any? ? '.':''}#{request.domain}" : "http://localhost:9000" }/public/images... | Ruby |
module DesignersHelper
def grouped_by_department(designers)
groups = {}
designers.each do |designer|
groups[designer.department] ||= []
groups[designer.department] << designer
end
groups
end
end
| Ruby |
module Projects::Index::WorkItemsHelper
# 刷新阶段下面的工作项
def remote_function_to_reload_work_items_in_stage_index(args = {})
remote_function :update => "stage_#{args[:stage_id]}_type_#{args[:work_item_type_id]}_work_items",
:url => work_items_url(args),
:method => :get
end
def rmb(_rmb)
number_... | Ruby |
module Projects::Index::WorkItemTypes::DesignerWorkItemsHelper
end
| Ruby |
module Projects::Index::DesignerWorkItemsHelper
end
| Ruby |
module Projects::Index::StagesHelper
# 刷新阶段
def remote_function_to_reload_stage_in_project_index(stage)
remote_function :update => "stage_info_#{stage.id}",
:url => stage_url(stage),
:method => :get
end
# 刷新阶段s
def remote_function_to_reload_project_stages_in_project_index(project, options = {... | Ruby |
module Projects::Index::ProjectsHelper
# 刷新项目
def remote_function_to_reload_project_in_project_index(project)
remote_function :update => "project_info_#{project.id}",
:url => title_project_url(project),
:method => :get
end
# 刷新项目统计
def remote_function_to_reload_project_stat_in_project_index
... | Ruby |
module Projects::Index::WorkItemTypeStagesHelper
# 刷新阶段-工作项分类
def remote_function_to_reload_stage_work_item_types_in_project_index(stage)
remote_function :update => "stage_#{stage.id}_work_item_types",
:url => work_item_type_stages_url(:id => stage.id),
:method => :get
end
end
| Ruby |
module AutoComplete::ProjectsHelper
end
| Ruby |
module AutoComplete::DesignersHelper
end
| Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
module LoaderHelper
def short_loader(div_id,html_options = {})
html_options.merge!(
:height => "' + $(\"#{html_options[:height_from]}\").getHeight() + '"
) if html_options[:height_from]
html_options.merge!(
... | Ruby |
class Department < ActiveRecord::Base
has_many :designers
validates_presence_of :name
validates_uniqueness_of :name
def paying_total_amount
DesignerWorkItem.sum :should_be_payed,
:conditions => [
'designers.department_id = ? and stages.pay_status = ? ',
id,
'paying'
],... | Ruby |
class DesignerWorkItem < ActiveRecord::Base
belongs_to :work_item
belongs_to :designer
belongs_to :stage
belongs_to :work_item_type
validates_presence_of :work_item_id,
:designer_id,
:billing_area,
:work_load,
:guided_percent,
:provided_percent,
:difficulty_num,
:should_be_payed
... | Ruby |
class Designer < ActiveRecord::Base
belongs_to :department
has_many :designer_work_items, :dependent => :destroy
validates_presence_of :full_name
validates_uniqueness_of :full_name
def exist?(args = {})
args[:designer_id] = id
DesignerWorkItem.exists? [
'stage_id = :stage_id and work_item_t... | Ruby |
class WorkItem < ActiveRecord::Base
belongs_to :work_item_type
belongs_to :stage
has_many :designer_work_items, :dependent => :destroy
validates_presence_of :name,
:work_item_type_id,
:stage_id
validates_uniqueness_of :name,
:scope => [:work_item_type_id, :stage_id]
validates_numericality_of... | Ruby |
class Stage < ActiveRecord::Base
belongs_to :project
has_and_belongs_to_many :work_item_types
has_many :designer_work_items, :dependent => :destroy
has_many :work_items, :dependent => :destroy
validates_presence_of :project_id,
:name,
:started_on,
:ended_on
validates_presence_of :payed_on,
... | Ruby |
class Project < ActiveRecord::Base
has_many :stages,:dependent => :destroy
validates_uniqueness_of :name
validates_presence_of :name
validates_presence_of :signed_on
default_scope :order => 'projects.updated_at desc'
def paying_stages
Stage.find_all_by_pay_status_and_project_id('paying',id)
end
... | Ruby |
require 'base64'
class LiteFetion < ActiveResource::Base
self.site = Rails.env.production? ? "http://localhost:4848" : "http://localhost:9000"
end | Ruby |
class WorkItemType < ActiveRecord::Base
has_and_belongs_to_many :stages
has_many :designer_work_items
validates_presence_of :name
validates_uniqueness_of :name
def designer_work_items_by_stage_id(stage_id)
DesignerWorkItem.find_all_by_stage_id_and_work_item_type_id(stage_id,id)
end
end
| Ruby |
class StagesController < ApplicationController
def index
@project = Project.find(params[:project_id])
end
def show
@stage = Stage.find(params[:id])
end
def new
@stage = Stage.new(:project_id => params[:project_id])
end
def create
@stage = Stage.new(params[:stage])
render :new ... | 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 ProjectsController < ApplicationController
layout 'base.html', :only => :index
def index
respond_to do |format|
format.html do
params[:pay_status] = 'paying'
projects_by_pay_status
end
format.js do
case
when params[:pay_status].present?
projects... | Ruby |
class WorkItemsController < ApplicationController
def index
@stage = Stage.find(params[:stage_id])
@type = WorkItemType.find(params[:work_item_type_id])
end
def new
@stage = Stage.find(params[:stage_id])
@type = WorkItemType.find(params[:work_item_type_id])
@work_item = WorkItem.new(
:... | Ruby |
class DesignerWorkItemsController < ApplicationController
def index
@stage = Stage.find(params[:stage_id])
@type = WorkItemType.find(params[:work_item_type_id])
@designer = Designer.find(params[:designer_id])
end
def new
@stage = Stage.find(params[:stage_id])
@type = WorkItemType.find(para... | Ruby |
class WorkItemTypeStagesController < ApplicationController
def index
@stage = Stage.find(params[:id])
end
def new
@stage = Stage.find(params[:stage_id])
end
def create
@stage = Stage.find(params[:stage_id])
@work_item_type = WorkItemType.find(params[:work_item_type_id])
@stage.work_it... | Ruby |
class DesignersController < ApplicationController
layout 'base.html', :only => [:index, :show]
def index
respond_to do |format|
format.html do
@designers = Designer.all
@html_title ="全体-设计师"
end
format.js do
case
when params[:department_id]
@designers... | Ruby |
class AutoComplete::ProjectsController < ApplicationController
def index
@projects = Project.all :conditions => [
'name like ? ',
"%#{params[:project_name]}%"
]
end
end
| Ruby |
class AutoComplete::DesignersController < ApplicationController
def index
@designers = Designer.all :conditions => [
'full_name like ?',
"%#{params[:designer_name]}%"
]
end
end
| Ruby |
require 'base64'
class SessionsController < ApplicationController
layout 'base.html'
before_filter :authorize, :except => [:new,:create]
PASSWORD_CARD = [
['G','U','H','B','2','1'],
['Q','M','Q','G','I','W'],
['T','J','B','N','S','9'],
['K','5','8','X','T','0']
]
LINE_CODES = ['A','B','C',... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.