text stringlengths 10 2.61M |
|---|
# Класс Train (Поезд):
# Имеет номер (произвольная строка) и тип (грузовой, пассажирский)
# и количество вагонов, эти данные указываются при создании экземпляра класса
# Может набирать скорость
# Может возвращать текущую скорость
# Может тормозить (сбрасывать скорость до нуля)
# Может возвращать кол... |
require 'rails_helper'
describe Build do
describe 'associations' do
it { should belong_to :repo }
it { should have_many(:file_reviews).dependent(:destroy) }
it { should have_many(:violations).through(:file_reviews) }
end
describe 'validations' do
it { should validate_presence_of :repo }
end
... |
require 'spec_helper'
describe QueueItem do
it { should validate_numericality_of(:position).only_integer }
describe "#rating" do
it "returns user's rating of video if review exists" do
rating_user = Fabricate(:user)
rated_video = Fabricate(:video)
video_review = Fabricate(:review, rating: ... |
class CreateCourses < ActiveRecord::Migration
def change
create_table :courses do |t|
t.string :course_name
t.integer :price, scale:2
t.datetime :start_time
t.datetime :end_time
t.belongs_to :trainer
t.timestamps
end
end
end
|
module GodaddyApi
class ServerMapping
include Kartograph::DSL
kartograph do
mapping Server
root_key plural: 'results', scopes: [:read]
property :serverId, scopes: [:read]
property :image, scopes: [:read]
property :spec, scopes: [:read]
property :key, scopes: [:read]
... |
module SupplyTeachers::TempToPermCalculatorHelper
def display_notice_period_required(calculator)
t('supply_teachers.home.temp_to_perm_fee.notice_period_required',
days: calculator.days_notice_required)
end
def display_notice_period_given(calculator)
t('supply_teachers.home.temp_to_perm_fee.notice_p... |
require 'spec_helper'
describe "Susanoo::AccessibilityChecker" do
describe "メソッド" do
let!(:checker) { Susanoo::AccessibilityChecker.new }
let!(:default_options) {
{
michecker: false, block: false, alt: false,
blank: false, style: false, link: false, text: false
}
}
describ... |
class Mall
def initialize(user, list_of_shops)
@user = user
@list_of_shops = list_of_shops
@shopping = true
end
def display_shops
i = 1
puts "List of Shops"
@list_of_shops.each do |shop|
puts "#{i}. #{shop.name}"
i += 1
end
end
def select_shop
puts "Select a shop please"
display_shop... |
class Agreement < ActiveRecord::Base
attr_accessible :content, :isactive, :title, :version
validates :title, :content, :version, :presence => true
validates :version, :uniqueness => true
has_many :employeragreements
end
|
class Renamecolumn < ActiveRecord::Migration[5.0]
def change
rename_column :rooms, :roomNumber, :roomnumber
end
end
|
class AddUserIdToCost < ActiveRecord::Migration[5.1]
def change
add_column :project_costs, :import_user_id, :integer
end
end
|
class User < ActiveRecord::Base
has_many :followers
has_many :playlists
has_many :likes
has_many :tracks, :through => :likes
TEMP_EMAIL = 'change@me.com'
TEMP_EMAIL_REGEX = /change@me.com/
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :time... |
class BusinessYear < ActiveRecord::Base
has_many :vouchers
has_one :accountplan
def self.findByYear(org, year)
find_by(organisation_id: org, year: year)
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'Courses show' do
background do
allow(Subscription).to receive(:open?)
.and_return(true)
end
given!(:course) { FactoryGirl.create(:course) }
given!(:lesson) { FactoryGirl.create(:lesson, course: course) }
scenario 'user can view t... |
module SpreeBlog
module Core
module Search
class Base
attr_accessor :properties
def initialize(params)
@properties = {}
prepare(params)
end
def retrieve_posts
@posts_scope = get_base_scope
curr_page = page || 1
@posts = @pos... |
class CreateRetailerProfiles < ActiveRecord::Migration
def change
create_table :retailer_profiles do |t|
t.references :user, index: true
t.string :business_name, null: false
t.string :website, null: false
t.string :phone
t.string :address1
t.string :address2
t.string :sub... |
require 'spec_helper'
describe GoCardless::PreAuthorization do
before :each do
@app_id = 'abc'
@app_secret = 'xyz'
GoCardless.account_details = {:app_id => @app_id, :app_secret => @app_secret,
:token => 'xxx', :merchant_id => '1'}
@client = GoCardless.client
end
... |
module Driving
# Width of a lane of a road (ie, a road is actually twice as wide)
ROAD_WIDTH = 3.65
# Width of an agent
AGENT_WIDTH = 1.75
# Length of an agent
AGENT_LENGTH = 4.45
# Maximum number of crumbs for an agent to record
AGENT_MAX_CRUMBS = 200
# How wide an agent's tires are with respect to ... |
class PartSerializer < ActiveModel::Serializer
has_many :comments
has_many :suggestions
has_many :versions
has_one :user
embed :ids, :include => true
attributes :id, :title, :content, :project_id
def user
object.user
end
end
|
module ActionView
module Helpers
class FormBuilder
def flatpickr_date_select(method, options = {}, html_options = {})
default_placeholder_hash={:placeholder=>"选择开始日期"}
placeholder_hash=default_placeholder_hash.merge(options)
existing_date = @object.send(method)
... |
=begin
Insights Service Approval APIs
APIs to query approval service
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
=end
class Action < ApplicationRecord
acts_as_tenant(:tenant)
NOTIFY_OPERATION = 'notify'.freeze
SKIP_OPERATION = 'skip'.freeze
MEMO_OPERAT... |
class Section < ApplicationRecord
validates_presence_of :title
has_many :items , dependent: :destroy
has_many :item_image, dependent: :destroy
has_many :item_text, dependent: :destroy
def as_json(_opts = {})
{
id: id,
title: title,
color: color,
collapse: collapse,
kind: kind,
er... |
require 'chefspec/matchers/shared'
module ChefSpec
# RSpec Matchers
module Matchers
RSpec::Matchers.define :log do |message|
match do |chef_run|
chef_run.resources.any? do |resource|
if resource_type(resource) != 'log'
false
elsif resource.respond_to?(:message)
... |
class Company < ActiveRecord::Base
has_many :favorite_companys
has_many :users, through: :favorite_companys
end
|
FactoryGirl.define do
#sequence(:email) {|n| "person-#{n}@example.com" }
#sequence(:count)
factory :title do
sequence(:name) {|n| "name-#{n}" }
end
factory :page do
page_number 1
asset_file { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'support', 'qvb.jpg')) }
end
factory :vers... |
require 'test/unit'
require 'kconv'
class TestKconv < Test::Unit::TestCase
EUC_STR = "\
\xa5\xaa\xa5\xd6\xa5\xb8\xa5\xa7\xa5\xaf\xa5\xc8\xbb\xd8\xb8\xfe\
\xa5\xd7\xa5\xed\xa5\xb0\xa5\xe9\xa5\xdf\xa5\xf3\xa5\xb0\xb8\xc0\xb8\xec
\x52\x75\x62\x79"
UTF8_STR = "\
\xe3\x82\xaa\xe3\x83\x96\xe3\x82\xb8\xe3\x82\xa7\
\xe3\x... |
module Api::V1
class AgentsController < ApplicationController
before_action :set_agent, only: [:show, :update, :destroy, :heartbeat, :disconnect, :pause, :resume]
# GET /agents
def index
@agents = Agent.where(deleted_at: nil).filter(params.slice(:status, :enabled, :jobqueue_id, :no_heartbeat_since)... |
require 'spec_helper'
describe News do
it {should validate_presence_of(:subject)}
it {should validate_presence_of(:description)}
it {should validate_presence_of(:place)}
it {should validate_presence_of(:date)}
it {should belong_to(:user)}
end |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# this Vagranfile needs vagrant-reload, you have to install it with:
# vagrant plugin install vagrant-reload
Vagrant.require_version ">= 1.8.1"
Vagrant.configure("2") do |config|
config.vm.box = "windows_2012_r2"
config.vm.define "test-node-one"
config.vm.hostna... |
module Dns
def self.table_name_prefix
'dns_'
end
end
|
feature 'User sees different homepage depending on if they are signed in or not' do
context 'when signed in' do
it 'they see the user homepage' do
user = create(:user)
sign_in user
visit root_path
# Replace this with application-specific assertion
expect(page).to have_content 'User ... |
require 'sinatra'
require 'sinatra/activerecord'
require 'pry'
require 'pry-nav'
require 'sinatra/contrib'
set :bind, '0.0.0.0'
before /.*/ do
if request.url.match(/.json$/)
request.accept.unshift('application/json')
request.path_info = request.path_info.gsub(/.json$/, '')
end
end
def render_... |
FactoryBot.define do
factory :packaging do
name {'Default Packaging Name'}
factory :new_packaging do
name {'New Packaging Name'}
end
factory :original_packaging do
name {'Original Packaging Name'}
end
end
end |
# frozen_string_literal: true
module BPS
class RequestError < ErrorWithMetadata
def bugsnag_meta_data
{
data_request: {
code: metadata[:code],
request: metadata[:request],
uri: metadata[:uri],
body: metadata[:body]
}
}
end
end
end
|
class Box
def initialize(w,h)
@width,@height = w,h
end
def to_s
"(w:#@width,h:#@height)"
end
end
box= Box.new(2,3)
puts box
|
require 'cocoapods-lazy/logger'
module Pod
module Lazy
class RemoteStorage
def initialize(config)
@config = config
end
def fetch(name:)
zip_name = "#{name}.zip"
url = @config.base_url + zip_name
`curl --fail #{url} --output #{zip_name}`
`unzip #{zip_name... |
class UserSerializer < ActiveModel::Serializer
attributes :patterns, :name
has_many :patterns
end
|
require_relative 'p04_linked_list'
class HashMap
include Enumerable
attr_accessor :count
def initialize(num_buckets = 8)
@store = Array.new(num_buckets) { LinkedList.new }
@count = 0
end
def include?(key)
linked_list(key).include?(key)
end
def set(key, val)
if !include?(key)
link... |
module Legion
module Transport
module Exchanges
class Extensions < Legion::Transport::Exchange
def exchange_name
'extensions'
end
end
end
end
end
|
class CreateSpecialityTable < ActiveRecord::Migration
def change
create_table :specialities do |t|
t.string :title
t.string :short_title
t.timestamps
end
end
def unchange
drop_table :specialities
end
end
|
# NOTICE:
#When logged in as different type,
#it's necessary to mention each type this "will" log in as some type
# Otherwise, previous type will store in cache/session? and failed all tests.
Given /^(?:|I )will be logged in as "([^"]*)" type$/ do |type|
case type.downcase
when "coach"
user = YAML.load(F... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: messages
#
# id :integer not null, primary key
# body :text
# conversation_id :integer
# user_id :integer
# read :boolean default(FALSE)
# created_at :datetime not null
... |
require "csv"
datasets = CSV.table "datasets.csv"
datasets.each do |dataset|
desc "calculate thickness and density of #{dataset[:name]}"
file dataset[:thickness_density] => ["thickness_density.py", dataset[:folder], dataset[:height_map_left], dataset[:height_map_right]] do |f|
sh "python #{f.prerequisites[0]... |
module WillPaginateFerret
module Finder
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def paginate_by_contents(q, options = {}, find_options = {})
# wp_parse_options is defined in plugin will_paginate
options, page, per_page = wp_parse_options op... |
module SimpleCov
#
# Base filter class. Inherit from this to create custom filters,
# and overwrite the passes?(source_file) instance method
#
# # A sample class that rejects all source files.
# class StupidFilter < SimpleCov::Filter
# def passes?(source_file)
# false
# end
# end
#
class... |
require "rails_helper"
RSpec.feature "Store Admin", type: :feature do
let!(:user) { User.create!(username: 'user', password: 'password') }
before do
visit login_path
fill_in "Username", with: "user"
fill_in "Password", with: "password"
click_button "Login"
end
it "can set the job status to i... |
# frozen_string_literal: true
# Helper for sending push notifications
module BPS
class Push
PRIORITIES = {
lowest: -2,
low: -1,
normal: 0,
high: 1,
emergency: 2
}.freeze
def self.for(user, priority: :normal)
new(user, priority: priority)
end
def self.notify(u... |
class CreateProjectmanagerRelationships < ActiveRecord::Migration[5.1]
def change
create_table :projectmanager_relationships do |t|
# 项目用户管理多对多
t.integer :user_id
t.integer :project_id
t.timestamps
end
end
end
|
require 'test_helper'
class SurrendersControllerTest < ActionController::TestCase
setup do
@surrender = surrenders(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:surrenders)
end
test "should get new" do
get :new
assert_response :succ... |
module CamaleonCms
class CustomFieldsRelationship < CamaleonRecord
self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}custom_fields_relationships"
# attr_accessible :objectid, :custom_field_id, :term_order, :value, :object_class,
# :custom_field_slug, :group_number
default_scope { orde... |
Fabricator(:user) do
full_name {sequence(:full_name) {Faker::Name.name }}
email {sequence(:email) { |n| "#{Faker::Internet.email}{n}@example.com"} }
password {sequence(:password) {Faker::Internet.password}}
end |
class UpdateChoices < ActiveRecord::Migration
def change
change_column_default(:choices, :option_a_votes, 0)
change_column_default(:choices, :option_b_votes, 0)
end
end
|
# frozen_string_literal: true
# Destroy all existing data
print 'Destroying existing models...'
Rails.application.eager_load!
ApplicationRecord.descendants.each(&:destroy_all)
puts 'done!'
# Multiplier constant
MULTIPLIER = 5
# Users
print 'Creating users...'
# Create user profiles with about field as a quote f... |
# -*- coding: utf-8 -*-
module Susanoo
module Accessibility
#
#=== 空白チェック
#
class Blank < Base
def validate(doc)
xpath = settings.target.xpath
nbsp = Nokogiri::HTML(" ").text
doc.xpath("#{xpath}/div//text()").each_with_index do |e, i|
if e.parent.present?
... |
Rails.application.routes.draw do
resources :prospects, only: [:new, :create]
devise_for :users
root to: 'pages#home'
get 'thanks', to: 'pages#thanks', as: 'thanks'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
require 'test_helper'
class CashCountTest < ActiveSupport::TestCase
test 'all values total cash counted' do
cash_count = CashCount.new fifty: 72,
fifty_cent: 72,
five: 72,
five_cent: 72,
hu... |
Rails.application.routes.draw do
resources :submissions
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
devise_for :users
resources :solutions
resources :problems
root 'pages#intro'
get '/intro', to: 'pages#intro'
get '/team', to: 'pages#team'
# For details on the DSL available within this f... |
class MerchantsController < ApplicationController
before_action :set_merchant, only: [:deals]
def deals
@deals = @merchant.deals.published.includes(:deal_images).paginate(page: params[:page])
end
private
def set_merchant
@merchant = Merchant.find_by(id: params[:id])
if @merchant.nil?
red... |
#
#
#[+]Exploit Title: Exploit Buffer Overflow NetZip Classic(SEH)
#[+]Date: 01\30\\2011
#[+]Author: C4SS!0 G0M3S
#[+]Software Link: http://proforma.real.com/real/nzclassic/nzclassic.html
#[+]Version: 7.5.1.86
#[+]Tested on: WIN-XP SP3 PORTUGUESE BRAZILIAN
#[+]CVE: N/A
#
#The structure of the zip file has been copied f... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Input
describe Mouse do
let(:described) { Vedeu::Input::Mouse }
let(:instance) { described.new(input) }
let(:input) {}
describe '#initialize' do
it { instance.must_be_instance_of(described) }
... |
class AddIndexToUserMessages < ActiveRecord::Migration
def self.up
add_index "user_messages", "user_id"
end
def self.down
remove_index "user_messages", "user_id"
end
end
|
class AddSensitiveContentWarningToStories < ActiveRecord::Migration[5.2]
def change
add_column :stories, :sensitive_content_warning, :text
end
end
|
class RoadmapHeader < ApplicationRecord
belongs_to :user
# roadmap_detailを1つ所持
has_one :roadmap_detail, dependent: :destroy
# デフォルトでcreated_atを逆順でソート
default_scope -> { order(created_at: :desc) }
# Formでroadmap_detailを複数所持可能にする
# allow_destroy : formでdestroyを指定すると子要素を削除する
# reject_if : すべての入力属性が空の場合、... |
class AddIsDefaultToEvaluationTemplates < ActiveRecord::Migration
def self.up
add_column :evaluation_templates, :is_default, :boolean, :default => true
end
def self.down
remove_column :evaluation_templates, :is_default
end
end
|
require File.dirname(__FILE__) + '/../test_helper'
class CompanyTest < Test::Unit::TestCase
fixtures :companies
def test_invalid_if_empty_attributes
company = Company.new
assert !company.valid?
assert company.errors.invalid?(:name)
assert company.errors.invalid?(:latest_price)
end
def tes... |
require 'spec_helper'
describe Dummy do
before do
@dummy = Dummy.new
end
it "must not be nil" do
@dummy.wont_be_nil
end
end
|
class CartesianProduct
include Enumerable
def initialize(set_one, set_two)
@set_one = set_one
@set_two = set_two
end
def each
@set_one.each do |i|
@set_two.each do |j|
yield [i,j]
end
end
end
end
#c = CartesianProduct.new([:a,:b], [4,5])
#c.each {... |
describe 'User profile' do
let(:user_1) { create(:user) }
let(:user_2) { create(:user) }
let(:admin) { create(:user) }
context 'when user is not logged in' do
context 'when user visits profile path' do
before { visit profile_path }
it 'redirects to root path' do
expect(current_path).to... |
class RemoveApplicationStatusLockedFromEvents < ActiveRecord::Migration
def change
remove_column :events, :application_status_locked, :boolean
end
end
|
require 'executor'
class YamlPlan < Demo
def self.title
"Yaml Plans"
end
def run
@prompt.clear_screen
@prompt.say(<<~INST)
Bolt plans compose multiple Bolt steps together, and share data between those steps
Bolt supports plans written in YAML. For example, this plan updates the Apache con... |
class ChangeColumnName < ActiveRecord::Migration[6.1]
def change
rename_column :socks, :type, :type_of_socks
end
end
|
class TestStandard < ActiveRecord::Base
include Hashable
attr_accessible :standard_id, :test_suite_id
belongs_to :test_suite
belongs_to :standard
end
|
Pod::Spec.new do |s|
s.name = "QuickRulerSuite"
s.version = "1.0.3"
s.summary = "A suite to quick create ruler control on iOS, which seems to be attractive. iOS上标尺控件的集合。"
s.description = <<-DESC
A suite to quick create ruler control on iOS, which seems to be attrac... |
class ChangePhoneagainColumn < ActiveRecord::Migration
def change
change_column :jobs, :phone_number, :string
end
end
|
require "wx_redpack"
class Redpack < ActiveRecord::Base
include WxRedpack
# SENDING:发放中, SENT:已发放待领取, FAILED:发放失败, RECEIVED:已领取, REFUND:已退款
enum status: { unknown: 0, sending: 1, sent: 2, failed: 3, received: 4, refound: 5 }
STATUS_TITLE = {
"unknown" => "未发放",
"sending" => "发放中",
"sent" => "已发放"... |
# frozen_string_literal: true
require "rails_helper"
describe User, type: :model do
it { is_expected.to allow_value("+48 999 888 777").for(:phone_number) }
it { is_expected.to allow_value("48 999-888-777").for(:phone_number) }
it { is_expected.to allow_value("48 999-888-777").for(:phone_number) }
it { is_expe... |
class RubyamfController < ActionController::Base
include RubyAMF::App
def gateway
RequestStore.rails_authentication = nil #clear auth hash
RequestStore.rails_request = request
RequestStore.rails_response = response
#Compress the amf output for smaller data transfer over the wire... |
class ProductDecorator < Draper::Decorator
delegate_all
def truncated_description
h.truncate(product.text, length: 120)
end
def current_amount
"На складе: #{product.amount} шт."
end
def price_in_rur
"#{product.price} ₽"
end
def method_name
end
end
|
require 'spec_helper'
describe TradeLead::McaData do
let(:fixtures_dir) { "#{Rails.root}/spec/fixtures/trade_leads/mca" }
let(:fixtures_file) { "#{fixtures_dir}/mca_leads.xml" }
let(:resource) { fixtures_file }
let(:importer) { described_class.new(fixtures_file) }
let(:expected) { YAML.load_file("#{fixtures_... |
# write a method that takes a year as input and returns the century
# the return value should be a string that beings with the century number
# and ends with "st", "nd", "rd" or "th" as appropiate for that number
# new centuries begin in years that end with 01
# years 1901-2000 comprise the 20th century
# Examples:
... |
module Api
module V1
class AuthController < ApplicationController
before_action :authorize_editor!, only: [:show]
def create
script = Script.find_by(cuid: params[:script][:cuid])
if script.present? && script.authenticate(params[:script][:password])
editor = script.editors.fi... |
# Write a method that returns a list of all substrings of a string. The
# returned list should be ordered by where in the string the substring begins.
# This means that all substrings that start at position 0 should come first,
# then all substrings that start at position 1, and so on. Since multiple
# substrings will ... |
class Coordinate
attr_reader :x, :y
def initialize(x, y)
@x = x
@y = y
end
def distance_to(i, j)
(x - i).abs + (y - j).abs
end
end
coordinates = INPUT.split("\n").map { |line| Coordinate.new(*line.split(", ").map(&:to_i)) }
westmost, eastmost = coordinates.minmax_by(&:x)
northmost, southmost = ... |
require File.dirname(__FILE__) + '/../spec_helper'
describe GlosariosController do
describe "handling GET /glosarios" do
before(:each) do
@glosario = mock_model(Glosario)
Glosario.stub!(:find).and_return([@glosario])
end
def do_get
get :index
end
it "should be successful"... |
require 'funl/version'
Gem::Specification.new do |s|
s.name = "funl"
s.version = Funl::VERSION
s.required_rubygems_version = Gem::Requirement.new(">= 0")
s.authors = ["Joel VanderWerf"]
s.date = Time.now.strftime "%Y-%m-%d"
s.description = "Sequences messages."
s.email = "vjoel@users.sourceforge.net"
... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root to: 'static#home'
devise_for :users
resources :mailer_subscription_unsubcribes, only: [:show, :update]
resources :mailer_subscriptions, only: [:index, :create, :update]
... |
require 'spec_helper'
describe Payment do
let(:item) { FactoryGirl.create(:item, user_id: 1, event_id: 1) }
let(:participant) { FactoryGirl.create(:participant, user_id: 1, event_id: 1) }
before do
@payment_from_item = item.payments.build(
participant_id: 1,
price: 12_345,
status: false)
... |
class AddEpayToCreditcard < ActiveRecord::Migration[5.2]
def change
add_reference :creditcards, :epay, foreign_key: true
remove_column :epays, :creditcard_id, :bigint
end
end
|
require 'spec_helper'
describe "users/new.html.haml" do
it "have a form" do
assign(:user, mock_model("User").as_null_object)
render
rendered.should have_selector("form", :method => "post", "action" => users_path)
end
end
|
# frozen_string_literal: true
module Vedeu
module Models
# A Page represents an array of Vedeu::Models::Row objects.
#
# @api private
#
class Page
include Enumerable
# @!attribute [r] rows
# @return [Array<NilClass|Vedeu::Models::Row>]
attr_reader :rows
class <<... |
class QualificationsSubjects < ActiveRecord::Migration
def up
create_table :qualifications_subjects, :id => false do |t|
t.integer :subject_id
t.integer :qualification_id
end
add_index :qualifications_subjects, [:subject_id, :qualification_id], :unique => true
end
def down
drop_table... |
Rails.application.routes.draw do
root "static_pages#root"
resources :posts, except: [:new, :edit]
end
|
json.array!(@donors) do |donor|
json.extract! donor, :id, :name, :address, :city, :state, :zip, :phone_number
json.url donor_url(donor, format: :json)
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :user_stocks
has_many :stocks, through: :use... |
class Recipe
attr_accessor :ingredients
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end ##TEMPORARY INITIALIZATION
def self.all
@@all
end
def self.most_popular_helper(curr_recipe)
new_array = RecipeCard.all.select do |recipe_card|
recipe_card.... |
# == Schema Information
#
# Table name: years
#
# id :integer not null, primary key
# year :integer
# created_at :datetime
# updated_at :datetime
#
class Year < ActiveRecord::Base
# Associations
has_many :issues
# Validations
validates :year, presence: true, uniqueness: true
def ... |
require "spec_helper"
describe ActiveRecord::Turntable::Algorithm::ModuloAlgorithm do
context "When initialized" do
before do
@alg = ActiveRecord::Turntable::Algorithm::ModuloAlgorithm.new(ActiveRecord::Base.turntable_config[:clusters][:mod_cluster])
end
context "#calculate with 1" do
subjec... |
class BaseScorer
def initialize(card: , style: )
@card = card
@style = style
end
def score
0.0
end
end
|
module Battleship
# represents a single player
# intended to subclass as human/computer players
class Player
attr_reader :name
attr_reader :grid
attr_accessor :opponent
def initialize(name)
@name = name
@grid = Grid.new
@ships = Ship.all
place_ships_randomly
end
de... |
class AddColumnsToUsers < ActiveRecord::Migration
def change
add_column :users, :postal_code, :integer
add_column :users, :tagline, :string
add_column :users, :about_me, :text
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.