code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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__) Todo::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 'coderay' gem 'htmlentities' gem 'coderay_bash' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sa...
Ruby
module ApplicationHelper def logged_in? !@current_user.blank? end def flash_messages if flash[:error] fl = flash[:error] flash[:error] = nil elsif flash[:notice] fl = flash[:notice] flash[:notice] = nil end fl end def hdatetime(date) return if date.blank? date.strftime("%Y.%m.%d %H:%M...
Ruby
module NotesHelper end
Ruby
module UsersHelper end
Ruby
module TasksHelper end
Ruby
module MainHelper end
Ruby
module CommentsHelper end
Ruby
#encoding: UTF-8 class Asset < ActiveRecord::Base attr_accessible :attachment, :attachment_filename, :attachment_content_type, :attachment_file_size, :task_id belongs_to :task validates_presence_of :attachment_content_type, :message => "첨부할 파일을 등록해 주세요" has_attached_file :attachment, :path => ":rails_r...
Ruby
class Note < ActiveRecord::Base # attr_accessible :title, :body end
Ruby
#encoding: UTF-8 class Comment < ActiveRecord::Base attr_accessible :commentable_id, :commentable_type, :content, :user_id validates_presence_of :content, :messages => "내용을 입력해 주세요" belongs_to :commentable, :polymorphic => true, :counter_cache => :comments_count belongs_to :user def is_owner?(u) u && u.id...
Ruby
class Point < ActiveRecord::Base attr_accessible :user_id, :score belongs_to :user belongs_to :task end
Ruby
#encoding: UTF-8 class User < ActiveRecord::Base validate :user_info_confirmation attr_accessible :login, :name, :password, :password_confirmation attr_accessor :password_confirmation validates_presence_of :login, :message => "로그인 아이디를 입력해주세요", :on => :create validates_uniqueness_of :login, :message...
Ruby
#encoding: UTF-8 class Task < ActiveRecord::Base attr_accessible :owner_id, :worker_id, :user_id, :content, :done, :point, :assets_attributes validates_presence_of :content, :message => "내용을 입력해주세요" has_many :comments, :as => :commentable, :dependent => :destroy has_many :assets, :dependent => :destroy belong...
Ruby
class NotesController < ApplicationController end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery before_filter :set_current_user def set_current_user @current_user ||= login_from_session end def login_from_session begin u = User.find(session[:user_id]) rescue @current_user = nil session[:user_id] = nil #reset_sess...
Ruby
class CommentsController < ApplicationController before_filter :login_required def create @comment = Comment.new(params[:comment].merge(:user_id => @current_user.id)) unless @comment.save flash[:notice] = @comment.errors.full_messages end end def destroy permission_check unless @comment.destroy ...
Ruby
class MainController < ApplicationController def index # 이렇다면 페이징 어떻게 할래? @tasks = { :inbox => Task.inbox.paginate(:per_page => 5, :order =>"id desc", :page => params[:inbox_page]), :focus => Task.focus.paginate(:per_page => 5, :order =>"id asc", :page => params[:focus_page]), :done => Task.complete.pa...
Ruby
#encoding: UTF-8 class TasksController < ApplicationController before_filter :login_required def destroy_asset @task = Task.find(params[:id]) @asset = Asset.find(params[:asset_id]) if @asset.destroy redirect_to task_path(@task) end end def create_assets @task = Task.find(params[:asset][:task_id]) ...
Ruby
#encoding: UTF-8 class UsersController < ApplicationController before_filter :login_required, :only => [:edit, :update] def new @user = User.new end def create @user = User.new(params[:user]) if @user.save @current_user = @user session[:user_id] = @user.id redirect_to root_path else render :...
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
AssetHost="http://127.0.0.1:3000"
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. Todo::Application.config.session_store :cookie_store, key: '_todo_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 generat...
Ruby
Todo::Application.routes.draw do match 'login', :to => "users#login", :via => [ :get ] match 'logout', :to => "users#logout", :via => [ :get ] match 'signin', :to => "users#signin", :via => [ :post ] resources :users resources :tasks do member do post 'take' post 'drop' post 'complete' post 'cre...
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 Todo::Application.initialize!
Ruby
Todo::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_co...
Ruby
Todo::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 serve...
Ruby
Todo::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 suite...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Todo::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__) Todo::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' }]) # Major.create(:name...
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 end
Ruby
module ApiHelper end
Ruby
class Potitem < ActiveRecord::Base ## ## def self.culcPots(list) p = {1=>{'item'=>0,'special'=>0},2=>{'item'=>0,'special'=>0},3=>{'item'=>0,'special'=>0},4=>{'item'=>0,'special'=>0},5=>{'item'=>0,'special'=>0}} list.each(){|pot| genre = pot.potid.to_i p[genre]['item'] += 1 ...
Ruby
# -*- coding: utf-8 -*- # class Rakutenitem < ActiveRecord::Base ##-------------------- def setRakutenItem(itm) self.barcode = itm[:barcode] self.itemname = itm[:itemName] self.itemcode = itm[:itemCode] self.weburl = itm[:webUrl] self.imageurl = itm[:imageUrl] self.genreid = itm[:genreId] self.rootg...
Ruby
# -*- coding: utf-8 -*- # class User < ActiveRecord::Base def getPots() ret = { 1 => {'item_num' => self.p1_item_num, 'special_num' => self.p1_special_num, 'complete_pattern' => self.p1_complete_pattern }, 2 => {'item_num' => self.p2_item_num, 'special_num' => self.p2_special_num, 'complete...
Ruby
# -*- coding: utf-8 -*- # # ## class ApiController < ApplicationController # skip_before_filter :verify_authenticity_token #=== 初期化API # def init rp = Hash.new rp['result'] = {} begin rescue rp['result'] = BKH_STATUS_ERROR logger.error($!.message) logger.error($!.backtrace[0 .. 10].join("\n...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. require 'uri' require 'time' class ApplicationController < ActionController::Base helper :all # include all helpers, all the time protect_from_forgery # See Action...
Ruby
# -*- coding: utf-8 -*- # # ## class WebController < ApplicationController def info #画像情報取得 begin user_id = params[:user_id].to_i raise ParameterException, "User id is invalid : #{user_id}" unless user_id > 0 pot_id = params[:pot_id].to_i raise ParameterException, "Pot id is invalid : #{...
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| # The priority is based upon order of creation: first created -> highest priority. map.connect 'web/:user_id/:pot_id', :controller => 'web', :action => 'info' map.connect 'item/:user_id/:pot_id', :controller => 'web', :action => 'itemlist' map.connect 'about', :co...
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.5' 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
# -*- coding: utf-8 -*- # # ## ## #=== Rakuten item search API wrapper # http://webservice.rakuten.co.jp/api/itemsearch/ # class ItemSearch < RakutenApiBase # #=== search method # def search(keyword) prm = {} prm['keyword'] = keyword prm['developerId'] = @developerId prm['affiliateId'] = @affiliateId ...
Ruby
# -*- coding: utf-8 -*- # # # require 'rubygems' require 'net/http' require 'httpclient' require 'json' require 'rexml/document' require 'pp' # #=== Rakuten API class RakutenApiBase @developerId ='' @affiliateId = '' @restUrl = '' ## # #=== Rakuten API Initialize # def initialize(developerId...
Ruby
# -*- coding: utf-8 -*- # # ## ## #=== Rakuten genre search API wrapper # http://webservice.rakuten.co.jp/api/genresearch/ # class GenreSearch < RakutenApiBase # #=== search method # def searchRootGenre(genreId) prm = {} prm['genreId'] = genreId prm['developerId'] = @developerId prm['affiliateId'] =...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
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 CreateStockLoggings < ActiveRecord::Migration def change create_table :stock_loggings do |t| t.integer :drug_id t.integer :stock_id t.integer :inventory_id t.float :quantity t.integer :stock_logging_category_id t.integer :created_by t.integer :updated_by t.ti...
Ruby
class DrugsManufacturers < ActiveRecord::Migration def change create_table :drugs_manufacturers, :id => false do |t| t.integer :drug_id t.integer :manufacturer_id end end end
Ruby
class CreateAppointments < ActiveRecord::Migration def change create_table :appointments do |t| t.integer :patient_id t.integer :staff_id t.date :date_appointment t.time :time_appointment t.integer :appointment_status_id t.integer :registration_method_id t.integer :create...
Ruby
class CreateTreatmentGroups < ActiveRecord::Migration def change create_table :treatment_groups do |t| t.string :label t.integer :created_by t.integer :updated_by t.timestamps end end end
Ruby
class CreateStaffs < ActiveRecord::Migration def change create_table :staffs do |t| t.integer :staff_role_id t.string :first_name t.string :last_name t.date :dob t.boolean :active t.integer :created_by t.integer :updated_by t.timestamps end end end
Ruby
class DrugsStocks < ActiveRecord::Migration def change create_table :drugs_stocks, :id => false do |t| t.integer :drug_id t.integer :stock_id end end end
Ruby
class CreatePaymentMethods < ActiveRecord::Migration def change create_table :payment_methods do |t| t.string :label t.integer :created_by t.integer :updated_by t.timestamps end end end
Ruby
class CreateInvoiceDetails < ActiveRecord::Migration def change create_table :invoice_details do |t| t.integer :invoice_id t.integer :invoice_item_id t.integer :invoice_item_type_id t.float :fee t.float :discount t.integer :created_by t.integer :updated_by t.timest...
Ruby
class DrugsStockPrescriptions < ActiveRecord::Migration def change create_table :drugs_prescriptions, :id => false do |t| t.integer :drug_id t.integer :prescription_id end end end
Ruby
class CreateTreatments < ActiveRecord::Migration def change create_table :treatments do |t| t.string :label t.string :detail t.integer :appointment_id t.integer :treatment_group_id t.float :fee t.integer :created_by t.integer :updated_by t.timestamps end end ...
Ruby
class CreateInventories < ActiveRecord::Migration def change create_table :inventories do |t| t.string :name t.text :description t.integer :created_by t.integer :updated_by t.timestamps end end end
Ruby
class CreateAppointmentStatuses < ActiveRecord::Migration def change create_table :appointment_statuses do |t| t.string :label t.integer :created_by t.integer :updated_by t.timestamps end end end
Ruby
class CreatePrescriptions < ActiveRecord::Migration def change create_table :prescriptions do |t| t.integer :drug_id t.integer :appointment_id t.integer :stock_logging_id t.string :dosage t.float :quantity t.float :fee t.text :note t.integer :created_by t.inte...
Ruby
class CreateSuppliers < ActiveRecord::Migration def change create_table :suppliers do |t| t.string :name t.string :code t.string :website t.text :address t.string :email t.string :phone t.string :fax t.integer :created_by t.integer :updated_by t.timesta...
Ruby
class CreateDrugs < ActiveRecord::Migration def change create_table :drugs do |t| t.integer :manufacture_id t.string :code t.string :name t.float :price_per_item t.text :description t.integer :created_by t.integer :updated_by t.timestamps end end end
Ruby
class CreateInvoiceItemTypes < ActiveRecord::Migration def change create_table :invoice_item_types do |t| t.string :label t.integer :created_by t.integer :updated_by t.timestamps end end end
Ruby
class AppointmentsDiagnoses < ActiveRecord::Migration def change create_table :appointments_diagnoses, :id => false do |t| t.integer :appointment_id t.integer :diagnosis_id end end end
Ruby