code
stringlengths
1
1.73M
language
stringclasses
1 value
module DepositBooksHelper end
Ruby
module UsersHelper end
Ruby
module SessionsHelper end
Ruby
module HomeHelper end
Ruby
module BookTypesHelper end
Ruby
module UserTypesHelper end
Ruby
class BookType < ActiveRecord::Base has_many :deposit_books end
Ruby
class DepositBook < ActiveRecord::Base belongs_to :user belongs_to :book_type validates :book_number, :user_id, :deposit_amount, :deposit_start_date, :deposit_end_date, :interest_amount, :book_type_id, presence: true end
Ruby
class User < ActiveRecord::Base has_secure_password has_many :deposit_books belongs_to :user_type validates :fullname, :username, :pin_code, :address, :date_of_birth, :phone, :pasport_number, :user_type_id, presence: true mount_uploader :picture, ImageUploader mount_uploader :pasport_scan, ImageUploader ...
Ruby
class UserType < ActiveRecord::Base has_many :users end
Ruby
class HomeController < ApplicationController before_filter :authenticate def index end def admin if current_user.user_type_id != 1 redirect_to root_path, alert: "You must be Admin to access this page !" end end end
Ruby
class UserTypesController < ApplicationController before_filter :authenticate, :authenticate_admin before_action :set_user_type, only: [:show, :edit, :update, :destroy] # GET /user_types # GET /user_types.json def index @user_types = UserType.all end # GET /user_types/1 # GET /user_types/1.json ...
Ruby
class SessionsController < ApplicationController layout "layouts/authentication" def new end def create user = User.find_by_username(params[:username]) pin = User.find_by_pin_code(params[:pin_code]) if user && user.authenticate(params[:password]) && pin session[:user_id] = user.id if u...
Ruby
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception private def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end d...
Ruby
class DepositBooksController < ApplicationController before_action :set_deposit_book, only: [:show, :edit, :update, :destroy] # GET /deposit_books # GET /deposit_books.json def index if (current_user.user_type_id == 2) or (current_user.user_type_id == 1 and params[:my]) @deposit_books = DepositBook.w...
Ruby
class BookTypesController < ApplicationController before_filter :authenticate, :authenticate_admin before_action :set_book_type, only: [:show, :edit, :update, :destroy] # GET /book_types # GET /book_types.json def index @book_types = BookType.all end # GET /book_types/1 # GET /book_types/1.json ...
Ruby
class UsersController < ApplicationController before_filter :authenticate, :authenticate_admin skip_before_filter :authenticate_admin, only: [:show, :edit, :update] before_action :set_user, only: [:show, :edit, :update, :destroy] # GET /users # GET /users.json def index @users = User.search(params[:se...
Ruby
# encoding: utf-8 class ImageUploader < CarrierWave::Uploader::Base # Include RMagick or MiniMagick support: # include CarrierWave::RMagick # include CarrierWave::MiniMagick # Choose what kind of storage to use for this uploader: storage :file # storage :fog # Override the directory where uploaded fil...
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__) Rails.application.load_tasks
Ruby
source 'http://rubygems.org' gem 'rails', '4.1.1' gem 'sass-rails', '~> 4.0.3' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc gem 'bcrypt', '~> 3.1.7' # gem 'therubyracer', platforms: :ruby # gem 'u...
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :fullname t.string :username t.string :email t.string :password_digest t.string :pin_code t.string :address t.timestamp :date_of_birth t.string :phone t.string :picture ...
Ruby
class CreateUserTypes < ActiveRecord::Migration def change create_table :user_types do |t| t.string :type_name t.timestamps end end end
Ruby
class CreateDepositBooks < ActiveRecord::Migration def change create_table :deposit_books do |t| t.string :book_number t.integer :user_id t.integer :deposit_amount t.timestamp :deposit_start_date t.timestamp :deposit_end_date t.integer :interest_amount t.integer :book_typ...
Ruby
class CreateBookTypes < ActiveRecord::Migration def change create_table :book_types do |t| t.string :type_name t.timestamps end 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 Rails.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 for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integration t...
Ruby
# Simple Jobs # =========== require 'java' java_import Java::MyscheduleQuartzExtraJob::LoggerJob java_import Java::MyscheduleQuartzExtraJob::ScriptingJob java_import Java::MyscheduleQuartzExtra::SchedulerTemplate java_import Java::JavaUtil::Date java_import Java::JavaLang::System # Schedule hourly job scheduler.schedu...
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
# 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
module ActiveRecord # Active Records will automatically record the user who created and/or updated a database objects # if fields of the names created_by/created_by are present. # # This module requires that your user object (which by default is <tt>User</tt> but can be changed # using the <tt>user_model...
Ruby
# add to the first line of each testcase: require File.dirname(__FILE__) + "/test_helper" def __DIR__(*args); File.join(File.dirname(__FILE__), *args); end RAILS_ROOT = __DIR__('../../../..') $:.unshift(__DIR__('/../lib')) # begin # require 'rubygems' # rescue LoadError $:.unshift(__DIR__('/../../../ra...
Ruby
# Install hook code here unless File.exist?(File.dirname(__FILE__) + "/../userstamp") Commands::Plugin.parse!(['install', 'http://delynnberry.com/svn/code/rails/plugins/userstamp/']) end
Ruby
require File.join(File.dirname(__FILE__), '../userstamp/lib/userstamp') require 'acts_as_userstamp'
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_userstamp plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the acts_as_user...
Ruby
require RAILS_ROOT + '/vendor/plugins/userstamp/lib/userstamp' module ActiveRecord class Base @@user_model = nil cattr_accessor :user_model def self.user_model @@user_model ||= Object.const_get(self.user_model_class_name) @@user_model end def self.user_model_...
Ruby
# add to the first line of each testcase: require File.dirname(__FILE__) + "/test_helper" def __DIR__(*args); File.join(File.dirname(__FILE__), *args); end RAILS_ROOT = __DIR__('../../../..') $:.unshift(__DIR__('/../lib')) # begin # require 'rubygems' # rescue LoadError $:.unshift(__DIR__('/../../../ra...
Ruby
# Install hook code here
Ruby
# Include hook code here require File.join(File.dirname(__FILE__), 'lib/text_options') require File.join(File.dirname(__FILE__), 'lib/ar_finder')
Ruby
# Uninstall hook code here
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the ar_finder plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the ar_finder plugin.' R...
Ruby
class TextOptions class Entry attr_accessor :index, :text, :value def initialize(index, text, value) @index = index @text = text @value = value end def to_array(*args) args ||= [:text, :index] args = [:text, :index] if args.empty? args.collect{|...
Ruby
class ArFinder DEFAULT_OPTIONS = {:delimeter => ' ', :strip => true} def initialize(options = nil) @options = {}.merge(options||{}) apply_options(@options) end def apply_options(options) return unless options options.each_pair{|k, v| send("#{k.to_s}=", v) if respond_to?("#{k.to...
Ruby
$KCODE="u" # add to the first line of each testcase: require File.dirname(__FILE__) + "/test_helper" def __DIR__(*args); File.join(File.dirname(__FILE__), *args); end RAILS_ROOT = __DIR__('../../../..') $:.unshift(__DIR__('/../lib')) # begin # require 'rubygems' # rescue LoadError $:.unshift(__DIR__...
Ruby
require 'select'
Ruby
# copyright akima class Select module Helper def self.empty?( s ) return true unless s return s.empty? if s.respond_to? "empty?" return false end def self.build_or_to_s( obj, params ) return obj.respond_to?(:build) ? obj.build(params) : obj.to_s end end attr_accessor...
Ruby
$KCODE="u" # add to the first line of each testcase: require File.dirname(__FILE__) + "/test_helper" def __DIR__(*args); File.join(File.dirname(__FILE__), *args); end RAILS_ROOT = __DIR__('../../../..') $:.unshift(__DIR__('/../lib')) # begin # require 'rubygems' # rescue LoadError $:.unshift(__DIR__...
Ruby
# Install hook code here
Ruby
require 'validates_jp_char'
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the validates_char plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the validates_char ...
Ruby
module JpChar class Type def self.instance return @@instances end KAKU_NAMES = { :hankaku => "半角", :zenkaku => "全角" } TYPE_NAMES = { :alphabet => "アルファベット", :numeric => "数字", :sign => "記号", :kanasign => "かな記号", :hiragana => "ひらがな", :katak...
Ruby
ActiveRecord::Errors.default_error_messages = { :accept_char => "accepts only %s", :deny_char => "denies %s" }.update(ActiveRecord::Errors.default_error_messages) require 'jp_char' ActiveRecord::Base.class_eval do # Validates String attribute of character type in Japanese. # # validates_char ...
Ruby
class CreateBookTitles < ActiveRecord::Migration def self.up create_table :book_titles do |t| t.column :title, :string, :limit => 255, :null => false t.column :authors, :string, :limit => 255, :null => false t.column :publisher, :string, :limit => 255, :null => false t.column :isbn, :strin...
Ruby
class CreateSpecLinks < ActiveRecord::Migration def self.up create_table :spec_links do |t| t.column :url, :string, :limit => 255, :null => false t.column :descriptions, :text t.column :external_url, :text end end def self.down drop_table :spec_links end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::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 datab...
Ruby
#!C:/dev/ruby.org/ruby/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 performance is seve...
Ruby
#!C:/dev/ruby.org/ruby/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/log/fastcg...
Ruby
#!C:/dev/ruby.org/ruby/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 performance is seve...
Ruby
#!C:/dev/ruby.org/ruby/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 performance is seve...
Ruby
#!C:/dev/ruby.org/ruby/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/log/fastcg...
Ruby
#!C:/dev/ruby.org/ruby/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 performance is seve...
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
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/about'
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/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/destroy'
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/breakpointer'
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/about'
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/console'
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/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
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/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/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module BookTitleHelper end
Ruby
module SpecLinkHelper end
Ruby
class BookTitle < ActiveRecord::Base end
Ruby
class SpecLink < ActiveRecord::Base end
Ruby
class BookTitleController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @boo...
Ruby
class SpecLinkController < ApplicationController def ajax_list @spec_links = SpecLink.find(:all) end def ajax_new end def ajax_save if params[:id] @spec_link = SpecLink.find(params[:id]) @spec_link.attributes = params[:spec_link] else @spec_link = SpecLink.new(params[:spec_...
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 # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_spec_linke...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION ...
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 # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
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