text stringlengths 10 2.61M |
|---|
require 'csv'
module RideShare
class Rider
attr_reader :id, :name, :phone_num
def initialize(args)
@id = args[:id]
@name = args[:name]
@phone_num = args[:phone]
@trips = []
@drivers = []
end
def trips
@trips ||= Trip.find_by_rider(@id)
end
def drivers
... |
require_relative '../../config'
# This is where you should use an ActiveRecord migration to
# HINT: checkout ActiveRecord::Migration.create_table
class CreateTeachers < ActiveRecord::Migration
def up
create_table :teachers do |t|
t.string :name
t.string :email
t.string :address
t.string... |
module OmniAuth
module Strategies
class GoogleOauth2
def get_access_token(request)
raise "request '#{request}'"
json = JSON.parse(request.body.read)
json = json.dup.deep_transform_keys { |key| key.to_s.underscore }
raise "invalid token '#{json['access_token']}'" unless verify... |
class Gamey::Input
class Action
attr_reader :name
def initialize(name)
@name = name
@state = false
@last_state = false
end
def pressed?
@state
end
def released?
!@state
end
... |
class AddFinishDateToChallenges < ActiveRecord::Migration[5.0]
def change
add_column :challenges, :finish_date, :date
end
end
|
BudgetCalculator::Application.routes.draw do
resources :budgets
root to: "budgets#new"
end
|
require 'digest/md5'
module MoneyMoney
#
# this is a representation of one line in a csv statement
# with translated, parsed attributes (cents, date, etc.).
#
class StatementLine
include MoneyStringParser
ATTRIBUTE_MAPPING = {
currency: "Währung",
amount: "Betrag",... |
class ItemgroupsController < ApplicationController
before_filter :signed_in_user
def create
@itemgroup = current_user.itemgroups.build(params[:itemgroup])
if @itemgroup.save
flash[:success] = "Collection created!"
redirect_to root_url
else
render 'static_pages/splash'
end
end
... |
class BankTransaction < ActiveRecord::Base
belongs_to :bank_statement
has_many :reconciliations, class: BankReconciliation
def reconciled?
!!reconciliation && reconciliation.persisted?
end
end
|
require 'spec'
require File.join(File.dirname(__FILE__), "..", "lib", 'bowsr')
module TestObject
attr_reader :method_called, :args
def method_missing(name, *args)
@method_called = name
@args = args
end
end |
# frozen_string_literal: true
require 'testing_prerequisites'
# rubocop:disable Metrics/ClassLength, Metrics/MethodLength
class TestPngfyer < Minitest::Test
module TestClasses
class TestPngfyer < AsciiPngfy::Pngfyer
def test_settings
settings
end
end
end
attr_reader(
:test_pngfy... |
require 'test_helper'
class BiblioCommons::TitleTest < ActiveSupport::TestCase
def test_id_from_url
url = 'http://nypl.bibliocommons.com/item/show/17213885052907'
id = BiblioCommons::Title.id_from_url(url)
assert_equal '17213885052907', id
end
def test_id_from_url_invalid
url = 'http://www.nypl.... |
# frozen_string_literal: true
module SnowplowRubyDuid
# This is the configuration object that is used for two additional cookie settings
# that can't be deferred from the request/response objects
module Configuration
@allowed = %i[none lax strict]
@same_site = :lax
@secure = false
def self.same... |
# -*- coding: utf-8 -*-
#
# Author:: lnznt
# Copyright:: (C) 2011 lnznt.
# License:: Ruby's
#
require 'test/unit'
require 'gmrw/extension/array'
class TestFields < Test::Unit::TestCase
def try_assert_equal(tests)
tests.each_with_index do |test, i|
actual, expected = test.first
assert_equal(expected,... |
require "tapioca/test_helpers/version"
require "action_view"
require "action_view/helpers"
require "action_view/helpers/javascript_helper"
module Tapioca
module TestHelpers
extend ActionView::Helpers::TagHelper
extend ActionView::Helpers::JavaScriptHelper
# Public: generates JavasCript code to disable a... |
RSpec::Matchers.define :match_rack_response do |code, headers, body|
match do |actual|
(actual[0].should == code) &&
(actual[1].should RSpec::Matchers::BuiltIn::Include.new(headers)) #&&
(actual[2].should RSpec::Matchers::BuiltIn::Include.new(body))
end
end
|
def full_title ( page_title )
base_title = "Survey Ninja"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end |
require "test_helper"
class TransactionsControllerTest < ActionDispatch::IntegrationTest
setup do
@transaction_alessandro = transactions(:salary)
@transaction_gorete = transactions(:pet_shop)
@alessandro = users(:alessandro)
log_in_as @alessandro
end
test "should get index" do
get transactio... |
class Question < ActiveRecord::Base
attr_accessible :poll_id, :body
validates :poll_id, :presence => true
validates :body, :presence => true
has_many(:responses,
:class_name => "Response",
:foreign_key => :question_id,
:primary_key => :id,
:dependent => :de... |
# Write a method that takes one argument,
# a positive integer, and returns a list of the digits in the number.
# creat a method definition with one perameter, 'number'
# could use the #digits method with a reverse
# OR use to_s, chars to create and array of seperated numbers
#
# def digit_list(number)
# number.t... |
class Asciifyier
CHAR_LIST = ' .,:;i1tfLCG08@'.split('').reverse
CHAR_LIST_LENGTH = CHAR_LIST.length - 1
def initialize(canvas)
@canvas = canvas
@width = canvas.width
@height = canvas.height
end
def asciify
output = ''
data = @canvas.data(0, 0, @width, @height)
(0...@height).each ... |
class Task < ApplicationRecord
has_many :taggings
has_many :tags, through: :taggings
validates_presence_of :title
validates :title, length: { maximum: 200 }
MAX_TAGS = 10
end
|
class AddStateofOriginToProfile < ActiveRecord::Migration[5.1]
def change
add_column :applicants, :state_of_origin, :string
end
end
|
Chess::Application.routes.draw do
devise_for :users
root :to => "home#index"
resources :games do
member do
get :export
end
end
end
|
#==============================================================================#
# ** IEX(Icy Engine Xelion) - Emblem System
#------------------------------------------------------------------------------#
# ** Created by : IceDragon (http://www.rpgmakervx.net/)
# ** Script-Status : Addon (Actors)
# ** Script Type ... |
RUBYFRIENDS_APP = RubyfriendsApp.new.tap do |app|
app.default_hashtag = "RubyFriends"
end
|
module Intent
class Search < Action
def initialize(entity)
super entity
@message = ''
add_cost :ap, 1
end
def take_action
item_drop = nil
item_drop = entity.location.type.search_roll_item if search_succeeded?
if item_drop === nil
message_ent = Entity::Message.new({characters: [entity.id]... |
class CreateVehicles < ActiveRecord::Migration
def change
create_table :vehicles do |t|
t.string :license_plate, null: false
t.belongs_to :vehicle_class, null: false, index: true, foreign_key: true
t.string :subtype
t.string :age
t.timestamps null: false
end
end
end
|
# ---------------------------------------
# Part 1
# ---------------------------------------
# Imagine we have an image.
# We’ll represent this image as a simple 2D array where
# every pixel is a 1 or a 0. The image you get is known
# to have a single rectangle of 0s on a background of 1s.
# Write a function that takes... |
class Attendance < ActiveRecord::Base
belongs_to :user
belongs_to :contest
has_many :submissions
def submissions_for(problem, type)
submissions.where(problem_id: problem.id, problem_type: type).first
end
def solved_submission_for(problem, type)
submissions.where(problem_id: problem.id, problem_ty... |
require File.expand_path('../../../spec_helper.rb', __FILE__)
packages = [
'apticron',
'bind9-host',
'bzip2',
'bsdutils',
'coreutils',
'cron',
'git-all',
'gnupg',
'iproute',
'logrotate',
'man-db',
'manpages',
'ntp',
'ntpdate',
'openjdk-7-jre-headless',
'o... |
require "minitest/autorun"
require_relative "panda.rb"
class Testpandafunctions < Minitest::Test
def test_class_returns_name
animal = Panda.new("poe")
assert_equal("poe",animal.name)
end
def test_class_returns_sound
animal = Panda.new("poe")
assert_equal("roar",animal.sound)
end
def test_class_returns_act... |
# Guest visit
Given(/^I am a guest$/) do
end
Given(/^I am a seller$/) do
@current_seller = Seller.create!(
:password => 'password',
:password_confirmation => 'password',
:email => "seller@example.com"
)
end
When(/^I login$/) do
visit "/login"
fill_in("Email", :with => 'seller@example.com')
... |
require 'pathname'
require 'aws-sdk-s3'
module Pdfsp
module Archiver
class ArchiverS3
class << self
def suitable?(settings_hash)
return false unless settings_hash.is_a? Hash
return false unless settings_hash.key?('type')
return false unless settings_hash['type'] == 's3'
return false unles... |
class AgentRegressionCheck < ApplicationRecord
include Positionable
positionable_ancestor :agent, touch: false
belongs_to :agent
enum spellchecking: [:inactive, :low, :medium, :high]
enum state: [:unknown, :success, :failure, :error, :running]
before_validation :clean_sentence
validates :sentence, len... |
# Large portions of this file are adapted from
# https://github.com/ffi/ffi/blob/master/lib/ffi/pointer.rb
module FFI
class Pointer
SIZE = 4
# Return the size of a pointer on the current platform, in bytes
# @return [Numeric]
def self.size
SIZE
end
# @param [nil,Numeric] len length of... |
class Player
attr_accessor :hand, :deck, :life_points, :name
def initialize(name, deck)
@name = name
@deck = deck
@hand = []
end
def draw
throw(:duel_end, "player '#{name}' LOST; ran out of cards") if @deck.empty?
@hand << @deck.shift
end
def shuffle!(sym)
send(sym).shuffle!
end... |
module Shoppe
module Kiwipay
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../../../templates", __FILE__)
desc "Creates Kiwipay initializer for your application"
def copy_initializer
template "kiwipay_initializer.rb", "con... |
require 'digest/sha2'
class User < ActiveRecord::Base
apply_simple_captcha
attr_protected :hashed_password, :enabled
attr_accessor :password
has_and_belongs_to_many :roles
has_and_belongs_to_many :performaces
has_and_belongs_to_many :papers
has_many :clubs
has_many :rates
has_many :questions
validates_... |
class HanoiGame
attr_accessor :towers
def initialize
@towers = [[1, 2, 3], [], []]
end
def render
towers_str = ""
self.towers.each do |tower|
towers_str << tower.inspect << "\n"
end
towers_str
end
def move(from, to)
raise ArgumentError if towers[from].empty?
if !towers[... |
class Machine < EventMachine::Connection
attr_reader :connected, :port_name, :port_info, :type, :model, :extruder_count,
:machine_info, :temperatures, :current_line, :printing, :paused,
:socket_info, :job_id, :segment
attr_accessor :uuid
def initialize(client, port_name)
s... |
# Cookbook Name:: nodejs
# Attributes:: default
#
# Copyright 2012 Flowdock Ltd.
#
# 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 ... |
require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/skip_dsl'
require_relative '../lib/online_order'
#_______________ WAVE 3 _______________
describe "OnlineOrder" do
#############################################################################################
# INITIALIZES OnlineOrder:
... |
FactoryBot.define do
factory :robot do
name 'Sophia'
# creates a random serial number
serial {SecureRandom.hex}
friendly true
inventor
end
end
# FactoryBot.create(:robot)
# FactoryBot.create(:robot, friendly: false)
# FactoryBot.create(:robot, friendly: false, name: 'Steve')
FactoryBot.cr... |
include 'line'
class GedcomParser
LINE_REGEX = /^(\d+)\s(@.+@|\b\S+\b)(.*)$/
def initialize file
@file = file
end
def parse
lines = []
@file.each do |line|
lines << Line.new(line.match(LINE_REGEX),@lines.last)
end
@file.close
lines
end
end |
require 'test_helper'
feature 'prioritize projects as an editor' do
scenario 'decrease project priority' do
editor_sign_in
visit project_path(projects(:mdp))
click_link 'Edit'
fill_in 'Priority', with: 3
click_on 'Update Project'
visit projects_path
Project.find(projects(:bp)).priority.m... |
if defined?(Logger)
class Logger
def format_message(severity, timestamp, progname, msg)
# If a newline is necessary then create a new message ending with a newline.
# Ensures that the original message is not mutated.
msg = "#{msg}\n" unless msg[-1,1] == "\n"
if msg !~ /\(pid\:/
ms... |
class CreateBundlings < ActiveRecord::Migration
def change
create_table :bundlings do |t|
t.references :bundle, :null => false
t.references :offer, :null => false
t.timestamps
end
add_index :bundlings, [:bundle_id, :offer_id], :unique => true
add_index :bundlings, :offer_id
end
end... |
class SeatingsController < ApplicationController
before_action :set_location
def show
@seatings = Seating.where(location_id: @location.id)
end
private
def set_location
@location = Location.find(params[:id])
end
end
|
# 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... |
module Authentication
extend ActiveSupport::Concern
included do
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
before_create :create_remember_token
before_save { email.downcase! }
has_secure_password
validates :username, :email, uniqueness: { case_sensitive: false }
va... |
class SessionsController < ApplicationController
get '/login' do
erb :'sessions/login'
end
post '/login' do
# if params[:user][:username].empty? || params[:user][:password].empty?
# flash[:error] = "Please fill in your username and password"
# redirect '/login'
# el... |
require 'csv'
require 'date'
# This file should contain all the record creation needed to seed the database with its default values.
# Region options: "north-rockies", "cariboos", "north-columbia", "south-columbia", "kootenay-boundary", "purcells", "lizard-range", "south-rockies", "kananaskis", "little-yoho", "jasper"?... |
# Greeting a user
# Write a program that will ask for user's name. The program will then greet the user. If the user writes "name!" then the computer yells back to the user.
puts "What is your name?"
name = gets.chomp()
if name.include? "!"
capitalize = name.upcase
# The solution uses ".chop" which is a bit clea... |
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Sliding Graphics
# Author: Kread-EX
# Version 1.0
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# TERMS OF USAGE
# #-------------------------------------------------------------------------------------... |
#
# Be sure to run `pod spec lint MemoryLeak.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
# To see working Podspecs in the CocoaPods repo see https://git... |
Hanami::Model.migration do
change do
create_table :accounts do
primary_key :id
column :email, String, unique: true, null: false
column :password_hash, String
end
# Used by the account verification and close account features
#
# create_table :account_statuses do
# primary_... |
class Product < ActiveRecord::Base
belongs_to :category
has_and_belongs_to_many :users
end
|
class Event < ActiveRecord::Base
# a. The events date is empty, in the past, or is not valid.
# b. The events title is already taken or empty.
# c. The event organizers name is empty.
# d. The event organizers email address is invalid.
# t.string :organizer_name, :organizer_email, :title
# t.date :date
valida... |
class EmployeesIsActiveDefaultTrue < ActiveRecord::Migration
def up
change_column :employees, :is_active, :boolean, default: true
Employee.all.each { |e| e.update_column(:is_active, true) }
end
def down
change_column :employees, :is_active, :boolean, default: nil
end
end
|
# frozen_string_literal: true
require 'paypal_client/version'
require 'paypal_client/errors'
require 'active_support/cache'
#
# Module PaypalClient provides an easy to use API client for the Paypal
# REST API https://developer.paypal.com/docs/api/overview/
#
# @author Dennis van der Vliet <dennis.vandervliet@gmail.co... |
require "formula"
class Appetize < Formula
homepage "https://github.com/YusukeIwaki/appetize-cli"
url "https://github.com/YusukeIwaki/appetize-cli/releases/download/v1.1.1/appetize_darwin_amd64"
sha256 "12875d28aaf8c00dbfcb5e5c54eace9b09e79bd324344b6e52b8c804293493f2"
head "https://github.com/YusukeIwaki/appet... |
class KeySerializer < ActiveModel::Serializer
attributes :code,
:label,
:position
end
|
require 'spec_helper'
include Devise::TestHelpers
describe 'Autorization' do
before :all do
DataFile.destroy_all
User.destroy_all
@user = FactoryGirl.create(:user)
@admin = FactoryGirl.create(:admin_user)
end
it 'change sign in link to sign out' do
login @user
response.should_not have_se... |
class AddFaelligkeitToDebits < ActiveRecord::Migration
def change
add_column :debits, :faelligkeit, :date
end
end |
require "spec_helper"
FROM_EMAIL = "mailer@example.com"
describe UserMailer do
describe 'email validation' do
let(:user) { FactoryGirl.create(:user, email_validation_token: "fooooobarrr") }
let(:mail) { UserMailer.email_validation_token(user) }
describe "send email validation token url" do
spe... |
require 'fakefs/safe'
require 'json'
Before do
FakeFS.activate!
end
After do
FakeFS::FileSystem.clear
FakeFS.deactivate!
end
def table_to_exons( table )
table_map = [
:splicing,
:start,
:stop,
:chromosome,
:mrnas
]
table.raw.map do |row|
params = Hash[table_map.zip(row)]
param... |
class SubjectCompetency < ActiveRecord::Base
attr_accessible :competency_id, :subject_id#, :learning_outcomes_attributes
belongs_to :subject
belongs_to :competency
# has_many :learning_outcomes, :dependent => :destroy
# accepts_nested_attributes_for :learning_outcomes, :allow_destroy => true
validates :c... |
class Genre < ApplicationRecord
has_many :products
enum genre_status: {
有効: 0, 無効: 1
}
end
|
class RenameOpinpnColumnToBooks < ActiveRecord::Migration[5.2]
def change
rename_column :books, :opinon, :opinion
end
end
|
#Building Class
class Building
attr_accessor :name, :address, :apartments
#hint apartments should be an array i.e @apartments = []
def initialize(name, address)
@address = address
@name = name
@apartments = []
end
def view_apartments
puts "Building #{@name} Apartment List"
@apartments.ea... |
# coding: utf-8
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'paytm_spree/version'
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'paytm_spree'
s.version = PaytmSpree::VERSION
s.summary ... |
class Api::V1::VendorsController < Api::V1::BaseApiController
def index
@vendors = Inventory::Vendor.where(:name => /^#{params[:filter]}/i).limit(7).map do |x|
{
value: x.id.to_s,
label: x.name,
vendor_no: x.vendor_no,
address: x.address,
state_license_num: x.state_li... |
require 'sinatra'
require 'json'
set :public_folder, 'public'
get '/' do
erb :index
end
post '/' do
content_type :json
command = params["command"][2..-1];
begin
io = IO.popen(command)
rescue SystemCallError => e
return {command: e}.to_json
end
if io
response = io.read
io.close
... |
require 'rspec'
require_relative 'tree'
describe TreeNode do
subject(:tree_root) do
TreeNode.new(1)
end
its(:parent) { should == nil}
its(:value) { should == 1 }
its(:children) {should == []}
describe "#add_child" do
let(:child) { TreeNode.new(10) }
it "adds a child node to the current node" do
t... |
class CreateUserAchievements < ActiveRecord::Migration
def change
create_table :user_achievements do |t|
t.references :user, null: false, index: true
t.references :achievement, null: false, index: true
t.timestamps null: false
end
add_foreign_key :user_achievements, :users, ... |
# frozen_string_literal: true
# Game
class Game < Interface
attr_accessor :player, :dealer, :game_over, :bank, :play_again, :deck, :interface
def initialize
game_greetings
@player = Player.new(gets.chomp)
valid_name
@dealer = Dealer.new
player_greetings
start_game
end
def start_game
... |
module Configent
module Utils
class Recurser
attr_accessor :pairs
def initialize(tree)
@pairs = {}
build_pairs_from tree
end
def build_pairs_from(tree, parent_key="")
tree.each_pair do |child_key, value|
if value.is_a?(Hash)
build_pairs_from(... |
class RemoveLocationFkNotNullConstraintFromJobs < ActiveRecord::Migration[6.0]
def change
change_column_null :jobs, :location_id, true
end
end
|
# 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 rails db:seed command (or created alongside the database with db:setup).
require 'faker'
# Lender objects
meg = Lender.create!(
email: "meg@meg.com",
password: "password"
)
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Comments', type: :request do
describe 'POST #create' do
let!(:user) { create(:user) }
let!(:avatar) { create(:avatar) }
context 'as a sign in user' do
before do
sign_in user
post api_v1_comments_path, params: { ... |
# frozen_string_literal: true
class AuthorizedUser < ActiveRecord::Base
belongs_to :group, class_name: 'UserGroup', inverse_of: :authorized_users
has_one :user, inverse_of: :authorized_user
validates :first_name, presence: true
validates :last_name, presence: true
validates :group, presence: true
validates... |
class ProductsController < ApplicationController
def index
@view = ProductView.new
end
end
|
class CreateLoans < ActiveRecord::Migration[6.1]
def change
create_table :loans do |t|
t.float :value
t.float :fee
t.integer :months
t.timestamps
end
end
end
|
require 'base64'
require 'openssl'
module ActiveMerchant
module Fulfillment
class AmazonService < Service
SERVICES = {
:outbound => {
:url => 'https://fba-outbound.amazonaws.com',
:xmlns => 'http://fba-outbound.amazonaws.com/doc/2007-08-02/',
:version => '2007-08... |
FIELD_MATCHER = /(?<name>.{3}):(?<value>.*)/
PASSPORTS = INPUT.split("\n\n").map do |data|
data.split(/\n| /).each_with_object({}) do |field, passport|
field_data = field.match(FIELD_MATCHER)
passport[field_data[:name]] = field_data[:value]
end
end
def between?(min, max)
->(value) { value.to_i >= min && ... |
require 'lib/tchat/command/command.rb'
require 'lib/tchat/user_connection.rb'
module TChat
module Command
class SigninCommand < Command
def self.command
"signin"
end
def self.description
"Authenticates a registered User with the system given an e-mail address and a password... |
#! env ruby
# Reorder/rewrite the psc file so content is sorted into the same order
# by entity/construct name. This is useful for comparing two sets of
# decompiled pex files.
require('optparse')
require('pathname')
require('fileutils')
require('pp')
options = {}
optParser = OptionParser.new do |opts|
opts.banner... |
class Card
attr_accessor :val, :suite
def initialize(card)
@val, @suite = card.split("")
end
end
class Hand
attr_accessor :cards
def initialize(cards)
@cards = cards.split(" ").map{|ch| Card.new(ch)}
end
def rank
return "STRAIGHT FLUSH" if straight? && flush?
return "STRAIGHT" if straight?
retu... |
class CreateHowGivens < ActiveRecord::Migration
def change
create_table :how_givens do |t|
t.text :HowGiven
t.text :HowGivenDescription
t.timestamps null: false
end
end
end
|
class ScoreDifferenceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless valid_score_difference(record)
record.errors.add attribute, ("game needs to be won by a two point margin")
end
end
private
def valid_score_difference(record)
record.player_score... |
json.array!(@rental_orders) do |rental_order|
json.extract! rental_order, :id, :group_id, :rental_item_id, :num
json.url rental_order_url(rental_order, format: :json)
end
|
module BikeContainer
DEFAULT_CAPACITY = 20
attr_reader :capacity
def initialize capacity = DEFAULT_CAPACITY
@capacity = capacity
@bikes = []
end
def add_bike(bike)
fail "#{self.class.name} full" if full?
bikes << bike
end
def remove_bike
fail "#{self.class.name} empty" if empty?
bikes.pop
... |
class Comment < ApplicationRecord
belongs_to :item
belongs_to :user
# mount_uploader :image, ImageUploader
validates :body, length: { minimum: 5 }, presence: true
# paginates_per 3
end
|
# == Schema Information
#
# Table name: topics
#
# id :integer not null, primary key
# tag :string(255)
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_topics_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_7b... |
class CreateRooms < ActiveRecord::Migration
def change
create_table :rooms do |t|
t.references :roomable, polymorphic: true
t.string :name
t.belongs_to :target, class_name: 'User'
t.belongs_to :owner, class_name: 'User'
t.timestamps null: false
end
end
end
|
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fappu/version'
Gem::Specification.new do |spec|
spec.name = "fappu"
spec.version = Fappu::VERSION
spec.authors = ["Buddy Magsipoc"]
spec.email = ["keikun17@gm... |
class AddFarmingQuestions < ActiveRecord::Migration
def change
# Perhaps we need a 'details or 'meta data' type model
# but for now just stick direct Enrollment and we can refactor
# as required
add_column :enrollments, :on_a_farm, :boolean, default: false
add_column :... |
class AddContactsAndFlagsToProviders < ActiveRecord::Migration
def change
add_column :providers, :tag_laser_cutting, :boolean, :default => false
add_column :providers, :tag_cnc_machining, :boolean, :default => false
add_column :providers, :contact_qq, :string
add_column :providers, :contact_wechat, :... |
require 'dotenv/load'
require "google/apis/sheets_v4"
require "googleauth"
require "googleauth/stores/file_token_store"
require "fileutils"
OOB_URI = "urn:ietf:wg:oauth:2.0:oob".freeze
APPLICATION_NAME = "BeachCoV2 Transformer".freeze
CREDENTIALS_PATH = "credentials.json".freeze
# The file token.yaml stores the user's... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.