code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class Model < ActiveRecord::Base
has_many :permission
#@@permission_code = 6
#def self.permission_code
# return @@permission_code
#end
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Code:#{code}"+","+"Name:#{name}"
end
def to_combo
return [self.name,self.name]
end
end
| Ruby |
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
# can :manage, :all
# else
# can :read, :all
# end
#
# The first argumen... | Ruby |
class Entry < ActiveRecord::Base
end
| Ruby |
class UserSession < Authlogic::Session::Base
logout_on_timeout true
consecutive_failed_logins_limit 3
failed_login_ban_for 0
end | Ruby |
class Group < ActiveRecord::Base
has_many :user
has_many :authentication
has_many :permissions , :through => :authentication
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :description , :maximum =>128
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"... | Ruby |
class Card < ActiveRecord::Base
has_many :customer
cattr_reader :per_page
validates_presence_of :name
validates_uniqueness_of :name
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Name:#{name}"
end
end
| Ruby |
class Occupation < ActiveRecord::Base
has_many :customer
cattr_reader :per_page
@@per_page = 5
validates_presence_of :name
validates_uniqueness_of :name
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Name:#{name}"
end
end
| Ruby |
class Province < ActiveRecord::Base
has_many :customers
validates_presence_of :name
validates_uniqueness_of :name
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Name:#{name}"
end
end
| Ruby |
class Nationality < ActiveRecord::Base
has_many :customer
cattr_reader :per_page
validates_presence_of :name
validates_uniqueness_of :name
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Name:#{name}"
end
end
| Ruby |
class Customer < ActiveRecord::Base
after_create :generate_customer_no
belongs_to :card
belongs_to :title
belongs_to :nationality
belongs_to :province , :class_name => "issue_province"
belongs_to :occupation
belongs_to :branch
has_many :agreements
has_attached_file :image, :styles => { :mediu... | Ruby |
class HelpController < ApplicationController
before_filter :require_user
def index
end
end
| Ruby |
class AdministratorController < ApplicationController
before_filter :require_user
def index
end
end
| Ruby |
class OccupationsController < ApplicationController
before_filter :require_user
# GET /occupations
# GET /occupations.xml
def index
authorize! :read, Occupation
#@occupations = Occupation.all
@search = Occupation.search(params[:search])
@occupations = @search.paginate(:per_page => 5 , :pag... | Ruby |
class ReportController < ApplicationController
helper :send_doc
include SendDocHelper
#before_filter :require_user
def index
@bar = open_flash_chart_object(600,300, url_for(:action=>'graph_bar'))
@pie = open_flash_chart_object(600,300, url_for(:action=>'graph_pie'))
@axis = open_flash_chart_obje... | Ruby |
class AuthenticationsController < ApplicationController
before_filter :require_user
# GET /authentications
# GET /authentications.xml
def index
#@authentications = Authentication.all
@search = Authentication.search(params[:search])
@search.meta_sort ||= 'group_id.asc'
@search.meta_sor... | Ruby |
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
end
def create
entry = Entry.new
begin
@user_session = UserSession.new(params[:user_session])... | Ruby |
class GroupsController < ApplicationController
before_filter :require_user
# GET /groups
# GET /groups.xml
def index
authorize! :read, Group
#@groups = Group.all
@search = Group.search(params[:search])
@groups = @search.paginate(:per_page => 5,:page => params[:page])
respond_to do |f... | Ruby |
class BranchesController < ApplicationController
before_filter :require_user
# GET /branches
# GET /branches.xml
def index
authorize! :read, Branch
#@branches = Branch.all
@search = Branch.search(params[:search])
@search.meta_sort ||= 'code.asc'
@branches = @search.paginate(:per_page =... | Ruby |
class PermissionsController < ApplicationController
before_filter :require_user
# GET /permissions
# GET /permissions.xml
def index
#@permissions = Permission.all
@search = Permission.search(params[:search])
@search.meta_sort ||= 'code.asc'
@permissions = @search.paginate(:per_page =>... | Ruby |
class AuditsController < ApplicationController
before_filter :require_user
# GET /audits
# GET /audits.json
def index
#@audits = Audit.all
authorize! :read, Audit
@search = Audit.search(params[:search])
@search.meta_sort ||= 'created_at.desc'
@audits = @search.paginate(:per_page => 10 ... | Ruby |
class SettingController < ApplicationController
before_filter :require_user
def index
end
end
| Ruby |
require 'rubygems'
require 'rufus/scheduler'
class MainController < ApplicationController
before_filter :require_user
def index
#PDFKit.new('http://google.co.th').to_file('output.pdf')
end
def job
scheduler = Rufus::Scheduler.start_new
scheduler.cron '0 22 * * 1-5' do
# every day of the week ... | Ruby |
class CustomersController < ApplicationController
before_filter :require_user
# GET /customers
# GET /customers.xml
def index
authorize! :read, Customer
@search = Customer.search(params[:search])
@search.meta_sort ||= 'code.asc'
@customers = @search.paginate(:per_page => 5 , :page => params[:pag... | Ruby |
class ApplicationController < ActionController::Base
before_filter :set_locale
protect_from_forgery
helper :all
helper_method :current_user_session, :current_user
#filter_parameter_logging :password, :password_confirmation
rescue_from CanCan::AccessDenied do |exception|
redirect_to '/403.html', :al... | Ruby |
class NationalitiesController < ApplicationController
before_filter :require_user
# GET /nationalities
# GET /nationalities.xml
def index
#@nationalities = Nationality.all
#@nationalities = Nationality.paginate :page => params[:page]
@search = Nationality.search(params[:search])
@nationa... | Ruby |
class AgreementsController < ApplicationController
before_filter :require_user
# GET /agreements
# GET /agreements.json
def index
authorize! :read, Agreement
# @agreements = Agreement.all
@search = Agreement.search(params[:search])
@agreements = @search.paginate(:per_page => 5,:page => par... | Ruby |
class CardsController < ApplicationController
before_filter :require_user
# GET /cards
# GET /cards.xml
def index
authorize! :read, Card
#@cards = Card.all
#@cards = Card.paginate :page => params[:page]
@search = Card.search(params[:search])
@cards = @search.paginate(:per_page => 5,:page =>... | Ruby |
class ::TitlesController < ApplicationController
before_filter :require_user
# GET /titles
# GET /titles.xml
def index
authorize! :read, ::Title
#@titles = ::Title.all
#@titles = ::Title.paginate :page => params[:page]
@search = ::Title.search(params[:search])
@titles = @search.paginate(:per... | Ruby |
class EntriesController < ApplicationController
before_filter :require_user
# GET /entries
# GET /entries.json
def index
authorize! :read, Entry
#@entries = Entry.all
@search = Entry.search(params[:search])
@search.meta_sort ||= 'created_at.desc'
@entries = @search.paginate(:per_page =... | Ruby |
class ProvincesController < ApplicationController
before_filter :require_user
# GET /provinces
# GET /provinces.xml
def index
authorize! :read, Province
#@provinces = Province.all
@search = Province.search(params[:search])
@provinces = @search.paginate(:per_page => 5,:page => params[:page]... | Ruby |
class UsersController < ApplicationController
# before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user
# GET /users
# GET /users.xml
def index
authorize! :read, User
@search = User.search(params[:search])
@search.meta_sort ||= 'id.asc'
@users = @search.paginate(... | Ruby |
class ModelsController < ApplicationController
before_filter :require_user
# GET /models
# GET /models.xml
def index
authorize! :read , Model
@search = Model.search(params[:search])
@models = @search.paginate(:per_page => 10 ,:page => params[:page])
respond_to do |format|
format... | 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'
require 'rake/dsl_definition'
include Rake::DSL
MyRental::Application.load_tasks
| Ruby |
source "http://rubygems.org"
gem "rails","~> 3.1.1"
# for fast instll gem: --no-ri --no-rdoc
# Bundle edge Rails instead:
# gem "rails", :git => "git://github.com/rails/rails.git"
# Use unicorn as the web server
#gem "unicorn", "~> 4.1.1"
gem "thin", "~> 1.3.1"
gem "eventmachine", "~> 1.0.0.beta.4.1"
#gem "puma"... | Ruby |
class AddBranchToCustomer < ActiveRecord::Migration
def self.up
add_column :customers , :branch_id ,:integer
end
def self.down
remove_column :customers , :branch_id
end
end
| Ruby |
class CreateAudits < ActiveRecord::Migration
def change
create_table :audits do |t|
t.string :model
t.string :action
t.string :before
t.string :after
t.timestamps
end
end
end
| Ruby |
class AddModelIdToPermission < ActiveRecord::Migration
def self.up
add_column :permissions , :model_id ,:integer
remove_column :permissions , :model
end
def self.down
add_column :permissions , :model ,:string
remove_column :permissions , :model_id
end
end
| Ruby |
class AddImageToCustomers < ActiveRecord::Migration
def self.up
add_column :customers, :image_file_name, :string
add_column :customers, :image_content_type, :string
add_column :customers, :image_file_size, :integer
add_column :customers, :image_updated_at, :datetime
end
def self.down
... | Ruby |
class AddLanguageToUser < ActiveRecord::Migration
def change
add_column :users, :language, :string
end
end
| Ruby |
class AddCardTitleCustomers < ActiveRecord::Migration
def self.up
#add_column :customers,:marr_status,:string
end
def self.down
#remove_column :customers,:marr_status
end
end
| Ruby |
class CreatePermissions < ActiveRecord::Migration
def self.up
create_table :permissions do |t|
t.string :name
t.string :description
t.timestamps
end
end
def self.down
drop_table :permissions
end
end
| Ruby |
class AddUserAudit < ActiveRecord::Migration
def up
add_column :audits , :user , :string
end
def down
remove_column :audits , :user
end
end
| Ruby |
class AddBranchToUser < ActiveRecord::Migration
def self.up
add_column :users , :branch_id ,:integer
end
def self.down
remove_column :users , :branch_id
end
end
| Ruby |
class CreateGroups < ActiveRecord::Migration
def self.up
create_table :groups do |t|
t.string :name
t.string :description
t.timestamps
end
end
def self.down
drop_table :groups
end
end
| Ruby |
class AddGroupToUser < ActiveRecord::Migration
def self.up
add_column :users , :group_id ,:integer
end
def self.down
remove_column :users , :group_id
end
end
| Ruby |
class CreateBranches < ActiveRecord::Migration
def self.up
create_table :branches do |t|
t.string :code
t.string :name
t.timestamps
end
end
def self.down
drop_table :branches
end
end
| Ruby |
class AddFlagToAuthentication < ActiveRecord::Migration
def self.up
add_column :authentications , :enable ,:boolean
end
def self.down
remove_column :authentications , :enable
end
end
| Ruby |
class CreateAgreements < ActiveRecord::Migration
def change
create_table :agreements do |t|
t.string :agreement_no
t.integer :customer_id
t.timestamps
end
end
end
| Ruby |
class CreateCustomers < ActiveRecord::Migration
def self.up
create_table :customers do |t|
t.string :code
t.integer :title_id
t.string :first_name
t.string :last_name
t.date :birth_date
t.string :nick_name
t.integer :nationality_id
t.string :marr_status
t.inte... | Ruby |
class CreateAuthentications < ActiveRecord::Migration
def self.up
create_table :authentications do |t|
t.integer :group_id
t.integer :permission_id
t.timestamps
end
end
def self.down
drop_table :authentications
end
end
| Ruby |
class AddAgentAgreement < ActiveRecord::Migration
def up
add_column :agreements , :user_id ,:integer
end
def down
remove_column :agreements , :user_id
end
end
| Ruby |
class CreateOccupations < ActiveRecord::Migration
def self.up
create_table :occupations do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :occupations
end
end
| Ruby |
class CreateCards < ActiveRecord::Migration
def self.up
create_table :cards do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :cards
end
end
| Ruby |
class AddModelToPermission < ActiveRecord::Migration
def self.up
add_column :permissions , :model ,:string
end
def self.down
remove_column :permissions , :model
end
end
| Ruby |
class AddCreateReadUpdateDestroyAuthentication < ActiveRecord::Migration
def self.up
remove_column :authentications , :enable
add_column :authentications , :can_create ,:boolean
add_column :authentications , :can_read ,:boolean
add_column :authentications , :can_update ,:boolean
add_column :authen... | Ruby |
class CreateModels < ActiveRecord::Migration
def self.up
create_table :models do |t|
t.string :name
t.string :code
t.timestamps
end
end
def self.down
drop_table :models
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :login, :null => false # optional, you can use email instead, or both
# t.string :email, :null => false # optional, you can use login instead, or ... | Ruby |
class CreateProvinces < ActiveRecord::Migration
def self.up
create_table :provinces do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :provinces
end
end
| Ruby |
class CreateTitles < ActiveRecord::Migration
def self.up
create_table :titles do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :titles
end
end
| Ruby |
class CreateNationalities < ActiveRecord::Migration
def self.up
create_table :nationalities do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :nationalities
end
end
| Ruby |
class AddCardIdToCustomer < ActiveRecord::Migration
def self.up
remove_column :customers , :card_type
add_column :customers , :card_id ,:integer
end
def self.down
add_column :customers , :card_type ,:integer
remove_column :customers , :card_id
end
end
| Ruby |
class CreateEntries < ActiveRecord::Migration
def change
create_table :entries do |t|
t.string :login
t.string :action
t.string :result
t.string :ip
t.timestamps
end
end
end
| Ruby |
class AddMainPropertiesToCustomers < ActiveRecord::Migration
def self.up
add_column :customers, :issue_by,:string
add_column :customers, :issue_province,:integer
add_column :customers, :issue_date,:date
add_column :customers, :issue_expire,:date
add_column :customers, :register_address,:string
... | Ruby |
class AddCodeToPermission < ActiveRecord::Migration
def self.up
add_column :permissions , :code ,:string
end
def self.down
remove_column :permissions , :code
end
end
| Ruby |
# encoding: utf-8
# 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' }])
# Ma... | Ruby |
require 'active_support'
# Logger class for custom logging format
class CustomLogger < ActiveSupport::BufferedLogger
private
# CustomLogger doesn't define strings for log levels
# so we have to do it ourselves
def severity_string(level)
case level
when DEBUG
:DEBUG
w... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run MyRental::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 |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | 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 |
# 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.
ActiveRecord::Base.include_root_in_json = true
# Store the full clas... | 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 |
set :application, "Aperture"
set :deploy_to "/home/inf/klopacin/www/#{application}"
set :repository, "git://inf.univ.gda.pl/~klopacin/aperture.git"
set :scm, :git
set :branch, "master"
set :deploy_via, :export
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can ... | 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 |
# 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
# 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 = '2.1... | 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 :comments
map.resources :users
map.resources :pictures, :has_many => :comments
#map.resources :comments
map.root :controller => 'site', :action => 'index'
# The priority is based upon order of creation: first created -> highest priority.
#... | Ruby |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy'
load 'config/deploy'
load 'lib/cap_recipes'
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module SiteHelper
def picture_table(pictures, options={:per_row => 5, :generate_remote_calls => true})
per_row = options[:per_row]
generate_remote_calls = options[:generate_remote_calls]
lst = Array.new
lst[0] = '<table class="picture_list">'
current_column = 0
pictures.each do |picture|
... | Ruby |
module UsersHelper
end
| Ruby |
module PictureHelper
end
| Ruby |
module CommentsHelper
end
| Ruby |
require 'digest/sha2'
class User < ActiveRecord::Base
validates_presence_of :username, :email
validates_uniqueness_of :username, :message => "Login nie jest unikalny!"
#validates_uniqueness_of :full_name
validates_uniqueness_of :email, :message => "Email nie jest unikalny!"
attr_accessor :password_confirmation
... | Ruby |
class Comment < ActiveRecord::Base
belongs_to :picture
belongs_to :user
validates_presence_of :body, :picture, :user
validates_uniqueness_of :body, :scope => [:picture_id, :user_id]
end
| Ruby |
class Vote < ActiveRecord::Base
belongs_to :picture
belongs_to :user
validates_presence_of :user, :picture
end
| Ruby |
require 'mini_magick'
class Picture < ActiveRecord::Base
validates_presence_of :title
after_save :write_file
belongs_to :user
has_many :comments, :order => ":created_at", :dependent => :destroy
has_many :votes, :dependent => :destroy
attr_reader :quantity, :pic
def image=(file_data)
@file_data = file_data... | Ruby |
require 'will_paginate'
class SiteController < ApplicationController
def index
@newest = Picture.find(:all, {:order => "created_at DESC", :limit => 10})
@baza = Picture.find(:all, {:order => "score DESC", :limit => 100},:conditions => "votes > 0 AND score >0")
@best=Array.new
@value1=0
@value2=0
... | Ruby |
require 'will_paginate'
class CommentsController < ApplicationController
layout 'application'
def create
@picture = Picture.find(params[:picture_id])
@comment = @picture.comments.build(params[:comment])
@comment.user_id = session[:user_id]
@comment.save
#redirect_to :back
respond_to do |format|
fo... | Ruby |
require 'will_paginate'
class PictureController < ApplicationController
helper :site
def delete
@picture = Picture.find(params[:id])
if session[:user_id] == @picture.user_id or User.find(session[:user_id]).is_admin
['small.jpg', 'medium.jpg', 'large.jpg'].each do |file|
if File.exists?("#{RAILS_ROOT}/pub... | Ruby |
class VoteController < ApplicationController
def create
@vote = Vote.new
@vote.picture = Picture.find(params[:vote]['picture_id'])
@vote.user = User.find(session[:user_id])
@vote.picture.update_score(params[:vote][:score])
@vote.save
respond_to do |format|
format.html { redirect_to :back }... | 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
before_filter :authorize, :except => [:login, :register, :index, :about, :pictures, :users, :show, :gallery, :p... | Ruby |
require 'digest/sha2'
require 'will_paginate'
class UsersController < ApplicationController
before_filter :admin_authorize
# GET /users
# GET /users.xml
def index
@users = User.find(:all, :order => :username)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml =>... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.