text
stringlengths
10
2.61M
class AddAssociationsBetweenTransactionsAndSubmissions < ActiveRecord::Migration[6.0] def change add_reference :transactions, :submission, type: :uuid end end
class Order < ApplicationRecord validates :address, :name, presence: true has_many :order_items, dependent: :destroy belongs_to :customer, optional: true enum order_status: { wait: 0, payment: 1, make: 2, preparing: 3, done: 4 } enum payment: { card: 0, bank: 1 } VALID_POSTAL_CODE_REGEX...
require 'rake/clean' require 'rspec/core/rake_task' require 'maestro/plugin/rake_tasks' require 'json' # to merge manifests $:.push File.expand_path('../src', __FILE__) CLEAN.include('manifest.json', '*-plugin-*.zip', 'vendor', 'package', 'tmp', '.bundle', 'manifest.template.json') task :default => :all task :all =>...
# # top-fans will take a stdin list of collapsed graphs (see note-collapse) # read through the posts, and then print out the top rebloggers # and fans from all those in stdin. # # By using stdin, this allows one to read over multiple blogs. # require 'rubygems' require 'bundler' Bundler.require def find_similar(list) ...
# -*- coding: utf-8 -*- require 'rspec' require 'catan' require 'colorize' describe Board do let(:game) { Game.new()} subject(:board) { Board.new(game) } context "after initialization" do it "has the right amount of roads" do expect(board.rds.count).to eq(72) end it "has the right amount of ...
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) Given /^I am not logged in$/ do end Then /^I should see a link to "([^\"]*)"$/ do |text| response.should have_selector("a", :content => text) end Then /^I should see an? "([^\"]*)" field$/ do |label| field_labeled(label).should...
require File.join(File.dirname(__FILE__), 'setup') require 'active_support/test_case' require 'logger' active_record_spec = Gem::Specification.find_by_name("activerecord") active_record_path = active_record_spec.gem_dir $LOAD_PATH << File.join(active_record_path, "test") module SlimScrooge class Test class << s...
class Dog attr_accessor :name, :breed, :age, :bark, :favorite_foods def initialize(name,breed,age,bark,favorite_foods) @name = name @breed = breed @age = age @bark = bark @favorite_foods = favorite_foods end def bark if @age<=3 return @bark.d...
feature 'Hit points' do scenario "I can see player 2's hit points" do sign_in_and_play expect(page).to have_content "Guilliman: 60/60hp" end end
class CreateInvoices < ActiveRecord::Migration def change create_table :invoices do |t| t.string :name t.string :address1 t.string :address2 t.string :num_ext t.string :num_int t.string :state t.string :city t.string :country t.string :rfc t.string :cp ...
require 'date' Gem::Specification.new do |s| s.name = 'git-run' s.version = '0.0.0' s.date = Date.today.to_s s.summary = "git run" s.description = "git run runs commands in git revisions" s.authors = ["Jeff Kreeftmeijer"] s.email = 'jeff@kreeftmeijer.nl' s.files = ...
class PetPersonality < ApplicationRecord belongs_to :pet validates :personality, presence: true enum personality: { ใŠใจใชใ—ใ„: 1, ใ•ใฟใ—ใŒใ‚Š: 2, ใ‚„ใ‚“ใกใ‚ƒ: 3, ใ‹ใ—ใ“ใ„: 4, ใฎใ‚“ใ: 5, ใŠใใณใ‚‡ใ†: 6, ใใพใใ‚Œ: 7, ไธ–่ฉฑๅฅฝใ: 8, ๅ…ƒๆฐ—: 9, ้ฃŸใ„ใ—ใ‚“ๅŠ: 10 } end
# frozen_string_literal: true module SystemCtl class ExperimentalRunInfoGenerator def initialize(commandline) @commandline = commandline end def run_info(service_id) snapshot = run_snapshot { user: snapshot.key?(service_id) ? snapshot[service_id] : nil, status: snap...
# frozen_string_literal: true module API module Exceptions class AuthenticationError < StandardError; end def self.included(base) base.rescue_from AuthenticationError do |e| message = e.message == e.class.name ? 'Wrong email or password' : e.message error!({ errors: message }, 401, 'Con...
RSpec.feature "Users can add a collaboration type for an activity" do let(:user) { create(:beis_user) } let(:activity) { create(:programme_activity, :at_collaboration_type_step, organisation: user.organisation) } before { authenticate!(user: user) } after { logout } context "when the user creates a new acti...
require 'rails_helper' require 'givdo/facebook/paginated_connections' RSpec.describe Givdo::Facebook::PaginatedConnections, :type => :lib do let(:params) { {:param => 'value'} } let(:graph) { double } subject { Givdo::Facebook::PaginatedConnections.new(graph, 'my_connections', params) } describe '#list' do ...
require 'benchmark' require_relative 'lib/activesupport/cache/elasticsearch_store' REPEATS = 500 def assert a, b if a != b $stderr.puts "a: #{a.inspect} b: #{b.inspect}" raise "a != b" end end def bench name, count, store puts "#{name}: #{count} actions per run" array_1k = ["a"] * 1024 array_20k =...
module Yaks class Format class CollectionJson < self register :collection_json, :json, 'application/vnd.collection+json' include FP # @param [Yaks::Resource] resource # @return [Hash] def serialize_resource(resource) result = { version: "1.0", items: ser...
class Admin::CategoriesController < ApplicationController layout 'admin' before_filter :require_http_basic_auth def index @categories = Category.order("position") end def new @category = Category.new end def edit @category = Category.find(params[:id]) end def update @category = Category.find(params...
require File.join(File.dirname(__FILE__), 'gilded_rose') describe GildedRose do describe '#update_quality' do it 'does not change the name' do items = [Item.new('foo', 0, 0)] GildedRose.new(items).update_quality expect(items[0].name).to eq 'foo' end it 'quality of an item is never nega...
class AddActiveDatesToProductionUnits < ActiveRecord::Migration def change add_column :production_units, :active_start_date, :date add_column :production_units, :active_end_date, :date end end
class CreateComments < ActiveRecord::Migration def change create_table :comments do |t| t.text :content, :null => false t.timestamps t.references :user t.references :article, :null => false end add_foreign_key(:comments, :users, :depe...
require 'easy_extensions/easy_scheduler' module EasyExtensions module SchedulerTasks class GitFetcherTask < EasyExtensions::EasySchedulerTask def initialize(options={}) super('git_fetcher_task', options) end def execute logger.info 'GitFetcherTask excuting...' if logger ...
require 'spec_helper' describe Kassociation do describe "Join Class" do before( :all) do @app = App.create( :name => "business") @person = @app.klasses.create( :name => "Person" ) @company = @app.klasses.create( :name => "Company") @jassoc = @app.kassociations.create( :typus => "join", :source => @pers...
require_relative './game_teams' require_relative './game' require_relative './team' require_relative '../modules/game_methods' require_relative '../modules/league_methods' require_relative '../modules/team_methods' require_relative '../modules/team_helper_methods' require_relative '../modules/season_methods' require_re...
json.array!(@internal_messages) do |internal_message| json.extract! internal_message, :id json.url internal_message_url(internal_message, format: :json) end
class CommentsController < ApplicationController before_action :authenticate_user! before_action :set_context, only: :create before_action :set_question, only: :create after_action :publish_comment, only: :create authorize_resource def create @comment = @context.comments.new(comment_params) @comm...
class CreateDocumentOwners < ActiveRecord::Migration[5.1] def change create_table :document_owners do |t| t.references :document, foreign_key: true t.string :owner_name t.string :owner_email t.timestamps end end end
feature 'attack' do scenario "attack player 2" do sign_in_and_play click_link "Attack" expect(page).to have_content "Angron attacked Guilliman" end scenario 'Attack reduces player 2s hit points by 10' do sign_in_and_play click_link "Attack" click_link "Ok" expect(page).not_to have_con...
module Repositories module Companies class Memory def initialize @companies = {} @next_id = 1 end def clear initialize end def save(company) if company.id update_existing(company) else create(company) end c...
class TopicResource < JSONAPI::Resource attributes :title, :progress, :objectives, :unit, :subject has_one :unit has_many :objectives has_many :problems def progress user = context[:current_user] return @model.progress(user) end filters :title, :unit_id end
class Ships < ActiveRecord::Migration[4.2] def change create_table :ships do |t| t.string :type_class t.string :sub_class t.decimal :top_speed t.integer :crew t.string :affiliation t.integer :agent_id t.string :note end end end
require "rails_helper" RSpec.describe ChatroomsController, type: :routing do describe "routing" do it "routes to #index" do expect(get: "/chatrooms").to route_to("chatrooms#index") end it "routes to #new" do expect(get: "/chatrooms/new").to route_to("chatrooms#new") end it "routes t...
# frozen_string_literal: true require_relative 'snapshot' # Helpers in Filewatcher class itself class Filewatcher class << self def system_stat(filename) case Gem::Platform.local.os when 'linux' then `stat --printf 'Modification: %y, Change: %z\n' #{filename}` when 'darwin' then `stat #{filena...
def roll_call_dwarves(dwarves) dwarves.each.with_index(1) do |dwarf, index| puts "#{index}. #{dwarf}" end end def summon_captain_planet(planeteer_calls) planeteer_calls.map { |call| call.capitalize + "!" } end def long_planeteer_calls(calls) calls.any? do |call| call.length > 4 end end def find_th...
require 'net/http' module Openfoodfacts class User < Hashie::Mash class << self # Login # def login(user_id, password, locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN) path = 'cgi/session.pl' uri = URI("https://#{locale}.#{domain}/#{path}") params = { "jqm" =>...
module BookKeeping VERSION = 3 end class Squares def initialize(n) @number_list = (0..n).to_a end def square_of_sum square = @number_list.reduce(:+)**2 square end def sum_of_squares sum = @number_list.map { |n| n**2 }.reduce(:+) sum end def difference square_of_sum - sum_of_squar...
# -*- mode: ruby -*- Vagrant.require_version ">= 2.2.6" Vagrant.configure("2") do |config| # The Zulip development environment runs on 9991 on the guest. host_port = 9991 http_proxy = https_proxy = no_proxy = nil host_ip_addr = "127.0.0.1" # System settings for the virtual machine. vm_num_cpus = "2" vm...
Pod::Spec.new do |s| # โ€•โ€•โ€• Spec Metadata โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€• # s.name = "SJLineRefresh" s.version = "1.1.6" s.summary = "A easy customizable shape pull-to-refresh view in UIScrolView." s.swift_version = '5' s.description = <<-DESC ...
class AddRemainingstoriesToSprints < ActiveRecord::Migration[5.1] def change add_column :sprints, :remainingstories, :integer,default: 0 end end
# Author:: Lucas Carlson (mailto:lucas@rufy.com) # Copyright:: Copyright (c) 2005 Lucas Carlson # License:: LGPL require "set" module ClassifierReborn module Hasher extend self # Removes common punctuation symbols, returning a new string. # E.g., # "Hello (greeting's), with {braces} < >...?...
# -*- encoding : utf-8 -*- # Kontroler wystawiajฤ…cy usล‚ugi dla klienta mobilnego jak i interfejsu webowego # # Umoลผliwia zgล‚oszenie uszkodzenia i pobieranie aktualnych danych kategorii. # class ServicesController < ApplicationController skip_before_filter :require_login layout false # POST /res/issue # POST ...
class StoriesController < ApplicationController before_action :load_story, only: [:show, :export, :flag] before_action :load_my_story, only: [:update, :delete] def show render_json @story end def update pushed_user_ids = @story.update(update_params) # Notify the users to whose feed this story ...
require 'todobot/services/commands/help_command_service' require 'todobot/services/commands/start_command_service' require 'todobot/services/tasks/create_task_service' require 'todobot/services/lists/create_list_service' require 'todobot/services/lists/show_list_service' require 'todobot/services/lists/show_lists_servi...
module Mastermind class Provider autoload :Mock, 'mastermind/provider/mock' autoload :Server, 'mastermind/provider/server' autoload :Notification, 'mastermind/provider/notification' autoload :Remote, 'mastermind/provider/remote' autoload :CM, 'mastermind/provider/cm' attr_accessor :resource, ...
# Use Enumerable#map to iterate over numbers and return an array containing each number divided by 2. Assign the returned array to a variable named half_numbers and print its value using #p. numbers = { high: 100, medium: 50, low: 10 } half_numbers = numbers.map {|k,v| v / 2} p half_numbers # LS Discussion #...
class Chakra < ActiveRecord::Base has_many :goddesses, :order => :number validates_presence_of :name, :description, :colour end
require "test_helper" class PaywhirlTest < Minitest::Test def test_that_it_has_a_version_number refute_nil ::Paywhirl::VERSION end end
require 'roo' require 'coercell/value' module Coercell class Parser def initialize(model) @model = model end def prepare_content(start=2) @content ||= (start..spreadsheet.last_row).collect do |line| content_line = {} titles.each do |title| content_line[title[:value...
desc "Removes the cached (public) images/javascript/stylesheets themes folders" task :theme_remove_cache do ['images', 'javascripts', 'stylesheets'].each do |type| path = "#{RAILS_ROOT}/public/#{type}/themes" puts "Removing #{path}" FileUtils.rm_r path, :force => true end end
require "test_helper" class IncidentsControllerTest < ActionController::TestCase def setup @incident = incidents(:one) end def test_index get :index assert_response :success assert_not_nil assigns(:incidents) end def test_show get :show, id: @incident assert_response :success end...
class AddUsersSeatsTable < ActiveRecord::Migration[5.2] def up create_join_table :users, :seats remove_column :users, :seat_id change_column :hosts, :flags, :text end def down drop_table :users_seats add_column :users, :seat_id, :integer change_column :hosts, :flags, :string end end
=begin input: string output: array rules: return a list of all substrings; need to be arranged by position when position is the same, they are ordered by length algorithm: set list to [] set count to 0 first loop to get all the substring starting from first letter add those to the list first then increase the...
module SPV # Converts list with fixture names into list of # SPV::Fixture objects. class Fixtures class Converter def self.convert_raw(raw_list) raw_list.map do |item| if item.kind_of?(String) Fixture.new(item) else Fixture.new(item[:fixture], item[:op...
require_relative "spec_helper" describe LineUnit do it "parses nested italic and bold" do assert_equal 'outside<b><i>i</i>b</b>', parse('outside***i*b**').join end it "parses code" do assert_equal '<code class="highlight">\\\\code</code>', parse('`\\\\code`').join assert_equal '<code class="highligh...
Write a method that takes a string, and returns a new string in which every consonant character is doubled. Vowels (a,e,i,o,u), digits, punctuation, and whitespace should not be doubled. Examples: double_consonants('String') == "SSttrrinngg" double_consonants("Hello-World!") == "HHellllo-WWorrlldd!" double_consonants...
Pod::Spec.new do |s| s.name = 'BPushSDK' s.version = '0.0.1' s.summary = 'Baidu Push SDK for iOS.' s.homepage = 'https://github.com/heenying/BpushSDK' s.license = { :type => 'Copyright', :text => 'LICENSE ยฉ2015-2017 Baidu, Inc. All rights reserved' } s.author = { 'heenying' => 'https://...
class FavoritesController < ApplicationController before_filter :authenticate_user! def create @follower_id = current_user.id @item_type = params[:favorite][:item_type] @item_name = params[:favorite][:item_name] @item_path = params[:favorite][:item_path] # use different parameters to distingu...
describe LtreeRails::Configuration do let(:configuration) { LtreeRails::Configuration.new } let(:configurable_options) { LtreeRails::Configuration::CONFIGURABLE_OPTIONS.keys } let(:configurable_options_defaults) { LtreeRails::Configuration::CONFIGURABLE_OPTIONS.values } it 'provides getter for all options from...
class AddPriceBoughtToStocks < ActiveRecord::Migration def self.up add_column :stocks, :bought_at, :decimal, :default => 0, :precision => 12, :scale => 2 end def self.down remove_column :stocks, :bought_at end end
def nyc_pigeon_organizer(data) data.each_with_object({}) do |(category, trait), new_list| trait.each do |value, names| names.each do |name| new_list[name] ||= {} new_list[name][category] ||= [] new_list[name][category] << value.to_s end end end end
# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure(2) do |config| # The most comm...
module Cocoadex class Function < SequentialNodeElement attr_reader :abstract, :declaration, :declared_in, :availability, :return_value TEMPLATE_NAME=:method def parameters @parameters ||= [] end def discussion "" end def handle_node node if node.classes.include?...
class AddPasswordDigestToUsers < Mongoid::Migration def change add_column :users, :password_digest, :string end def self.up end def self.down end end
class PeopleController < ApplicationController # before_action :set_authentication require 'rest-client' EMAIL = "sid@gmail.com" PASSWORD = "123456" API_BASE_URL = "http://localhost:3000" def index url_u = "#{API_BASE_URL}/people.json" rest_cli = RestClient::Resource.new(url_u...
require 'rails_helper' describe AuditStructureCreator do let!(:audit) { create(:audit) } let(:audit_audit_strc_type) { audit.audit_structure.audit_strc_type } it 'creates a structure record' do audit_strc_type = create(:audit_strc_type, parent_structure_type: audit_audit_strc_typ...
require_relative "lockbox_transform" require "test/unit" class LockboxTransformTestWithSimpleSample < Test::Unit::TestCase def setup @lt = LockboxTransform.new() @data = "Title: my bank account\nInformation: line1\nCategory: Bank Account\nNotes: line1\n" end def test_that_it_understands_sam...
class CreateEasyAttendanceActivities < ActiveRecord::Migration def self.up create_table :easy_attendance_activities do |t| t.column :name, :string, :null => false t.column :position, :integer, :null => true, :default => 1 t.column :at_work, :boolean, :default => false t.column :is_default,...
# Copyright ยฉ 2011-2019 MUSC Foundation for Research Development~ # All rights reserved.~ # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~ # 1. Redistributions of source code must retain the above copyright notice, this l...
class DropDebitCreditHrefFieldsFromRentals < ActiveRecord::Migration def change remove_column :rentals, :debit_href remove_column :rentals, :credit_href end end
require_relative "../linked_list.rb" RSpec.describe LinkedList, "#append" do node1 = "node1" node2 = "node2" node3 = "node3" node4 = "node4" node5 = "node5" node6 = "node6" list = LinkedList.new(node1) context "#append" do it "adds a new node to start of the list" do expect(list.head.valu...
class Cocktail < ApplicationRecord has_many :ingredients, through: :doses has_many :doses validates :name, presence: true, uniqueness: true before_destroy :destroy_all_doses protected def destroy_all_doses self.doses.each { |dose| dose.destroy } end end
require 'spec_helper' return unless defined?(Rack) RSpec.describe Sentry::Rack::CaptureExceptions, rack: true do let(:exception) { ZeroDivisionError.new("divided by 0") } let(:additional_headers) { {} } let(:env) { Rack::MockRequest.env_for("/test", additional_headers) } describe "exceptions capturing" do ...
require 'rails_helper' describe Location do it 'is created when all attributes are valid' do expect(build(:location)).to be_valid end it 'requires a state' do expect(build(:location, state_id: '')).to be_invalid end it 'correctly references the state it\'s in' do create(:state) sample = cre...
#!/usr/bin/env ruby # run committed files against the ruby style guide. require 'open3' stdout, stderr, status = Open3.capture3("git diff --name-only --cached | grep -E '#{%w[rb rake].map{|ext| '\.' + ext}.join('|')}' ") modified_files = stdout.split(/\n/) if modified_files.count > 0 $stdout.puts("Code conventions: ...
require('minitest/autorun') require('minitest/rg') require_relative('../Song.rb') class SongTest < MiniTest::Test def test_song_title song1 = Song.new("Waterloo","Abba") assert_equal("Waterloo",song1.title) end def test_song_artist song1 = Song.new("Waterloo","Abba") assert_equal("Abba",song1.a...
Bball::Application.routes.draw do root :to => "home#index" match "app" => "dash#index" resources :games resources :teams do resources :players end end
class Backoffice::ContactInfosController < Backoffice::BackofficeController def index @contact_infos = ContactInfo.order(active: :desc).order(:id) end def new @contact_info = ContactInfo.new end def create @contact_info = ContactInfo.new(info_params) if @contact_in...
require "spec_helper" feature "Signing out" do before do user = Factory(:confirmed_user) sign_in_as!(user) end scenario "Signing out a user" do visit "/" click_link "Sign out" page.should_not have_content("Signed in as") end end
require File.expand_path(File.dirname(__FILE__) + "/qna_test_helper") describe "AdminTest" do include QnaTestBase before :each do init_qna_pages @product = product @asker = user @super_user = super_user @qa_admin = qa_moderator end it "verify if the answers moderation link is...
require "date" class Todo def initialize(text, due_date, completed) @text = text @due_date = due_date @completed = completed end def to_displayable_string if @completed==false puts (@text.to_s + ': ' + @due_date.to_s + ': ' + @completed.to_s) ...
Pod::Spec.new do |s| s.name = 'ElementaryCyclesSearch' s.version = '0.4.0' s.summary = 'Elementary Circuits of a Directed Graph' s.description = <<-DESC The implementation is pretty much generic, all it needs is a adjacency-matrix of your graph and the objects of your nodes. T...
#### # # module Contact # # The system follows entities with an address this wraps up the relationship # # Contact is used by Property, Client and Agent. # Contact includes entities and an address. #### # module Contact extend ActiveSupport::Concern include Entities included do accepts_nested_attributes_for :...
class BillSearch include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :start, :end PAGE_SIZE = 15 def initialize(args = {}) @start = args[:start] @end = args[:end] end def retrieve_bills(username) rds = RdsClient.new bills = rds.get_user_bills(username, @start, @...
class Mockup < ActiveRecord::Base enum status: { active: 0 } belongs_to :raw_image belongs_to :user belongs_to :project validates_presence_of :user, :project validates_associated :raw_image, :user, :project validates :name, length: { in: 0..100 } validates :name, format: { with: /\A[a-zA-Z0-9\s]+\z/,...
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'liquid_constant_contact/version' Gem::Specification.new do |spec| spec.name = "liquid_constant_contact" spec.version = LiquidConstantContact::VERSION spec.authors = ["E...
require 'test_helper' class Admin::LecturesControllerTest < ActionController::TestCase include Devise::TestHelpers def setup @controller = Admin::LecturesController.new john_smith = User.find_by_email("john.smith@mmu.ac.uk") sign_in john_smith end test "should get index" do get :index ...
# frozen_string_literal: true require 'spec_helper' describe Dotloop::Template do let(:client) { Dotloop::Client.new(access_token: SecureRandom.uuid) } subject(:dotloop_template) { Dotloop::Template.new(client: client) } describe '#initialize' do it 'exist' do expect(dotloop_template).to_not be_nil ...
#This is to synchronize the ids of file groups and collections with production as needed for DLS tests on pilot # This class is to handle doing the database/solr work of changing the ids. A small amount of file system manipulation # will also be necessary to move the actual content. class Temp::IdSynchronizer attr_a...
json.array!(@compras) do |compra| json.extract! compra, :id, :user_id, :proveedor_id, :fecha, :estado json.url compra_url(compra, format: :json) end
module Roby module DRoby module V5 # Cross-instance identification of an object class RemoteDRobyID # The peer on which the object is known as {#droby_id} # # @return [PeerID] attr_reader :peer_id # The ...
class Person def initialize(person_name) @name=person_name end def name=(person_name) @name=person_name end def name @name end end mike=Person.new("MIKE") # # mike.name= "MIKE" mike.name
class AddAwesomeToUsers < ActiveRecord::Migration def change remove_column :users, :first_time_omniauth, :integer add_column :users, :awesome, :integer end end
class Account < ApplicationRecord has_many :transactions, class_name: "AccountTransaction", foreign_key: "recipient_account_id" has_many :transfered_transactions, class_name: "AccountTransaction", foreign_key: "origin_account_id" belongs_to :owner, polymorphic: true validates :currency, :account_type, ...
require File::join( File::dirname(__FILE__), %w{ .. .. spec_helper } ) ruby_version_is "1.9" do require File::join( File::dirname(__FILE__), %w{ shared behavior } ) MyBO = Class::new BasicObject describe "BasicObject's subclasses behave" do extend BasicObjectBehavior it "privately" do MyBO.priva...
require 'sinatra/base' require 'battleships' require_relative 'game' require_relative 'random_ships.rb' class BattleshipsWeb < Sinatra::Base set :views, proc { File.join(root, '..', 'views') } # start the server if ruby file executed directly run! if app_file == $0 get '/' do erb :index end get '/ne...
class UserMailer < ActionMailer::Base def account_created(company, user, creator, password, login_url) from(SMTP_FROM) recipients(user.email) subject("#{company.name}: Your user account was created") body(:user => user, :creator => creator, :password => password, :login_url => login_url) end def...
class AddPlatformRegionToOAuthAccounts < ActiveRecord::Migration[5.1] def change add_column :oauth_accounts, :platform, :string, limit: 3, default: 'pc', null: false add_column :oauth_accounts, :region, :string, limit: 6, default: 'us', null: false end end
module TweetsHelper def link_to_tweets_page return unless @page_link page = params[:page] page = page.nil? ? 1 : page.to_i url = request.env['PATH_INFO'] url += '?query=' + params[:query] if params.has_key?(:query) if (page > 1 and page == 2) ret = link_to('PageUp', url) elsif (...
class ApplicationController < ActionController::Base def blank_square_form render({:template => "calculation_templates/square_form.html.erb"}) end end