text stringlengths 10 2.61M |
|---|
#モデルに書いたメソッドはコントローラーで使用可能
#いわゆるインスタンスメソッド
class User < ApplicationRecord
#saveを実行する前にemailを小文字に破壊的に変換、selfが付いているので自分自身の変数ということ
before_save { self.email.downcase! }
#nameカラムのバリデーション
validates :name, presence: true, length: { maximum: 50 }
#emailのバリデーション、formatでemailの型を検証、uniquenessで被りがないか検証
validates :... |
class PayrollEntriesController < ApplicationController
before_filter :payroll_entry_owner
layout 'application-admin'
def show
@payroll_entry = PayrollEntry.find(params[:id])
@payroll = @payroll_entry.payroll
@entries_by_date = @payroll_entry.group_by_date_and_calculate_totals
end
... |
class Notifications < ActionMailer::Base
default :from => "from@example.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.notifications.membership.subject
#
def membership(owner, items)
@items = items
mail :to => owner, :subject => 'Member... |
json.array!(@member_event_categories) do |member_event_category|
json.extract! member_event_category, :id, :mec_sName, :mec_sDescripton
json.url member_event_category_url(member_event_category, format: :json)
end
|
fastlane_version "2.69.2"
default_platform :android
platform :android do
before_all do
end
desc "Build Debug"
lane :build do
gradle(
task: "assembleDebug"
)
end
desc "Build Release"
lane :build_release do
gradle(
task: "assembleRelease"
)
end
desc "Bump version number"... |
require 'rails_helper'
RSpec.describe "Edits", type: :request do
let(:user) { FactoryGirl.create(:user) }
let(:other_user) { FactoryGirl.create(:user) }
def log_in_as(user, remember_me: '1')
post login_path, params: { session: { email: user.email,
password: user.pa... |
ActiveAdmin.register Transaction do
permit_params :id, :kind, :original_balance, :amount, :amount_positive,
:final_balance, :confirmation, :itemable_type, :itemable_id,
:itemable, :concernable, :concernable_type, :concernable_id,
:reason, :restaurant_id
belongs_to :... |
class Search < SitePrism::Page
set_url "/"
# Submit Form Elements
element :title_field, :id, "title"
element :body_field, :id, "content"
element :keywords_field, :id, "keywords"
element :minimum_impact_field, :id, "minImpactFactor"
element :maximum_impact_field, :id, "maxImpactFactor"
element :primary_... |
class ContactEntry < ActiveRecord::Base
validates :name, :email, :message, :presence => true
end
|
class CreateFavorite < ActiveRecord::Migration
def change
create_table :favorites do |t|
t.belongs_to :tweet
t.belongs_to :user, index: true
t.timestamps null: false, index: true
end
end
def down
drop_table :favorites
end
end
|
Rails.application.routes.draw do
get "/", to: "home#index", as: "home"
post "/webhooks", to: "webhooks#index", as: "webhooks"
match "/404", to: "errors#not_found", via: :all
match "/500", to: "errors#internal_server_error", via: :all
match "/422", to: "errors#unprocessable_entity", via: :all
get "/signup... |
module BTWATTCH2
class Payload
CMD_HEADER = [ 0xAA ]
RTC_TIMER = [ 0x01 ]
MONITORING = [ 0x08 ]
TURN_OFF = [ 0xA7, 0x00 ]
TURN_ON = [ 0xA7, 0x01 ]
BLINK_LED = [ 0x3E, 0x01, 0x02, 0x02, 0x0F ]
class << self
def rtc(time)
payload = [
RTC_TIMER,
time.sec, ti... |
require "gepub"
require "sinatra"
class Hivemind < Sinatra::Base
get "/epubs" do
@epubs = EPub.all
erb :"epubs/index"
end
get "/epubs/upload" do
erb :"epubs/upload"
end
post "/epubs/upload" do
tf = params[:epub][:tempfile]
book = nil
File.open(tf) do |f|
book = GEPUB::Book.pa... |
class Waiter
attr_accessor :name, :yrs_experience
@@all = []
def initialize(name, yrs_experience)
@name = name
@yrs_experience = yrs_experience
@@all << self
end
def self.all
@@all
end
# create a meal
def new_meal(customer, total, tip=0)
Meal.... |
Rails.application.routes.draw do
root to: 'posts#index'
post 'posts', to: 'posts#create'
# メモのidを取得。queryパラメーターを使用した場合、/posts/?id=1とリクエストを送ると、
# params[:id]にてパラメーターを取得できる。今回はpathパラメーターで、一意の情報であるidを取得する
get 'posts/:id', to: 'posts#checked'
end
|
require "formula"
class Dcraw < Formula
homepage "http://www.cybercom.net/~dcoffin/dcraw/"
url "http://www.cybercom.net/~dcoffin/dcraw/archive/dcraw-9.22.tar.gz"
sha1 "f786f12d6cbf2a5571881bcf7f9945365459d433"
bottle do
cellar :any
sha1 "a41d9e98e7c9470a488702da477b9413b9576716" => :mavericks
sha1... |
class Api::V1::EntriesController < ApplicationController
def index
@entries = Entry.all
render json: @entries
end
end
|
class City < ActiveRecord::Base
has_many :neighborhoods
has_many :listings, :through => :neighborhoods
has_many :reservations, through: :listings
include Place::InstanceMethods
extend Place::ClassMethods
# def city_openings(datestring1, datestring2)
# date1 = City.to_date_time(datestring1)
# dat... |
# Requires ruby 1.9.3
# A Trie is, as the pronunciation suggestions, a tree ( More accurately a root
# system ). Each node contains a single letter, with branches to all possible
# subletters in a word set.
# Words that share prefixes will follow the same path until they differ, at
# which point they branch into thei... |
class UserSessionsController < ApplicationController
layout 'login'
def new
end
def create
if login(params[:email], params[:password])
@user = User.find_by_email(params[:email])
redirect_back_or_to(user_path(@user))
else
flash.now.alert = "Login failed."
render action: :new
end
end
... |
class CreateAdminReviews < ActiveRecord::Migration
def change
create_table :reviews do |t|
t.references :student, index: true
t.string :avatar
t.integer :rating
t.references :bootcamp, index: true
t.text :body
t.text :url
t.timestamps
end
end
end
|
require 'test_helper'
class CategoryTest < ActiveSupport::TestCase
# This method is always run before all the successive tests run
def setup
@category = Category.new(name: "sports")
end
test "category should be valid" do
# Basically the following statement tests that can we create a new instance of Category a... |
class AddLiteracyRatePercentageAbove15ToYears < ActiveRecord::Migration
def change
add_column :years, :literacy_rate_percentage_above_15, :decimal
end
end
|
class CreateCheckins < ActiveRecord::Migration
def change
create_table :checkins do |t|
t.boolean :sober
t.integer :mood
t.text :remarks
t.boolean :need_support
t.references :user, index: true, foreign_key: true
t.timestamps null: false
end
end
end
|
#
# Seeds Client
#
# Clients consist of reference number, entities (only 1 in examples)
# and an address
#
# Client Entity Address
# id human_ref id title initials Name id flat_no house
# 1 1 1 Mr K S Ranjitsinhji 1 96 Old Trafford
# 2 2 ... |
require_relative '../test_helper'
#require_relative '../app/models/deposition'
class DepositionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
# # CAS REFUS D'EMBARQUEMENT
test "Should return true when Refus d'embarquement" do
reason = "Refus d'embarquement"
dep_city = "P... |
# Copyright::
# License::
# Description::
# Usage::
class Storage < ActiveRecord::Base
belongs_to :user
belongs_to :deployment
belongs_to :cloud
belongs_to :storage_type
has_many :data_chunks
include ModelMixins::PatternMixin
include ModelMixins::DataLinkMixin
validates :user_id, :cloud_id, :stora... |
class NodeWrapper
CLASS_NODES = %i(module class)
attr_reader :node, :nesting
def initialize(node, nesting)
@node = node
@nesting = nesting
end
def parent
nesting.last(2).first
end
def global_scope?
nesting.size <= 2
end
def current_namespace_node(deep_level = 1)
nesting.revers... |
class Mark < ActiveRecord::Base
belongs_to :user
belongs_to :educational_program
has_many :groups, through: :user
has_one :profile, through: :user
validates :user_id, :educational_program_id, :subject, :value, presence: true
validates :value, numericality: { integer_only: true, greater_than_or_equal_to: ... |
class MyCar
attr_accessor :color
attr_reader :year
def initialize(year, color, model)
@year = year
@color = color
@model = model
@speed = 0
@ignition = "off"
end
def change_speed(spd)
if @ignition == "on"
if spd > @speed
puts "Your car sped up from #{@speed} to #{spd} m... |
class ContactMailer < ActionMailer::Base
default from: "bassanly.exe@gmail.com"
def contact_form(sender, recipient, message)
@user = sender
@message = message
if @message.size > 4000
@message = @message[0..4000] + " \n #{I18n.t('message_truncated')}"
end
mail(to: recipient.email, subject:... |
# Requiring this file causes Test::Unit failures to be printed in a format which
# disables the failing tests by monkey-patching the failing test method to a nop
#
# Note that this will only detect deterministic test failures. Sporadic
# non-deterministic test failures will have to be tracked separately
require 'test/... |
# frozen_string_literal: true
require_relative 'core/cli_options'
module CMSScanner
module Controller
# Core Controller
class Core < Base
def setup_cache
return unless NS::ParsedCli.cache_dir
storage_path = File.join(NS::ParsedCli.cache_dir, Digest::MD5.hexdigest(target.url))
... |
# frozen_string_literal: true
module CopyToClipboardHelper
def copy_to_clipboard_button string_to_copy, label = nil
tag.span label || string_to_copy,
data: { copy_to_clipboard: string_to_copy },
class: "btn-tiny btn-nodanger btn-copy-to-clipboard"
end
end
|
module JRuby::Lint
class Collector
attr_accessor :checkers, :findings, :project, :contents, :file
def initialize(project = nil, file = nil)
@checkers = Checker.loaded_checkers.map(&:new)
@checkers.each {|c| c.collector = self }
@findings = []
@project, @file = project, file || '<inlin... |
require 'google/api_client'
class YoutubeVideoFetcher
DEVELOPER_KEY = ENV['YOUTUBE_API_KEY']
YOUTUBE_API_SERVICE_NAME = 'youtube'
YOUTUBE_API_VERSION = 'v3'
def self.get_service
client = Google::APIClient.new(
:key => DEVELOPER_KEY,
:authorization => nil,
:application_name => $PROGRAM_N... |
class FormatHistoric < FormatVintage
def format_pretty_name
"Historic"
end
def in_format?(card)
card.printings.each do |printing|
next if @time and printing.release_date > @time
# These are currently no excluded sets
return true if printing.arena?
end
false
end
end
|
class WidgetsController < ApplicationController
before_action :set_widget, only: [:show, :edit, :update, :destroy]
# GET /widgets
# GET /widgets.json
def index
@widgets = Widget.all_descendants
end
# GET /widgets/1
# GET /widgets/1.json
def show
end
# GET /widgets/new
def new
@widget = ... |
require_relative "./tax_rate"
class Orderline
class OrderlineArgumentError < StandardError; end
attr_reader :line, :tax
def initialize(line = [])
raise OrderlineArgumentError if line.size < 3
@line = line
@tax = TaxRate.new(product_name, price).apply
end
def quantity
line[0].to_i
end
... |
class Transaction
attr_reader :date, :balance_change, :new_balance
def initialize(date, balance_change, initial_balance)
@date = date
@balance_change = balance_change
@new_balance = initial_balance + balance_change
end
end |
class Post < ApplicationRecord
belongs_to :user
belongs_to :location
belongs_to :day
has_many :post_comments
end
|
class Dialog
STATES = %w(start new finish address point_name point_description point_location point_type point_options)
attr_reader :id
attr_accessor :state
attr_reader :answers
def initialize chat_id, json
@id = chat_id
@state = json.nil? ? STATES[0] : json.state
@answers = json.nil? ? {} : js... |
module DataMapper
module Associations
module OneToOne #:nodoc:
class Relationship < Associations::Relationship
%w[ public protected private ].map do |visibility|
superclass.send("#{visibility}_instance_methods", false).each do |method|
undef_method method unless method.to_s == ... |
require 'util/miq-xml'
class ScanProfilesBase
def self.get_class(type, from)
k = from.instance_variable_get("@scan_#{type}_class")
return k unless k.nil?
k = "#{from.name.underscore.split('_')[0..-2].join('_').camelize}#{type.camelize}"
require "metadata/ScanProfile/#{k}"
from.instance_variable_... |
module HomeHelper
def fetch_featured_manufacturers
@featured_manufacturers = Manufacturer.featured.logo_present.order(:name).limit(60).to_a
end
def fetch_featured_boats
limit = 12
country = Country.find_by(iso: session[:country])
@featured_boats = Boat.featured.active.country_or_all(country).or... |
require 'rest-client'
class CandidateBidRequestStub
def self.callback(candidate_id)
api = RestClient::Resource.new "http://local:3000/api"
attrs = {
candidate: {
bid: bid
}
}
raw_json = api["candidates/#{candidate_id}"].put attrs.to_json, accept: "application/json", content_ty... |
require 'rails_helper'
RSpec.describe CandidaturesController, type: :controller do
let(:volunteer) { create(:volunteer) }
let(:gig) { create(:gig) }
let(:valid_attributes) {
{
gig_id: gig.id,
volunteer_id: volunteer.id,
introduction_letter: 'Im here to help the dogs',
accepted: fals... |
# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
require 'rubygems'
require 'bundler'
Bundler.setup(:default, :test)
# Require simplecov before loading ..dummy/config/environment.rb because it will cause metasploit_data_models/lib to
# be loaded, which would result in Coverage not recording hits for any of the... |
class Step400Proc < ActiveRecord::Migration
def up
connection.execute(%q{
CREATE OR REPLACE FUNCTION public.proc_step_400(process_representative integer,
experience_period_lower_date date,
experience_period_upper_date date,
current_payroll_period_lower_date date,
current_payr... |
class Primer
def initialize(target)
@target = target
end
def prime
count = 1
position = 1
until count == @target
position += 2
if is_prime?(position)
count += 1
end
end
position
end
def is_prime?(number)
(2..Math.sqrt(number)).each do |divisor|
bre... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
Rails.application.routes.draw do
concern :api_base do
resources :leaders
resources :states do
resources :leaders do
collection do
get 'us_senate'
... |
require 'rails_helper'
describe Card do
let(:cardset) { create(:cardset) }
let(:card) { cardset.cards.build(question: "Question", answer: "Answer") }
subject { card }
it { should respond_to(:question) }
it { should respond_to(:answer) }
it { should respond_to(:cardset_id) }
it { should respond_to(:car... |
#! /bin/env ruby
require 'getoptlong'
infiles=Hash.new
para_list=nil
inter=Hash.new
pairs=Hash.new
out_prefix=nil
infiles['nega']="/home/sswang/project/dimer/data/DRYGIN/negative_interactions.list"
infiles['posi']="/home/sswang/project/dimer/data/DRYGIN/positive_interactions.list"
###################################... |
class Movie < Media
validates_presence_of :imdb_id
validates_uniqueness_of :imdb_id
def year
release_date && release_date.split('-').first
end
def self.search(title, year = nil)
self.where('title LIKE ?', title).first
end
def self.search_imdb(title, year = nil)
result = ImdbService.search(t... |
json.array!(@petclubs) do |petclub|
json.extract! petclub, :id, :name, :description
json.url petclub_url(petclub, format: :json)
end
|
Rails.application.routes.draw do
resources :users, only: [:new,:create,:show]
resources :rewards, only: [:index, :show]
get '/login', to: "sessions#new"
post '/login', to: "sessions#create"
delete '/logout', to: 'sessions#destroy'
resources :rewards_users, only: [:new, :create]
namespace :admin do
... |
class CreatePriceTables < ActiveRecord::Migration
def change
create_table :price_tables do |t|
t.string :name
t.integer :days
t.integer :day1
t.integer :day2
t.integer :day3
t.integer :night
t.integer :dinner
end
end
end
|
# -*- coding: utf-8 -*-
module Mushikago
module Tombo
# キャプチャリクエスト
class CaptureRequest < Mushikago::Http::PostRequest
def path; '/1/tombo/capture' end
request_parameter :url
request_parameter :image_format
request_parameter :image_quality do |v| v.to_i.to_s end
request_paramete... |
Given /^(?:that\s)?Product Moderation is (enabled|disabled)$/ do |state|
App.product_moderation[:enabled] = (state == 'true')
end
Given /^I have (?:a\s)?product (.*) created (\d+) days ago$/ do |product_name, days_ago|
@product = Factory :product, :title => product_name.gsub(/^"|"$/, ''), :created_at => (Ti... |
module TextToNoise
class LogReader
attr_reader :io
def initialize( io, mapper )
@io, @mapper = io, mapper
end
def call()
while line = io.gets
@mapper.dispatch line
TextToNoise.throttle!
end
end
end
end
|
require 'rails_helper'
RSpec.describe Player, type: :model do
it { expect(subject).to have_db_column(:full_name) }
it { expect(subject).to have_many(:sports) }
end
|
class CreateCampaigns < ActiveRecord::Migration
def change
create_table :campaigns do |t|
t.string :campaign_id, :limit => 8
t.string :campaign_name, :limit => 40
t.string :campaign_description
t.column :active, "ENUM('Y','N')"
t.datetime :campaign_changedate
t.datetime :campai... |
class AdminController < ApplicationController
# Error Codes
SUCCESS = 1
FIRST_NOT_VALID = 101
LAST_NOT_VALID = 102
EMAIL_NOT_VALID = 103
PASS_NOT_VALID = 104
PASS_NOT_MATCH = 109
DOB_NOT_VALID = 105
ADDRESS_NOT_VALID = 110
CITY_NOT_VALID = 111
ZIP_NOT_VALID = 106
CONTACT_ONE_NOT_VALID = 112
... |
class Admissions::ResourceSuggestionsController < Admissions::AdmissionsController
before_filter :set_resource_suggestion, only: [:edit, :update,
:confirm_destroy, :destroy]
load_resource find_by: :permalink
authorize_resource
def index
respond_to do |format|
format.html {
order = params... |
class CreateActivites < ActiveRecord::Migration
def change
create_table :activites do |t|
t.string :titre
t.text :description
t.string :typeactivite
t.string :prix
t.string :adresse
t.date :datedebut
t.date :datefin
t.timestamps
end
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX_NAME = "debian-wheezy-64"
BOX_URI = "http://basebox.libera.cc/debian-wheezy-64.box"
VBOX_VERSION = "4.3.8"
VAGRANTFILE_API_VERSION = "2"
DOMAIN = "cluster.local"
HOSTS = [
{ :host => "node1-debian", :ip => "192.168.42.11"},
{ :host => "node2-debian", :ip => "192.168.42.... |
class CashRegister
attr_accessor :total , :discount, :items, :last_transaction
def initialize(discount = 0)
@items = []
@total = 0
@discount = discount
end
def total
return @total
end
def add_item(item,price,num = 1)
value = price * num
@total += value
num.times do
... |
json.jobs do |json|
json.array!(@jobs) do |job|
# Main Elements
json.id job.id
json.company job.company
json.position job.position
json.location job.location
json.salary job.salary
json.status job.status
# Secondary Elements
json.contact job.contact
json.email job.email
js... |
FactoryGirl.define do
factory :resume_table_medium do
row { Faker::Number.between(1, 10) }
sequence(:sequence)
artist_medium nil
resume_table nil
end
end
|
class PagesController < ApplicationController
def index
@page = Page.find_by(slug: params[:page])
end
end
|
class AddToTables < ActiveRecord::Migration
def change
add_column :messages, :receiver, :text
add_column :comments, :commentable_name, :text
end
end
|
require 'rubygems'
require 'net/http'
require 'nokogiri'
require 'schema'
require 'user'
require 'twitt'
require 'user_follower'
require 'follower'
require 'timeout'
class Spider
attr_accessor :base_url, :visited, :queue, :root_username, :limit
def initialize(root_username,limit)
@base_url = "http://www.twitt... |
class SyncAttributesOfContactInfos < ActiveRecord::Migration[5.0]
def change
add_column :contact_infos, :web, :string
add_column :contact_infos, :facebook, :string
end
end
|
# -*- coding: utf-8 -*-
require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
gem.name = "monkeyshines"
gem.authors = ["Philip (flip) Kromer"]
gem.email ... |
class AddRedirectUrlToKuhsaftPages < ActiveRecord::Migration
def change
I18n.available_locales.each do |locale|
add_column :kuhsaft_pages, "redirect_url_#{locale.to_s.underscore}", :text
end
end
end
|
require 'spec_helper'
require 'aws/templates/utils'
describe Aws::Templates::Help::Rdoc::Parametrized::Constraints::DependsOnValue do
let(:parametrized) do
Module.new do
include Aws::Templates::Utils::Parametrized
parameter :field
parameter :depends_on_value_requires_field,
cons... |
class Product < ActiveRecord::Base
validates :name, :description, :price, presence: true
validates :name, length: { maximum: 50 }
validates :description, length: { maximum: 150 }
end
|
module Awesome
module Definitions
module Filters
def self.included(base)
base.extend ClassMethods
base.cattr_accessor :search_filters
base.cattr_accessor :verbose_filters
end
module ClassMethods
def search_filters_enabled
self.search_filter_keys(false... |
class Api::V1::UsersController < ApplicationController
before_action :authorized, only: [:update]
def create
user = User.new(user_params)
if user.save
token = encode_token(user_id: user.id)
render json: {user: UserSerializer.new(user), jwt: token }, include: "*.*.*", status: :created
el... |
class UsersFilter
def initialize(type, id = nil)
@type = type
@id = id
end
def ids
send @type, @id
end
private
def all(*_)
User.without_state(:closed).map(&:id)
end
def from_cluster(id)
User.without_state(:closed).map do |u|
if u.all_projects.any? { |p| p.requests.wher... |
# $LICENSE
# Copyright 2013-2014 Spotify AB. All rights reserved.
#
# The contents of this file are 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-... |
module OHOLFamilyTrees
module CurselogCache
class Servers
include Enumerable
def initialize(cache = "cache/publicLifeLogData/")
@cache = cache
end
attr_reader :cache
def each(&block)
iter = Dir.foreach(cache)
.select {|dir| dir.match("curseLog_")}
... |
require 'interrotron'
describe "running" do
def run(s,vars={},max_ops=nil)
Interrotron.run(s,vars,max_ops)
end
it "should exec identity correctly" do
run("(identity 2)").should == 2
end
describe "and" do
it "should return true if all truthy" do
run("(and 1 true 'ohai')").should be_tr... |
class Forum < ApplicationRecord
before_create :generate_permalink
searchkick
belongs_to :user
has_many :comments, dependent: :destroy
private
def generate_permalink
pattern=self.subject.parameterize
duplicates = Forum.where('permalink like ?', "%#{pattern}%")
if duplicates.present?
self.permalink ... |
# frozen_string_literal: true
module ManageStations
attr_accessor :station
def create_station
print 'Введите название станции: '
station = Station.new(gets.chomp)
stations << station
puts "Станция '#{station.name}' создана!"
rescue StandardError => e
puts "#{e.message}\n"
end
def take_a... |
class Dish < ApplicationRecord
has_many :combo_items, dependent: :restrict_with_exception
end
|
module ItemPedia
module_function
CATEGORIES = {
:all => "Tutti",
:potion => "Oggetti",
:ingredient => "Ingredienti",
:other => "Altro",
#:weapon = "Armi",
#:armor = "Armature",
} #NON RIMUOVERE LA PARENTESI
V_DROP = "Drop"
V_STEAL = "Da rubare"
#------------------------... |
class Question < ActiveRecord::Base
validates_presence_of :body
has_many :answers
has_many :users, through: :answers
end |
require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'
module Kuhsaft
module Translations
class Add < Rails::Generators::Base
include Rails::Generators::Migration
source_root(File.join(Kuhsaft::Engine.root, '/lib/templates/kuhsaft/translations'))
... |
class FplTeams::UpdateWaiverPickOrderForm < ApplicationInteraction
object :current_user, class: User
object :fpl_team_list, class: FplTeamList
object :fpl_team, class: FplTeam
object :waiver_pick, class: WaiverPick
object :round, default: -> { fpl_team_list.round }
array :waiver_picks, default: -> { fpl_t... |
class Request < ApplicationRecord
belongs_to :customer
belongs_to :service
has_many :proposal, dependent: :delete_all
validates :article, presence: true
validates :description, presence: true
#validates :legacy_code, format: { with: /\A[a-zA-Z]+\z/, message: "only allows letters" }
#validates :description, pre... |
# frozen_string_literal: true
class TransactionHistory
def initialize
@transaction_logs = []
end
def add_transaction(transaction)
@transaction_logs.push(transaction)
@transaction_logs = @transaction_logs.sort_by {
|trnsaction| trnsaction[:date]
}
end
attr_reader :transaction_logs
end
|
class User
include MongoMapper::Document
attr_reader :password
key :account_id, ObjectId, :required => true
key :username, String, :required => true, :unique => true
key :email, String, :required => true, :unique => true
key :password_digest, String, :required => true
key :session_token, String, :requi... |
class UsersController < ApplicationController
before_action :authenticate_user!
def index
@users = User.all.page(params[:page]).per(10)
end
def destroy
@user = User.find(params[:id])
if current_user.admin?
@user.destroy
redirect_to users_path, notice: 'ユーザーを削除しました'
elsif @user == c... |
class WelcomeController<ApplicationController
def index
if current_user && current_user.provider == "twitter"
@recent_timeline = current_user.timeline
end
end
end
|
class Topic < ActiveRecord::Base
belongs_to :user
has_many :topic_posts
has_many :posts, :through => :topic_posts, :dependent => :destroy
end
|
require 'test_helper'
class MatchImporterTest < ActiveSupport::TestCase
test 'imports placement matches' do
account = create(:account)
importer = MatchImporter.new(account: account, season: 1)
path = file_fixture('valid-placement-import.csv')
assert_difference 'account.matches.placements.count', 6 d... |
class Edge
include Comparable
attr_accessor :node1, :node2, :weight
def initialize(node1, node2, weight)
@node1 = node1
@node2 = node2
@weight = weight
end
def hash_key
return @node1.node_data.to_s + "->" + @node2.node_data.to_s
end
def <=>(other)
@weight <=> other.weight
end
e... |
class CreateReservations < ActiveRecord::Migration[5.0]
def change
create_table :reservations do |t|
t.string :title
t.datetime :begin_at
t.datetime :ends_at
t.references :meeting_room, foreign_key: true
t.timestamps
end
end
end
|
module Yawast
module Scanner
module Plugins
module SSL
class SSL
def self.print_precert(cert)
scts = cert.extensions.find {|e| e.oid == 'ct_precert_scts'}
unless scts.nil?
Yawast::Utilities.puts_info "\t\tSCTs:"
scts.value.split("\n").ea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.