text stringlengths 10 2.61M |
|---|
class CreateAreas < ActiveRecord::Migration[5.0]
def change
create_table :areas do |t|
t.string :nombre
t.integer :state_id
t.string :poblacion
t.string :edad
t.string :hogares
t.string :con_hijos
t.string :sin_hijos
t.string :rpc
t.string :viviendas
t.s... |
#!/usr/bin/ruby -w
#
# Test etch's handling of various actions: pre, post, setup, test, etc.
#
require File.expand_path('etchtest', File.dirname(__FILE__))
class EtchActionTests < Test::Unit::TestCase
include EtchTests
def setup
# Generate a file to use as our etch target/destination
@targetfile = rele... |
# frozen_string_literal: true
class Election < ApplicationRecord
belongs_to :annual_meeting, -> { where type: 'AnnualMeeting' }, class_name: 'AnnualMeeting',
inverse_of: :elections
belongs_to :member
belongs_to :role
validates :member_id, :role_id, presence: true
scope :current, ->(now = Time.current... |
module Madness
# Handle command line execution. Used by bin/madness.
class CommandLine
include Singleton
include Colsole
# Launch the server
def execute(argv=[])
launch_server_with_options argv
end
private
# Execute the docopt engine to parse the options and then launch the
... |
require 'exchange_rate'
RSpec.describe ExchangeRate do
describe 'parsing the xml' do
before(:each) do
@yesterday = Date.today.prev_day
@parser = XMLParser.new
@exchange_rate = ExchangeRate.new(Date.new(2018, 8, 3), 'EUR', 'USD')
end
it 'should set the xml file' do
@parser.get_ra... |
module DelayedCell
class Proxy
def initialize(target)
@queue = Queue.new target
end
def method_missing(method, *args, &block)
@queue.push Job.new(method, args)
end
end
end |
require 'logger'
module GooglePlay
module Log
@loggers = {}
def logger
@logger ||= Log.logger_for(self.class.name)
end
def self.logger_for(klass)
@loggers[klass] ||= configure_logger_for(klass)
end
def self.configure_logger_for(klass)
logger = Logger.new(STDOUT)
log... |
require "help.rb"
module TestsHelp
#####################################
# Private section #
#####################################
@@TESTHELP=Hash.new()
private
class TestsHelp_Err < StandardError
end
class TestSection
def initialize()
@entries = Hash.new
@descript... |
require_relative '02_searchable'
require 'active_support/inflector'
# bundle exec rspec spec/03_associatable_spec.rb
# Phase IIIa
class AssocOptions
attr_accessor(
:foreign_key,
:class_name,
:primary_key
)
def model_class
#go from a class name to a class object
@class_name.constantize
en... |
require 'rails_helper'
RSpec.describe "action_requireds/edit", type: :view do
before(:each) do
@action_required = assign(:action_required, ActionRequired.create!(
name: "MyString",
phone: "MyString",
address: "MyString",
category: "MyString",
ref_number: "MyString",
remarks: "... |
class SecretCodeController < ApplicationController
load_and_authorize_resource :class => "SecretCodes"
#show all secrets codes
#scope-> action handling
def index
@secret_codes = SecretCodes.includes(:user).all
end
def create
strong_params = secret_code_params
SecretCodes.create_codes strong_params[... |
require File.dirname(__FILE__) + '/spec_helper.rb'
describe "Client" do
it "should instantiate a client with a username and password" do
c = PostalMethods::Client.new(PM_OPTS)
c.class.should == PostalMethods::Client
end
it "should fail without a user/pass on instantiation" do
lambda {PostalMeth... |
require 'rails_helper'
describe Merchant, type: :model do
let(:customer) {Customer.create(first_name: "Jorge",
last_name: "Mexican",
created_at: "2020-12-12 12:12:12",
updated_at: "2020-12-11 12:12:12")}
let(:mer... |
require_relative("../db/sql_runner.rb")
require_relative("animal")
class Owner
attr_reader :id
attr_accessor :name, :notes, :phone_number
def initialize(options)
@name = options['name']
@id = options['id'].to_i if options['id']
@notes = options['notes']
@phone_number = options['phone_number']
... |
class Trade::BatchUpdate
def initialize(search_params)
search = Trade::Filter.new(search_params)
@shipments = Trade::Shipment.joins(
<<-SQL
JOIN (
#{search.query.to_sql}
) q
ON q.id = trade_shipments.id
SQL
)
end
def execute(update_params)
affected_shipments... |
Rails.application.routes.draw do
root 'test#test'
post '/posttest', to:'test#post'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
require_relative 'Randomizer'
class Die < Randomizer
attr_reader :sides
def initialize(sides_input,colour_input)
@enum_colour = [:red,:green,:blue,:yellow,:black,:white]
if sides_input < 3
return nil
end
colour_flag = false
for i in (0..@enum_colour.si... |
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
# All rights reserved.
#
# This source file is distributed as part of the Needle dependency injection
# library for Ruby. This file (and the library as a whole) may be used only as
... |
# Removing full vs. rating distinction as part of the RIC project
# These columns are no longer needed as they serve no purpose going forward.
class DropDeprecatedFullRatingColumns < ActiveRecord::Migration
def self.up
remove_column :product_stats, :active_full_review_count
remove_column :product_stats, ... |
class ConversationsChannel < ApplicationCable::Channel
def subscribed
#createing a generic channel where all users connect
# stream_from "conversations_channel"
# creating a private channel for each user
stream_from "current_user_#{current_user.id}"
end
def unsubscribed
# Any cleanup ne... |
class AddMagicAttributesToActiveAdminAssets < ActiveRecord::Migration
def change
add_column :active_admin_assets, :storage_width, :integer
add_column :active_admin_assets, :storage_height, :integer
add_column :active_admin_assets, :storage_aspect_ratio, :float
add_column :active_admin_assets, :storage... |
class Workflow::AccrualKey < ApplicationRecord
belongs_to :workflow_accrual_job, class_name: 'Workflow::AccrualJob', foreign_key: 'workflow_accrual_job_id'
has_one :workflow_globus_transfer, class_name: 'Workflow::GlobusTransfer', dependent: :destroy, foreign_key: 'workflow_accrual_key_id'
def exists_on_main_ro... |
class SessionsController < ApplicationController
def new
end
def create
@user = User.find_by_credentials(user_params[:email], user_params[:password])
return nil if @user.nil?
login! @user
redirect_to user_url(@user)
end
def destroy
logout!
redirect_to new_session_url
end
private
def user_params... |
require 'spec_helper'
describe Launchpad::Settings do
let(:settings_fixture) { 'spec/fixtures/config/settings.yml' }
let(:settings_path) { 'spec/fixtures/config/current-settings.yml' }
before do
FileUtils.copy settings_fixture, settings_path
stub_const 'Launchpad::Settings::PATH', settings_path
end
... |
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
class JobTest < Test::Unit::TestCase
context "A Job" do
should "output the :task" do
job = new_job(:template => ":task", :task => 'abc123')
assert_equal %q(abc123), job.output
end
should "output the :task if it's in sin... |
require 'hashie'
module SimplyGenius
module Atmos
class SettingsHash < Hashie::Mash
include GemLogger::LoggerSupport
include Hashie::Extensions::DeepMerge
include Hashie::Extensions::DeepFetch
disable_warnings
PATH_PATTERN = /[\.\[\]]/
def notation_get(key)
path = ... |
# frozen_string_literal: true
namespace :db do
desc 'It updates every user access token'
task update_token: :environment do
User.all.each { |user| AccessTokenRefresher.new(user).call }
end
end
|
class Producer < ApplicationRecord
has_one :appellation
has_one :country, :through => :appellation
has_many :wines
end
|
class AdminsController < ApplicationController
before_action :authenticate_user!
before_action :require_admin
def index
@users = []
@editors = []
end
def add_editor_admin
if params[:q]
if params[:q].blank?
params[:q] = "@"
end
@users = User.search(params[:q])
else
... |
require_relative './topten'
describe '#sanitize' do
it 'should remove punctuation' do
expect(sanitize('test!')).to eq 'test'
end
it 'should normalize to lowercase' do
expect(sanitize('Test!')).to eq 'test'
end
end
describe '#break_line' do
it 'should count words in a string of text' do
... |
require 'rails_helper'
describe 'user deletes an article' do
describe 'they link from the show page' do
it 'displays all articles without the deleted article' do
article_3 = Article.create!(title: "Title 3", body: "Body 3")
article_2 = Article.create!(title: "Title 2", body: "Body 2")
visit ar... |
class ExampleController < ApplicationController
def example1
# Explicit Render:
#
# We can specify the specific file we want to render
# and send back to the browser
render '/example/explicit_render'
end
def example2
# Implicit Render:
#
# Rails can guess the name based on the con... |
if @user.valid?
json.set! :result, :success
else
response.status = 400
json.set! :result, :error
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
# Antes de qualquer ação, o usuário precisa estar logado
before_action :require_login
private
def require_login
unless logged_in?
flash[:notice] = "Você precisa estar logado."
redirect_to '/sign_in'... |
raise 'Wrong number of arguments' unless ARGV.length >= 2 && ARGV.length <= 3
steam_id = SteamId.to_64(ARGV[0])
raise 'Invalid steam id' unless steam_id
username = ARGV[1]
raise 'Empty username' if username.empty?
terminated_at = Time.zone.now + ActiveSupport::Duration.parse(ARGV[2]) if ARGV.length == 3
# Find the ... |
class CreateImages < ActiveRecord::Migration
def change
create_table :images do |t|
t.references :folder
t.string :title
t.string :alternative
t.text :description
t.string :image_file_name
t.string :image_content_type
t.integer :image_file_size
t.integer :ord... |
class Matrons::RegistrationsController < Matrons::ApplicationController
skip_before_action :authenticate_user!, only: %i(new create)
def new
render_view Matrons::Registrations::New, matron_create: nil
end
def create
matron_create = Matron::Create.run(hparams.fetch(:matron_create, {}))
if matron_c... |
require "rails_helper"
describe Tag do
let(:repo) { Repository.new(name: "test/hello-world") }
describe ".find" do
let(:name) { "latest" }
context "with a repository returning non-json content type for meta blob" do
let(:blob_content_type) { "application/octet-stream" }
it "returns one repos... |
require 'concurrent'
class ConcurrencySimulation
def initialize
@processes = []
if block_given?
yield self
run
end
end
def add_process(&block)
@processes << Process.new.tap do |p|
p.instance_eval(&block)
end
end
def processes_count
@processes.length
end
def ru... |
require 'authenticate/callbacks/lifetimed'
module Authenticate
module Model
#
# Imposes a maximum allowed lifespan on a user's session, after which the session is expired and requires
# re-authentication.
#
# = Configuration
# Set the maximum session lifetime in the initializer, giving a time... |
FactoryBot.define do
factory :forums_topic, class: 'Forums::Topic' do
parent { nil }
association :created_by, factory: :user
locked { false }
pinned { false }
hidden { false }
isolated { false }
default_hidden { false }
description { 'a *sample* description' }
name { 'General Discu... |
class Answer < ApplicationRecord
belongs_to :question
scope :correct_answers, -> { where(correct: true) }
validates :body, presence: true
validate :validate_count_answer, on: create
private
def validate_count_answer
errors.add(:question, 'Ошибка. Ответов > 4') if question.answers.count >= 4
end
... |
require "rails_helper"
describe StaticPagesController do
let(:user) { build_with_attributes(User) }
context "#email_sent" do
before { user.save }
it "assigns @user" do
get :email_sent, id: user.id, email: user.email
expect(assigns[:user]).to be_instance_of(User)
end
it_behaves_like "... |
class AdminPortfolioSerializer < ActiveModel::Serializer
attributes :id, :user_id, :market_value, :in_balance, :created_at
def market_value
# Report no value if they haven't set up yet.....
object.current_shares.present? ? object.send(:current_market_value) : 0.0
end
def in_balance
# Report in ba... |
#!/usr/bin/ruby
class String
def lowercase?
chars.all? do |c|
!('A'..'Z').include?(c)
end
end
def uppercase?
chars.all? do |c|
!('a'..'z').include?(c)
end
end
end
ALPHABET = [*'a'..'z']
TRANSLATIONS = ALPHABET.zip(ALPHABET.shuffle).to_h
def translate(string)
string.chars.map d... |
Registrar::Engine.routes.draw do
root "sessions#new"
get "/auth/google/callback", to: "sessions#create"
get "/signin", to: "sessions#new"
get "/signout", to: "sessions#destroy"
resource :sessions, only: [:new, :create, :destroy]
end
|
class RemoveUserRefFromPost < ActiveRecord::Migration[5.0]
def change
remove_column :posts, :user, :refernces
end
end
|
class Metasubservicio < ActiveRecord::Base
include Compartido
belongs_to :metaservicio
has_many :servicios, :dependent => :destroy
validates_presence_of :nombre, :message => "no puede ir vacío"
validates_presence_of :metaservicio_id, :message => "no puede ir en blanco"
# Necesario para poder obtene... |
Container.boot(:logger) do |container|
start do
SemanticLogger.application = 'stasi-bot'
SemanticLogger.add_appender(io: STDOUT)
container.register(:logger, SemanticLogger['stasi-bot'])
end
end
|
class CreateQuestionnaireReports < ActiveRecord::Migration
def change
create_table :questionnaire_reports do |t|
t.string :title, null:false, limit:255
t.string :summary, null:false, limit:800
t.timestamps null: false
end
end
end
|
#require 'date'
class BloodOath
attr_accessor :initiation_date, :follower, :cult
@@all_oaths = []
def initialize (follower, cult, initiation_date = Date.today)
@follower = follower
@cult = cult
if initiation_date.class == Date
@initiation_date = "#{initiati... |
require "cat"
RSpec.describe Cat do
describe "#name" do
it "is super excited about its name" do
expect(Cat.new("Milo").name).to eq("Milo!!!")
end
end
describe "#speak" do
it "says meow" do
expect(Cat.new("Ninetales").speak).to eq("meow")
end
end
end
|
class Beer < ActiveRecord::Base
has_many :users, through: :associations
end
|
class CreateAnswers < ActiveRecord::Migration
def change
create_table :answers do |t|
t.string :value
t.references :reply, index: true, foreign_key: true
t.references :item, index: true, foreign_key: true
t.timestamps null: false
end
remove_column :replies, :answers, :jsonb
end
... |
class CreateParkingLists < ActiveRecord::Migration
def change
create_table :parking_lists do |t|
t.string :first_name
t.string :last_name
t.string :email
t.integer :spot_number
t.datetime :parked_on
t.timestamps
end
end
end
|
module LoremIpsumNearby
class Config
attr_writer :search_radius,
:search_radius_unit,
:data_file_path,
:center_point,
:result_sort_by,
:result_data_keys
# Matching customers within this radius
def search_radius
@search_radius ||= 100
end
# Matching customers w... |
# frozen_string_literal: true
FactoryBot.define do
factory :address do
line_1 { Faker::Address.street_address }
locality { Faker::Address.city }
administrative_area { Faker::Address.city }
postal_code { Faker::Address.postcode }
end
end
|
class QueueItem < ActiveRecord::Base
belongs_to :user
belongs_to :video
delegate :title, to: :video, prefix: :video
delegate :category, to: :video
validates_numericality_of :position, { only_integer: true }
def rating
review.rating if review
end
def rating=(new_rating)
... |
class ChangeCompanyTimezoneDatatype < ActiveRecord::Migration
def change
change_column :companies , :time_zone , :string
end
end
|
# frozen_string_literal: true
require "test_helper"
require_relative "common"
require "active_record"
class PostgresqlAdapterTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
def setup
database_config = { "adapter" => "postgresql", "database" => "activerecord_unittest" }
ar_tests = File... |
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
set :environment, "development"
set :output, "/home/richard/Rails/football_predictions/log/cron_log.log"
#Retrieve League Table
... |
class Notebook < ActiveRecord::Base
include PgSearch
multisearchable :against => [:title, :description]
validates :author_id, presence: true
belongs_to(
:author,
:class_name => 'User',
:foreign_key => :author_id,
:primary_key => :id
)
has_many :notes, dependent: :destroy
end
|
if ENV['HEROKU'].present?
keys = [:name,
:hostname,
:exception_notification_sender,
:exception_notification_recipient,
:mail__user_name,
:mail__password,
:mail__smtp__address,
:mail__smtp__port,
:mail__domain,
:storage,
... |
require 'rails_helper'
require 'dummy_opener'
RSpec.describe Nordnet::NumbersParser do
let(:dummy_opener) { DummyOpener.new }
let(:page) { Nokogiri::HTML(dummy_opener.call('__key_values__')) }
let(:parser) { described_class.new }
let(:good_call) { parser.call(page) }
it 'returns a StockDatum' do
expe... |
class Tester
class T1
def palindrome?(string)
# first implementation
# treat string as an array of characters
# 1. check edge cases first
# return false for non-strings and nil strings by checking length method
# 2. remove non-alphabet characters from string
# create a new... |
#---
# Excerpted from "Rails 4 Test Prescriptions",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit ... |
# 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... |
require 'rails_helper'
describe User, type: :model do
describe 'validations' do
it {should validate_presence_of :email}
it {should validate_presence_of :api_key}
it {should validate_presence_of :password}
end
describe 'instance_methods' do
it '#create_key' do
user = User.new(
ema... |
FactoryGirl.define do
factory :task do
name "Task01"
status 0
description "A simple task."
end
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :sw_project_customer_qnax_role_access_right, :class => 'SwProjectCustomerQnax::RoleAccessRight' do
user_role_id 1
action "MyString"
resource "MyString"
brief_note "MyString"
last_updated_by_id 1
e... |
class ResumevidsController < ApplicationController
def create
@member=Member.find(params[:member_id])
@resumevid=@member.resumevids.create(params[:resumevid])
respond_to do |format|
if @resumevid.save
format.html { redirect_to edit_member_path(@member), :notice => 'Video was successfully add... |
# == Schema Information
#
# Table name: appreciations
#
# id :bigint not null, primary key
# project_id :integer not null
# appreciator_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Appreciation < Ap... |
class AddPlanmodelToPlans < ActiveRecord::Migration[6.0]
def change
add_column :plans, :plan_content, :string
add_column :plans, :plan_time, :integer
end
end
|
require_relative '../app/models/legislator'
require_relative '../app/models/rep'
require_relative '../app/models/sen'
require_relative '../app/models/del'
require_relative '../app/models/com'
require 'csv'
class SunlightLegislatorsImporter
def self.import(filename)
csv = CSV.new(File.open(filename), :headers => ... |
class Api::V1::RidesController < ApplicationController
# Creates a new +Ride+ object, and update status of +CabStatus+.
# Assign nearest cab to +Ride+.
#
# API: POST /rides/{pink, source_latitude, source_longitude, dest_latitude, _dest_longitude}
#
# @return [cab_number] The created +Ride+
def crea... |
require 'rails_helper'
describe Verify::AddressController do
let(:user) { build(:user) }
before do
stub_verify_steps_one_and_two(user)
end
describe '#index' do
it 'redirects if phone mechanism selected' do
subject.idv_session.vendor_phone_confirmation = true
get :index
expect(resp... |
require 'base64'
require 'iron_mq'
# Backend for data pipeline that publishes to IronMQ
#
# Assumes the following env vars:
# - IRON_TOKEN=MY_TOKEN
# - IRON_PROJECT_ID=MY_PROJECT_ID
module RailsPipeline::IronmqPublisher
def self.included(base)
base.send :include, InstanceMethods
base.extend ClassMethods
... |
class Workshop < ApplicationRecord
belongs_to :DateLookup
belongs_to :Organization
end
|
require 'rails/generators'
require 'rails/generators/migration'
class ActsAsTaggableMigrationGenerator < Rails::Generators::Base
include Rails::Generators::Migration
def self.source_root
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end
def self.next_migrat... |
module Orocos
# This is hardcoded here, as we need it to make sure people don't use
# MQueues on systems where it is not available
#
# The comparison with the actual value from the RTT is done in
# MQueue.available?
TRANSPORT_MQ = 2
Port.transport_names[TRANSPORT_MQ] = 'MQueue'
# Suppor... |
require 'method_source'
class DelayedWorker
module Concern
def add_job_into_delayed_worker(
scheduled_at: nil,
job_name: 'Delayed worker',
subject_id: respond_to?(:id) ? id : nil,
subject_type: self.class,
params: {},
queue: 'default',
backtrace: false,
retry: 12,
... |
# frozen_string_literal: true
require File.expand_path('lib/divvyup/version')
Gem::Specification.new do |s|
s.name = 'divvyup'
s.version = DivvyUp::VERSION
s.summary = 'DivvyUp Worker Queue'
s.description = 'A simple redis-based queue system designed for failure'
s.authors = ['Jonathan Joh... |
json.array! @jobs do |job|
json.extract! job, :id, :title, :total_pay, :spoken_languages
end
|
class Category < ApplicationRecord
validates :name,
presence: true,
length: { minimum: 3, maximum: 30 },
uniqueness: true
has_many :sub_categories, dependent: :destroy
end |
class Topic < ApplicationRecord
extend FriendlyId
friendly_id :title, use: :slugged
validates_presence_of :title
#a data relationship is created by giving one data element the aspect of having many of another data element, as in the code line below, where we are saying that any topic will have many blogs attach... |
# encoding: utf-8
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# run... |
def letter_case_count(string)
stat = {lowercase: 0, uppercase: 0, neither: 0}
string.chars.each do |letter|
case letter
when /[a-z]/
stat[:lowercase] += 1
when /[A-Z]/
stat[:uppercase] += 1
else
stat[:neither] += 1
end
end
return stat
end
puts letter_case_count('abCdef 123... |
class Post < ApplicationRecord
has_one_attached :image
belongs_to :category, optional: true
belongs_to :user, optional: true
has_many :adds
has_many :users_added, through: :adds, source: :user
end
|
module Square
# WebhookSubscriptionsApi
class WebhookSubscriptionsApi < BaseApi
# Lists all webhook event types that can be subscribed to.
# @param [String] api_version Optional parameter: The API version for which
# to list event types. Setting this field overrides the default version used
# by the... |
# Copyright 2016 OCLC
#
# 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 writing, software
# ... |
class ChangeDefaultValueOfEnquiries < ActiveRecord::Migration
def change
change_column :enquiries, :boat_currency_rate, :float, default: 1
end
end
|
class Company < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :requirements, dependent: :destroy
has... |
class Edge
attr_reader :from, :to, :cost
def initialize(from, to, cost)
@from = from
@to = to
@cost = cost
end
def to_s
"#{@from} ---> #{@to}, with #{@cost} weight."
end
end
|
class Category < ActiveRecord::Base
has_many :products
has_many :category_childs,
class_name: 'Category',
foreign_key: 'category_parent_id'
belongs_to :category_parent,
class_name: 'Category',
foreign_key: 'category_parent_id'
end
|
class CreateResourceSubwayLines < ActiveRecord::Migration
def change
create_table :resource_subway_lines do |t|
t.references :resource, null: false
t.references :subway_line, null: false
t.timestamps
end
add_index :resource_subway_lines, :resource_id
add_index :resource_subway_lines... |
require 'logger'
require_relative 'private_gem_server/version'
require_relative 'private_gem_server/server'
require_relative 'private_gem_server/scanner'
require_relative 'private_gem_server/sources'
require_relative 'private_gem_server/sanity'
module PrivateGemServer
class << self
attr_writer :logger
de... |
class CreateMrclDetailRecords < ActiveRecord::Migration
def change
create_table :mrcl_detail_records do |t|
t.integer :representative_number
t.integer :representative_type
t.integer :record_type
t.integer :requestor_number
t.string :policy_type
t.integer :policy_number
t.... |
class Product < ApplicationRecord
belongs_to :supplier
belongs_to :category
has_many :images
has_many :orders
has_many :category_products
has_many :categories, through: :category_products
validates :name, presence: true
def is_discounted?
price <= 300
end
def tax
price * 0.09
end
def ... |
class Subscription < ApplicationRecord
belongs_to :subscriber
belongs_to :magazine
end
|
#!/usr/bin/ruby
require 'net/http'
require 'digest'
require 'uri'
require 'openssl'
require 'base64'
require 'digest/md5'
require 'rexml/document'
class Create_Header
def initialize(access_key, secret_key)
@access_key = access_key
@secret_key = secret_key
end
def create_sign_str(http_metho... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.