text stringlengths 10 2.61M |
|---|
# -*- encoding : utf-8 -*-
class PagesController < ApplicationController
filter_access_to [:index, :new, :create]
filter_access_to [:show, :edit, :update, :destroy, :history], attribute_check: true,
load_method: :load_page
filter_access_to [:admin], ... |
class User < ActiveRecord::Base
has_many :tweets
def fetch_tweets!
self.tweets.delete_all
tweets = Twitter.user_timeline(self.username, :count => 200)
tweets.each do |tweet|
self.tweets << Tweet.create(text: tweet[:text])
end
self.updated_at = Time.now
self.save
end
def tweets_... |
class Space<ActiveRecord::Base
belongs_to :user
has_many :photos
validates :address, presence: true
validates :cost, presence: true
validates :description, presence: true
has_many :bookings
end
|
class Photo < ActiveRecord::Base
include MediaSupport
media :image, inverse_of: :owner
belongs_to :gallery
PARAMS = [
:id,
:gallery_id,
:link,
image_attributes: [:id, :file, :_destroy]
]
validates :image, presence: true
validates :link, format: { with: URI.regexp }, allow_blank: true
e... |
require_relative './pricing_rules.rb'
require_relative './shopping_item.rb'
class Checkout
attr_reader :pricing_rules, :inventory, :cart
def initialize(pricing_rules)
@pricing_rules = pricing_rules
@inventory = Inventory.new
@cart = {}
end
def add_shopping_item(shopping_item)
@inventory.add... |
class AddFieldsToUser < ActiveRecord::Migration
def change
add_column :users, :profile_name, :string
add_column :users, :profile_pic, :string
add_column :users, :cover_pic, :string
add_column :users, :location, :string
add_column :users, :facebook_link, :string
add_column :users, :twitter_link... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_one_attached :avatar
has_many :posts, dependent: ... |
class Term < ActiveRecord::Base
belongs_to :profile
belongs_to :office
scope :active, where("(start_date IS NULL OR start_date < :now) AND (end_date IS NULL OR end_date > :now)", {:now => Time.now})
def header
if office.is_officer?
"Officers"
elsif office.is_special?
"Special Members"
... |
# encoding: UTF-8
module Morpher
class Evaluator
class Transformer
# Abstract namespace class for coercing transformers
class Coerce < self
include AbstractType, Nullary::Parameterized, Transitive
# Evaluator for parsing an integer
class ParseInt < self
register :p... |
# frozen_string_literal: true
# checkmate responsibilities
module Checkmate
def potential_blockers(piece1, from1, all_possible_moves)
# p piece1
king_pos = king_position
btwn_squares = between_squares(king_pos, from1)
blockers = btwn_squares&.select { |move| all_possible_moves.include?(move) }
bl... |
class DatEvent < ActiveRecord::Base
#########################
# 関連定義
#########################
# プロジェクト構成データに所有される(1:1)
belongs_to :dat_projectcomp, :foreign_key => "project_tree_id"
# イベントユーザーデータを所有する(1:多)
has_many :dat_eventusers, :foreign_key => "event_id", :dependent=>:destroy
#
#=== テンプレートデータから... |
require 'tempfile'
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Ipizza::Config do
describe '.load_from_file' do
before(:each) do
Ipizza::Config.load_from_file(File.expand_path(File.dirname(__FILE__) + '/../config/plain_config.yml'))
end
it 'should load configur... |
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :configure_permitted_edit_parameters, if: :devise_controller?
include TheRole::Controller
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to ... |
require 'spec_helper'
describe 'Single Granule Data Access', reset: false do
downloadable_collection_id = 'C179002914-ORNL_DAAC'
context 'when the user is not logged in' do
before(:each) do
load_page :search, focus: downloadable_collection_id
wait_for_xhr
first_granule_list_item.click_link "... |
Rails.application.routes.draw do
concern :active_scaffold_association, ActiveScaffold::Routing::Association.new
concern :active_scaffold, ActiveScaffold::Routing::Basic.new(association: true)
resources :child_models, concerns: :active_scaffold
resources :main_models, concerns: :active_scaffold
root :to => re... |
class AddContestant < ActiveRecord::Migration[5.1]
def change
create_table :contestants do |t|
t.integer :tournament_id, null: false
t.boolean :active, default: true
t.string :name
t.string :email
t.timestamps
end
end
end
|
require './app/config/shield_generator'
require 'simplecov'
class GhShieldsBuilder
def initialize
@generator = ShieldGenerator.new
end
def build_shields
@generator.write_shield("coverage", coverage_percentage, coverage_color)
end
private
def coverage_percentage
SimpleCov.result.covered_perce... |
# frozen_string_literal: true
require "fileutils"
RSpec.describe ZoomSlack::ProcessDetector::Mac do
let(:open) { class_spy(Open3) }
let(:compiled_path) { File.join(Dir.tmpdir, ZoomSlack::ProcessDetector::Mac::COMPILED_SCRIPT) }
let(:source_path) { File.join(File.dirname(__FILE__).gsub("spec", "lib"), "source", ... |
# frozen_string_literal: true
module Jidoka
module Notifiable
extend ActiveSupport::Concern
included do
def send_notification
notify(@opts)
# These are just notifications so they can silently fail but still report error
rescue StandardError => e
capture_error(e)
end
... |
require_relative '../lib/string_helper'
class Plan
NO_ADMITE_CONYUGE = 'NO_ADMITE_CONYUGE'.freeze
ADMITE_CONYUGE = 'ADMITE_CONYUGE'.freeze
REQUIERE_CONYUGE = 'REQUIERE_CONYUGE'.freeze
attr_accessor :id, :nombre, :slug, :costo,
:cobertura_visitas, :cobertura_medicamentos,
:edad_m... |
class CreateAdvanceFeeCategories < ActiveRecord::Migration
def self.up
create_table :advance_fee_categories do |t|
t.string :name
t.string :description
t.integer :financial_year_id
t.boolean :online_payment_enabled, :default => true
t.boolean :is_enabled, :default => true
t.boo... |
#
# Cookbook Name:: libarchive
# Resource:: file
#
# Copyright:: 2017-2018 Chef Software, Inc.
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
# Author:: Tim Smith (<tsmith@chef.io>)
#
resource_name :archive_file
provides :libarchive_file
property :path, String, name_property: true, coerce: proc { |f| ::File.expand... |
require 'rails_helper'
describe Admin::StatsController do
context 'when admin not logged in' do
%w(index).each do |action|
it "requires authentication for :#{action}" do
get action.to_sym
expect(response).to redirect_to new_admin_user_session_path
end
end
end
end
|
class PurchaseAddress
include ActiveModel::Model
attr_accessor :user_id, :item_id, :postcode, :prefecture_id, :municipality, :address, :building_name, :phone_number, :token
with_options presence: true do
validates :user_id
validates :item_id
validates :postcode, format: {with: /\A\d{3}[-]\d{4}\z/, me... |
require 'test_helper'
class JobsControllerTest < ActionDispatch::IntegrationTest
setup do
@job = jobs(:one)
end
test "should get index" do
get jobs_url
assert_response :success
end
test "should get new" do
get new_job_url
assert_response :success
end
test "should create job" do
... |
require 'rake'
require 'pry'
markdowns = Rake::FileList.new('**/*.md') do |fl|
fl.exclude do |f|
`git ls-files #{f}`.empty?
end
end
# all foo/bar/blah.md becomes foo/bar/blah.html
htmls = markdowns.ext('html').pathmap('dist/%p')
task default: :html
task html: htmls
# tell rake to create the dist dir if it ... |
RSpec::Matchers.define :have_status do |type, message = nil|
match do |_response|
assert_response type, message
end
end
RSpec::Matchers.define :serialize_object do |object|
match do |response|
@serializer_klass.new(object, root: false).to_json == response.body
end
chain :with do |serializer_klass|
... |
# frozen_string_literal: true
require 'jiji/test/test_configuration'
require 'logger'
describe Jiji::Model::Logging::Log do
include_context 'use backtests'
let(:time_source) { Jiji::Utils::TimeSource.new }
let(:log) { Jiji::Model::Logging::Log.new(time_source) }
let(:backtest_log) do
Jiji::Model::Logging... |
require 'multi_json'
require 'csv'
require 'tmpdir'
require 'logger'
require 'set'
require 'salesforce_bulk_query'
require 'restforce'
require 'webmock/rspec'
class Helper
DEFAULT_API_VERSION = '30.0'
def self.create_default_restforce
Restforce.new(
:username => ENV['USERNAME'],
:password => ENV['P... |
module Elements
class EssenceImage < Essence
belongs_to :value, :class_name => '::Image'
def serializable_hash(options=nil)
value.present? ? Elements::Commons.image_to_hash(value) : nil
end
end
end
|
Rails.application.routes.draw do
get 'matches/edit'
root 'static_pages#home'
# DEVISE
devise_for :admins, path: "admin"
# RESOURCES
resources :leagues do
resources :matches, only: [:edit, :update]
resources :players, only: [:edit, :update, :show]
member do
get 'joueurs', to: 'leagues#sh... |
# frozen_string_literal: true
require 'hanami/application/routes'
module Welcome
class Routes < Hanami::Application::Routes
define do
slice :main, at: '/' do
root to: 'home.show'
end
end
end
end
|
require './f5'
require 'optparse'
require 'pp'
require 'ostruct'
class Optparser
LB_METHODS = %w[LB_METHOD_GLOBAL_AVAILABILITY LB_METHOD_TOPOLOGY]
LB_METHOD_ALIASES = { "ga" => "LB_METHOD_GLOBAL_AVAILABILITY", "topology" => "LB_METHOD_TOPOLOGY"}
def self.parse(args)
options = OpenStruct.new
opts = Opt... |
class CreateBasicPartyInfos < ActiveRecord::Migration[5.2]
def change
create_table :basic_party_infos do |t|
t.integer :party_id
t.string :first_name
t.string :middle_name
t.string :last_name
t.string :suffix
t.integer :attorney_id
end
end
end
|
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the f... |
# frozen_string_literal: true
require "rails_helper"
describe Term do
before { Timecop.freeze(2016, 1, 1) }
after { Timecop.return }
it { is_expected.to have_many(:academic_degree_terms).dependent(:destroy) }
it { is_expected.to have_many(:academic_degrees).through(:academic_degree_terms) }
it { is_expect... |
module Audience
module Api
class Client
# Auto pagination functionality
#
# Example:
# Audience::Api.auto_paginate :list_contacts, 2 do |batch|
# pp batch
# end
module AutoPaginate
# Yields given block within collection
def auto_paginate(api_method... |
class PhotosController < ApplicationController
def create
if !params.has_key?( :file )
message = Message.invalid_request( "file" )
render json: { error: message }, status: 400
return
end
photo_h = {}
photo_h[:image] = params[:file]
if params.has_key?( :user_id )
relation = "User"
photo_h[:use... |
class CreateFamilias < ActiveRecord::Migration
def change
create_table :familias do |t|
t.string :codigo
t.string :familia
t.timestamps
end
end
end
|
class AddDelegateVoteCount < ActiveRecord::Migration
def change
add_column :all_delegates, :vote_count, :integer, :default => 0
add_index :all_delegates, :vote_count
end
end
|
class ClassEnv
DefaultPath = "config/property.yml"
PROPERTY = RecursiveOpenStruct.new(YAML.load_file(DefaultPath))
def self.method_missing(method_name, *args, &block)
if PROPERTY[method_name]
return PROPERTY.send(method_name)
end
super
end
end
# ClassEnv.base_url
# ClassEnv.app_token |
class UsersController < ApplicationController
inherit_resources
respond_to :html, :json
before_filter :authenticate_user!
filter_resource_access
before_filter :set_selectable_roles, :except => [:destroy]
def index
index! do |format|
format.json {
render :text => "{\"users\" : #{@users.t... |
class User < ActiveRecord::Base
include BCrypt
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :username, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
validates :passwo... |
class AddPrimaryAndOrderToItems < ActiveRecord::Migration
def change
add_column :items, :primary, :boolean, default: false
add_column :items, :order, :integer
end
end
|
require './parsers'
require './utils'
DATA_DIR = "/usr/local/share/feedr"
TARGET_DIR = File.join(DATA_DIR, "media")
LIST_FILE = File.join(DATA_DIR, "db.list")
RESOURCE = "http://www.reddit.com/r/EarthPorn/.rss"
class DownloadingParser < RedditRSSParser
def initialize(target_dir, db_hash)
@target_dir = target_di... |
# == Schema Information
#
# Table name: sporting_goods
#
# id :integer not null, primary key
# user_id :integer not null
# lat :float not null
# lng :float not null
# description :text
# category :string not null
# pic_url :str... |
class CreateOrders < ActiveRecord::Migration[5.2]
def change
create_table :orders do |t|
t.bigint :user_id
t.integer :amount, null: false
t.integer :shipping_fee, null: false
t.integer :payment, null: false
t.string :postal_code, null: false
t.string :prefectures, null: false
... |
class MomentumCms::Page < ActiveRecord::Base
# == MomentumCms ==========================================================
include MomentumCms::BelongsToSite
self.table_name = 'momentum_cms_pages'
# == Constants ============================================================
# == Relationships ===============... |
RedmineApp::Application.routes.draw do
resources 'failures', only: %i[index show update]
end
|
require 'rails_helper'
RSpec.describe ApplicationHelper, type: :helper do
describe '#link_to_image' do
it 'returns clickable image if condition is true' do
expect(helper.link_to_image(true, 'url', 'img')).to eql '<a href="url">img</a>'
end
it 'returns just an image if condition is false' do
... |
#!/usr/bin/ruby
#
# consolidate/aggregate hits files
# input files are assumed to be sorted by hits descending
#
# format is assumed:
# parameters
# arg 0: input file pattern
# arg 1: tot postings
# arg 2: output file
totPostings = ARGV[1].to_i
thresholds = []
files = []
candidates = []
i = 0
# input files(s)
Dir.... |
class HolaUserCoupon < ActiveRecord::Base
belongs_to :hola_user
belongs_to :coupon
validates_uniqueness_of :coupon_id, :scope => :hola_user_id
end
|
require 'test_helper'
class FitmentsControllerTest < ActionController::TestCase
setup do
@fitment = fitments(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:fitments)
end
test "should get new" do
get :new
assert_response :success
en... |
class BuildMailer < ActionMailer::Base
def success(recipient, build)
setup
subject I18n.t('build_mailer.subject.success', :project => build.project.name, :plan => build.name)
set_header(recipient, build)
end
def failure(recipient, build)
setup
subject I18n.t('build_mailer.subject.failure', ... |
class Add0ToBoards < ActiveRecord::Migration[5.2]
def change
add_column :boards, "0", :string
end
end
|
require 'rails_helper'
RSpec.describe CommentsController, type: :controller do
before do
@user = create(:user)
@product = create(:product, user: @user)
@purchase = create(:purchase, product: @product, user: @user)
end
context "when not logged in" do
before do
session[:user_id] = nil
end... |
Rails.application.routes.draw do
root 'zoos#index'
resources :zoos do
resources :animals
end
resources :animals do
resources :comments
end
end
|
require 'spec_helper'
describe "group_memberships/new" do
before(:each) do
assign(:group_membership, stub_model(GroupMembership,
:user_id => 1,
:group_id => 1
).as_new_record)
end
it "renders new group_membership form" do
render
# Run the generator again with the --webrat flag if yo... |
# frozen_string_literal: true
## --- BEGIN LICENSE BLOCK ---
# Copyright (c) 2016-present WeWantToKnow AS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including wit... |
class ListingsController < ApplicationController
def index
@wassup = "waasssup"
@listings = Listing.all
end
def new
@listing = Listing.new
end
def create
new_listing = Listing.new(listing_params)
if new_listing.save
redirect_to listings_path
else
render new_listing
e... |
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Amendable
describe ReviewForm do
subject { form }
let(:component) { create(:opinion_component) }
let(:amendable) { create(:opinion, component: component) }
let(:emendation) { create(:opinion, component: component)... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
describe 'GET #new' do
let(:user) { FactoryGirl.create(:user) }
before do
login_user(user, sign_in_path)
end
it 'render sign up page' do
get :new
expect(response).to render_template :new
end
end
end
|
class Item < ApplicationRecord
validates :size, :width, :weight, :length, :height, numericality: {greater_than: 0}
validates :dispatch, :destination, presence: true
end
|
class AddIndexToUsersEmail < ActiveRecord::Migration
def change
#you need to fill in the line below
add_index :users, :email, unique: true
end
end
|
module FueledOsxBuildTools
class DmgMetadata
def initialize(dmg_path)
@dmg_path = dmg_path
@os = FueledOsxBuildTools::OsCheck.new.os
end
def volumes_dir
if map[@os]
map[@os]['volumes_dir']
end
end
def pkg_name
if map[@os]
map[@os]['pkg_name']
e... |
def input_students
puts "Please enter the name of the students. \nTo finish, just hit return twice."
students = []
name = gets.chomp
while !name.empty? do
students << {:name => name, :cohort => :november}
puts "Now we have #{students.length} students"
name = gets.chomp
end
students
end
def prin... |
require_relative "repositories/car_repository"
require_relative "repositories/rental_repository"
require_relative "repositories/modification_repository"
# The `InputParser` is in charge of reading the database and providing
# the relevent repositories:
#
# - a `RentalRepository` for the rentals and
# - a `Modification... |
class PersonPhone < ApplicationRecord
#
# Validations
#
belongs_to :person
# before_save :validate_phone
#
# Validations
#
validates(
:phone,
uniqueness: true
)
validate(
:is_phone_valid?
)
def is_phone_valid?
errors.add(:phone, "Phone Number Is Already Added") if self.per... |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Avoid resetting session during callback so that Devise can redirect back to
# the originally requested page. This is really a GET request redirected
# from the OpenID endpoint anyway, so we're never going to be able to receive
# a... |
module Deco
def self.table_name_prefix
'deco_'
end
end
|
helpers do
def configureLinkedin
LinkedIn.configure do |config|
config.client_id = ENV["LINKEDIN_CLIENT_ID"]
config.client_secret = ENV["LINKEDIN_CLIENT_SECRET"]
# This must exactly match the redirect URI you set on your application's
# settings page. If your redirect_uri is dynamic, ... |
require 'terminal'
require 'runit/testcase'
require 'runit/assert'
require 'runit/cui/testrunner'
class TestTerminal < RUNIT::TestCase
include KeyEvent::Key
include KeyEvent::Modifier
def test_xterm1
data = [
"a", [KEY_A, 0],
"z", [KEY_Z, 0],
"A", [KEY_A, SHIFT],
"Z", [KEY_Z, SHIFT],
0.chr, [KEY_S... |
require 'rails_helper'
RSpec.describe Students::FollowEducatorService, type: :service do
it "can create a relationship between students and educators" do
student = create(:student)
educator = create(:educator)
service = Students::FollowEducatorService.new(student, educator)
expect {
service.exe... |
class AuthenticationsController < ApplicationController
def new
end
def create
@user = User.find_by(email: params[:email])
log_in @user
end
def destroy
session.destroy
redirect_to root_path, notice: "You have been signed out"
end
private
def log_in(user)
if user && user.authent... |
class Answer < ApplicationRecord
belongs_to :question
belongs_to :user
def as_json(options = {})
super(options.merge(include: :user))
end
end
|
class BasicPushSubscriber < ActionSubscriber::Base
publisher :greg
# queue => alice.greg.basic_push.booked
# routing_key => greg.basic_push.booked
def booked
$messages << payload
end
queue_for :cancelled, "basic.cancelled"
routing_key_for :cancelled, "basic.cancelled"
def cancelled
$messages ... |
#!/usr/bin/env ruby
# :title: Plan-R CLI Tab Completion
=begin rdoc
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'readline'
#require 'abbrev'
require 'plan-r/application/cli/command'
module PlanR
module Cli
module Completion
DEFAULT_PROMPT = '> '
# TODO: plugin l... |
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
before {visit root_path}
it "should have the content 'Sample App'" do
page.should have_content('Sample App')
end
it "should have the correct title" do
page.should have_selector('title', :text => 'La Casa')
end
... |
class ApplicationController < ActionController::Base
before_action :get_instagram_media
rescue_from CanCan::AccessDenied do |exception|
redirect_to main_app.root_url, alert: exception.message
end
def get_instagram_media
if InstagramAccessToken.second.nil?
entry = InstagramAccessToken.create(acc... |
module Topographer
class Importer
class Mapper
class IgnoredFieldMapping < Topographer::Importer::Mapper::FieldMapping
def initialize(input_columns)
@input_columns = input_columns
@output_field = nil
end
def required?
false
end
end
end... |
require_relative './page_base.rb'
class TelevisionReview < PageBase
def await
@webdriver_wait.until { @webdriver.find_element(television_review_keyword) }
end
def get_title
@webdriver.find_element(television_review_keyword).text
end
private
def television_review_keyword
{:class => '_14jn_'}
... |
require 'test/unit'
require 'get_response'
class TC_Bencode < Test::Unit::TestCase
def test_get_success
response = GetResponse.new("d8:completei13e10:incompletei2e8:intervali7200e12:min intervali7200e5:peers90:;^\361\247\367,\030\017'\264R3V\217J\264\005HW\022-\272\017\253z\2479\321\300\000Vx\235\v\201T\324\317Y... |
module Headjack
module DefaultAdapter
module ClassMethods
def all_filter result
result
end
def auto_filter result
all_filter result
end
def call conn, payload
filter = filter_method(payload)
res = conn.post(endpoint, parse_payload(payload, filter: fi... |
class Creator < ActiveRecord::Base
has_many :restaurants
has_secure_password
EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :name, presence: true, length: {within: 2..50}
validates :email, presence: true, format: {with: EMAIL_REGEX}, uniqueness: {case_sensitive: false}
validates :password, p... |
class CreateTaskOrders < ActiveRecord::Migration
def change
create_table :task_orders do |t|
t.integer :game_id
t.integer :team_id
t.integer :task_id
t.integer :order_n
t.boolean :solved
t.boolean :dropped
t.datetime :time_start
t.datetime :time_hint1
t.dateti... |
require 'spec_helper'
require 'erb'
describe 'CentrosController' do
let(:centro_nombre) do
'Hospital Italiano'
end
let(:otro_centro) do
'Hospital Suizo'
end
let(:latitud) do
-34.555
end
let(:longitud) do
39.501
end
let(:prestacion) do
{ 'nombre' => 'Traumatología', 'costo' => ... |
#==============================================================================
# ** Database
#------------------------------------------------------------------------------
# Autor: Valentine
# MySQL Plugin: Gallighanmaker
#==============================================================================
module Database... |
class VipLbPoolAssignmentsController < ApplicationController
# sets the @auth object and @object
before_filter :get_obj_auth
before_filter :modelperms
# GET /vip_lb_pool_assignments
# GET /vip_lb_pool_assignments.xml
def index
## BUILD MASTER HASH WITH ALL SUB-PARAMS ##
allparams = {}
allparams... |
require 'minitest/autorun'
require 'minitest/reporters'
MiniTest::Reporters.use!
require_relative 'cash_register'
require_relative 'transaction'
class CashRegisterTest < MiniTest::Test
# def setup; end
def test_accept_money
register = CashRegister.new(0)
transaction = Transaction.new(20)
transaction... |
class Profile < ActiveRecord::Base
devise :cas_authenticatable, :trackable
has_many :terms
has_many :blogs, :foreign_key => "author_id"
has_many :memberships
has_attached_file :avatar,
:styles => { :medium => "143x148>", :tiny => "52x52>" },
:default_url => "/images/layout/icon_people.png"
valida... |
class CreateArticles < ActiveRecord::Migration[5.0]
def change
create_table :articles do |t|
t.string :title
t.text :content
t.integer :user_id
t.integer :attachnment_id
t.string :attachnment_type
t.timestamps
end
add_index :articles, [:attachnment_id, :attachnme... |
require 'java'
# Set the weka home
ENV['WEKA_HOME'] = File.join(Rails.root, '/lib/weka-3-7-5/packages')
require Rails.root + 'lib/weka-3-7-5/packages/packages/LibSVM/LibSVM.jar'
require Rails.root + 'lib/weka-3-7-5/packages/packages/LibSVM/lib/libsvm.jar'
require Rails.root + 'lib/weka-3-7-5/packages/packages/LibLINEA... |
class CreateLocationCategoryTypes < ActiveRecord::Migration[5.0]
def change
create_table :location_category_types do |t|
t.integer :location_id, :category_type_id
end
end
end
|
class AddFieldsToCceReports < ActiveRecord::Migration
def self.up
add_column :cce_reports,:subject_id,:integer
add_column :cce_reports,:cce_exam_category_id,:integer
end
def self.down
remove_column :cce_reports,:subject_id,:integer
remove_column :cce_reports,:cce_exam_category_id,:integer
end
e... |
# XSD4R - WSDL named element collection.
# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
# redistribute it and/or modify it under the same terms of Ruby's license;
# either the dual license version in 2003, or any late... |
class Auth::Encryptors::Sha512
class << self
attr_accessor :token_delimeter
attr_writer :stretches
def stretches
@stretches ||= 20
end
def encrypt(*what)
digest = what.flatten.join(token_delimeter)
stretches.times { digest = Digest::SHA512.hexdigest(digest) }
dige... |
class FeedSerializer
include Rails.application.routes.url_helpers
def initialize(posts_object)
@posts = posts_object
end
def to_serialized_json
end
private
def get_image_url
url_for(@post.image)
end
end |
class ExpireMagicLinkAndNotifyUsers < ApplicationUseCase
def initialize(employee)
@employee = employee
end
def perform
expire_magic_link
notify_users
end
private
def expire_magic_link
@employee.update_attributes!(magic_link_expiry: Time.current)
end
def notify_users
UserMailer.do... |
Sequel.migration do
change do
create_table(:session_informations) do
String :name, :primary_key => true
String :value, :text => true
end
end
end
|
class Article < ApplicationRecord
has_many :article_categories, dependent: :destroy
has_many :categories, through: :article_categories
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.