text stringlengths 10 2.61M |
|---|
class ChangeTimeslotUserToDefaultuser < ActiveRecord::Migration[5.1]
def change
rename_column :timeslots, :user_id, :default_user_id
end
end
|
# frozen_string_literal: true
RSpec.describe Customerio::IdentifyUserJob do
describe '.perform' do
let(:user) { create(:user) }
subject(:perform) do
described_class.perform_now(user_id: user.id)
end
let(:identify_user_service) { instance_double('Customerio::IdentifyUserService') }
before... |
require_relative 'song.rb'
class Artist
attr_accessor :name
def initialize(name)
self.name = name
end
def songs
Song.all.find_all {|song_obj| song_obj.artist == self}
end
def add_song(song)
song.artist = self
end
def add_song_by_name(name)
song = Song.new(name)
self.add_song(song)
end
def self.so... |
require 'rails_helper'
RSpec.describe Package, type: :model do
it { should validate_presence_of :order_id }
it { should belong_to :order }
it { should have_many :pastas_packages_relationships }
it { should have_many :pastas }
end
|
require 'rails_helper'
describe Progress, type: :model do
context '有効な情報が入力されたとき' do
it '正常に登録される' do
progress = FactoryBot.build(:progress)
expect(progress.valid?).to eq(true)
end
end
context '無効な情報が入力されたとき' do
it '内容が存在しないためエラーとなる' do
progress = FactoryBot.build(:progress, conten... |
class CreateItemOrders < ActiveRecord::Migration[5.2]
def change
create_table :item_orders do |t|
t.belongs_to :item, index: true
t.belongs_to :order, index: true
t.decimal "fix_price", precision: 5, scale: 2
end
end
end
|
module RSpec::Core
class ExampleGroup
class << self
#
# This macro is available inside of each controller spec:
#
# describe UsersController do
# describe "/users" do
# it_should_be_protected :index
# end
# end
#
def it_... |
# LRTHW Exercise 4
# Number of cars in total
cars = 100
# The space available in each car for passengers
space_in_a_car = 4
# The total number of drivers available
drivers = 30
# The total number of passengers
passengers = 90
# Assign a variable value to the number of cars not being used
cars_not_driven = cars - drive... |
class ApplicationController < ActionController::Base
#methods here are available to ALL controllers
helper_method :current_user, :logged_in? #adding this line makes the method availble to views as well as controllers
def current_user #retrieve current user instance var or look up in dbase
@current_user... |
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# -*- ruby -*-
#
require 'rubygems'
require 'rss'
require 'open-uri'
require 'hpricot'
#
# 取得したフィードを配列で返す。
# フィードが無い場合は空配列を返す。
# 指定したURLが無効な場合はnilを返す。
#
def process_rss(rss,list)
content = ''
open(rss){ |f|
content = f.read
}
rss = nil
begin
rss = ... |
module Hangman
class Row
attr_accessor :cells
def initialize(string)
@cells = string.split("").map do |letter|
if letter =~ /\w/
Cell.new("_")
else
" "
end
end
end
def update_row(input, word)
i = 0
while i < @cells.length
if input == word.value[i].upcase
set_cell(inp... |
class Report
attr_accessor :text
def initialize
@text = []
end
#observers must have a common interface, here it is the update method
def update(info)
#the observer also has to know how to interact with the subject
@text << "#{info.name} has been changed to #{info.value}"
end
end |
class DonationAdditionalField < ActiveRecord::Base
belongs_to :finance_donation
has_many :donation_additional_details
has_many :donation_additional_field_options, :dependent=>:destroy
accepts_nested_attributes_for :donation_additional_field_options, :allow_destroy=>true
validates_presence_of :name
validates... |
Given "I am viewing any part of the dashboard" do
step "I am on the main dashboard"
end
Given "I know the serial number of a registered device" do
memorize_fact(:serial_number, device.serial_number)
end
def search_for(serial)
within('#device-search') do
fill_in('serial_number', with: serial)
find_button... |
class RemoveIrbDatesFromProtocols < ActiveRecord::Migration
def change
remove_column :protocols, :irb_approval_date, :timestamp
remove_column :protocols, :irb_expiration_date, :timestamp
end
end
|
# encoding=utf-8
require "han/version"
require 'thor'
require 'nokogiri'
require 'open-uri'
require 'net/http'
module Han
class CLI < Thor::Group
argument :character
def process
uri = URI(URI::encode("http://www.zdic.net/sousuo/?q=#{character}"))
res = Net::HTTP.get_response(uri)
doc = ... |
# frozen_string_literal: true
module Zafira
class Client
attr_accessor :environment, :run_owner, :test_suite_owner,
:test_suite, :job, :run, :current_test_case, :unavailable
def initialize(config)
self.config = config
end
def test_case_handler_class
return unless confi... |
class NewRecordMailer < ApplicationMailer
default from: 'Sistema registro de garantias'
def new_record_email(ticket)
@ticket = ticket
attachments.inline["mail_sent.png"] = File.read("#{Rails.root}/app/assets/images/mail_sent.png")
mail(to: @ticket.analist, subject: 'Nuevo registro de garantia')
end
e... |
class RenameSupplementalIndeces < ActiveRecord::Migration
def up
rename_index :articles, 'supplementals_pkey', 'articles_pkey'
rename_index :articles, 'index_supplementals_on_creator_id', 'index_articles_on_creator_id'
rename_index :articles, 'index_supplementals_on_deleted_at', 'inde... |
class CatsController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :find_owner, only: [:index, :show, :create, :update, :destroy]
before_action :find_owner_cat, only: [:index, :show, :update, :destroy]
# Lista todos os gatinhos de determinado owner
# GET /owners/:owner_i... |
class Notification::Notification < ActiveRecord::Base
attr_accessible :user, :instance, :action, :read
belongs_to :user, class_name: "MDB::User"
belongs_to :instance, polymorphic: true
validates_presence_of :user, :instance, :action
scope :unread, where('read = ?', false)
def mark_as_read!
s... |
module AuthenticationConcern
extend ActiveSupport::Concern
included do
helper_method :current_user
helper_method :logged_in?
end
def current_user
return nil if session[:user_id].blank?
@current_user ||= User.where(id: session[:user_id]).first
end
def logged_in?
!current_user.nil?
en... |
class Sector
attr_accessor :location, :item
def initialize(location, item)
@location = location
@item = item
end
def arrive_at_sector(astronaut)
puts "You have arrived at sector #{location}!"
sleep(1)
discover_item(astronaut)
end
private
def discover_item(astronaut)
genera... |
module Cli
module Formattable
private
def format
as_json? ? :json : :table
end
def as_json?
options[:raw]
end
end
end
|
class CalificationsController < ApplicationController
before_action :set_publication
before_action :set_calification, only: [:destroy]
def create
if existing_calification?
flash[:notice] = 'ya calificaste la publicación'
else
@publication.califications.create(user_id: ... |
class AddlockedToAdmins < ActiveRecord::Migration[5.1]
def change
add_column :admins, :locked_at, :datetime
end
end
|
module IpRestriction
class AllowedIpsConstraint
def matches?(request)
checker.allowed?(request.remote_ip)
end
private
def checker
@checker ||= IpChecker.new(IpsRetriever.new.office_ips)
end
end
end
|
# frozen_string_literal: true
module FacebookAds
class Account < Base
FIELDS = %w[].freeze
class << self
def all(query = {})
get('/me/accounts', query: query, objectify: true)
end
end
end
end
|
class RenameOrderToPositionInSkillsAndCategories < ActiveRecord::Migration
def change
rename_column :skills, :order, :position
rename_column :categories, :order, :position
end
end
|
class PeopleController < InheritedResources::Base
load_and_authorize_resource
helper_method :person, :people
protected
def collection
if params[:status]
@people = Person.where(status: params[:status])
else
super
end
end
def person
resource
end
def people
collection
end
... |
class Event < ApplicationRecord
has_many :meetings
has_many :users, through: :meetings
end
|
#!/usr/bin/env ruby
require 'thor'
require 'redis'
require 'net/dns'
require 'tire'
class Lists < Thor
desc 'clean emailFile', 'Clean an email file'
def clean(email_file)
bad_names = Array.new
File.foreach(File.dirname(__FILE__) + '/bad.first.names.txt') { |line| bad_names << line.delete("\n") }
Fil... |
require "rails_helper"
RSpec.describe Apps::DeploymentsController, type: :routing do
describe "routing" do
let(:app) { create(:app) }
let(:deployment) { create(:deployment, app: app) }
it "routes to #index" do
expect(:get => "#{api_prefix}/apps/#{app.name}/deployments").to \
route_to("apps... |
require 'driver'
require_relative "../pages/page"
require 'csv'
describe "HelloWorld" do
before(:all) do
@driver = WebDriver.new('https://www.propertyfinder.ae/')
sleep 5
@seach_page = Pages::PropertyFinder.new(@driver)
@seach_page.search_for_property
sleep 5
end
it "Getting price of lis... |
class GroupsController < ApplicationController
skip_before_action :authenticate_request
def new
if current_user
@group = current_user.groups.build
else
@group = Group.new
end
render json: @group
end
def create
if current_user
... |
class AddPublicFlagsOnQuotations < ActiveRecord::Migration[5.0]
def change
add_column :quotations, :public_for_artist, :boolean, default: false
add_column :quotations, :public_for_commissioner, :boolean, default: false
end
end
|
class ProposalVersionsQuery
def initialize(proposal)
@proposal = proposal
end
def container
base_container.alter_query do |relation|
relation.where(id: version_ids)
end
end
private
attr_reader :proposal
def base_container
@_base_container ||= TabularData::Container.new(:versions,... |
module Sumac
# Acts as the backend to {ObjectRequestBroker} to hide implementation from the application.
# It is responsible for handling all events directed to the broker.
# It also shares access to all its helpers.
# It should only have methods that effect the broker's state. Other methods should be called... |
class Pub::SongsController < Pub::BaseController
before_filter :add_song_tab_active, :only => [:new, :create]
def index
return @titles = Title.all if params[:q].blank?
@titles = Title.search_by_name(params[:q])
end
def new
@song = Song.new
#@song.titles.build(:primary => true)
#@song.versions.build... |
require 'rails_helper'
RSpec.describe XmlContactImporter, type: :model do
describe '#import' do
context 'when structure true' do
let(:content) do
<<-content.strip_heredoc
<?xml version="1.0" encoding="UTF-8" ?>
<contacts>
<contact><name>Kökten</name><lastName>Adal<... |
#encoding: utf-8
class SayGoodBye < Botpop::Plugin
include Cinch::Plugin
match(/^!sg [\w\-\.].+/, use_prefix: false, method: :exec_sg)
HELP = ["!sg src_name"]
ENABLED = config['enable'].nil? ? true : config['enable']
def exec_sg m
arg = m.message.split.last
m.reply config[arg].sample
end
end
|
class TimeConverter
attr_reader :time_string, :period, :date
def initialize(time_string, period=nil, date=nil)
@time_string = time_string
@period = period
@date = date
end
def convert
hours, mins, secs = time_string.split(":").map(&:to_i)
hours += 12 if period == "PM"
create_time_objec... |
require_relative '../lesson4/module/module.rb'
class Part
include Firmware
attr_reader :type
def initialize(type)
@type = type
end
end |
class MessagesController < ApplicationController
skip_before_filter :admin_authorize, only: [:destroy, :delete, :apply, :invite, :pm]
before_action :set_message, only: [:destroy,:delete]
# GET /messages
# GET /messages.json
def index
@messages = Message.all
end
def delete
if @message.read
... |
# Problem 257: Angular Bisectors
# http://projecteuler.net/problem=257
#
# Given is an integer sided triangle ABC with sides a ≤ b ≤ c.
# (AB = c, BC = a and AC = b).
# The angular bisectors of the triangle intersect the sides at points E, F and G (see picture below).
#
#
# http://projecteuler.net/project/images/... |
#{{{ Marathon Fixture
require 'default'
#}}} Marathon Fixture
require 'common/on_main_window_as'
def test
java_recorded_version = '1.6.0_20'
on_main_window_as('MarathonDolphin', 'dolphin') do
select('TabbedPane', '受付リスト')
click('kutu01')
# Memo: 他の受付があればずれる
assert_p('RowTipsTable', 'Text', 'ドル... |
# Write a method that returns true if the string passed as an argument is a palindrome, false
# otherwise. A palindrome reads the same forward and backward. For this exercise, case matters
# as does punctuation and spaces.
# Understanding the problem:
# Pass string to method
# Compare string to backwards string
... |
FactoryGirl.define do
# Crea topicos genericos
# factory :project do
# sequence(:name) { |n| "Test project#{n}" }
# sequence(:type) { |n| "Technologie" }
# description "description"
# end
factory :project do
name "Project"
project_type "Project type"
description "project description"
end
en... |
# coding: utf-8
Gem::Specification.new do |s|
s.name = 'yjtool'
s.version = '0.0.1'
s.authors = ["yj"]
s.date = '2015-03-21'
s.summary = "yjtool command tool"
s.description = "yjtool command tool, Common tools"
s.email = ['houmanager@hotmail.com']
s.files... |
FactoryGirl.define do
factory :piece_result do
name {Faker::Name.name}
end
end
|
require "dotenv/load"
require "yaml"
require_relative "openai"
class RecipeBase
PROMPT_FILE = "prompts.yml"
def initialize(name:)
@name = name
end
private
attr_reader :name
def openai
OpenAI.new(api_key: ENV["OPENAI_KEY"])
end
def prompt
YAML.load_file(PROMPT_FILE).dig(self.class::PROM... |
class RemoveTeacherFromStudents < ActiveRecord::Migration[6.0]
def change
remove_column :students, :teacher, :string
end
end
|
require_relative 'board.rb'
class MainWindow < Qt::Widget
slots 'startGame()', 'resizeBoard()'
def initialize(parent = nil)
super()
widthLabel = Qt::Label.new(tr('Width:'))
heightLabel = Qt::Label.new(tr('Height:'))
cellSizeLabel = Qt::Label.new(tr('Cell size:'))
@width = Qt::LineEdit.new('40... |
class AddDigestToArticles < ActiveRecord::Migration
def change
add_column :articles, :digest, :string
add_index :articles, :digest
end
end
|
require 'net/http'
class RaroUtil
def self.to_time_desc(segundos)
hora = Time.at(segundos).gmtime.strftime("%H")
minuto = Time.at(segundos).gmtime.strftime("%M")
segundo = Time.at(segundos).gmtime.strftime("%S")
tempo = ""
if hora.to_i == 1
tempo += "#{hora} hora "
elsif hora.to... |
class BudgetsController < ApplicationController
def index
@budgets = Budget.where(user_id: current_user.id)
end
def show
@new_budget = Budget.new
@budgets = current_user.budgets
@budgets_in_order = Budget.order(:budget_date).where(user_id: current_user.id)
@current_year_budgets = @budgets.sel... |
class AddClumnToGroupUser < ActiveRecord::Migration
def change
add_column :group_users, :role, :string, null: false, default: 'member'
add_column :group_users, :status, :string, null: false, default: 'inviting'
end
end
|
class AddPublicColumnToChatroomTable < ActiveRecord::Migration[5.2]
def change
add_column :chatrooms, :public, :boolean
end
end
|
class Mms::ToolCategory < ActiveRecord::Base
self.table_name = "mms_tool_categories"
has_many :mms_tools, :foreign_key => "mms_tool_category_id", :class_name=>"Mms::Tool", :dependent => :destroy
validates_presence_of :name, :message => '不能为空'
named_scope :apps, :conditions=>["mms_tool_categories.tp = 1"]
n... |
class Admin::FeedsController < ApplicationController
layout 'admin'
# 需要管理员权限
before_action :require_is_admin
def index
# 设置当前时间
@current_time = Time.now
@teams = Team.includes(:users).all.order_by_name
if params[:start_date].present? and params[:end_date].present?
@start_date = Time.pa... |
class ApplicationController < ActionController::Base
protect_from_forgery
include ApplicationHelper
before_filter :authenticate_user!
def ADMIN!
return redirect_to root_url if !current_user.admin?
end
end
|
class TuanShopsController < ApplicationController
before_action :current_shop, only: [:destroy, :edit, :update, :show]
def show
@comments = TuanDealComment.where(tuan_deal_id: params[:id])
end
def new
@shop = TuanShop.new
end
def create
@shop = TuanShop.new(shop_params)
if @shop.save
... |
class CreateEntertainmentActivities < ActiveRecord::Migration
def change
create_table :entertainment_activities do |t|
t.integer :business_liability_policy_id
t.integer :entertainment_activity_type_id
t.integer :times_per_week
t.timestamps null: false
end
end
end
|
# frozen_string_literal: true
module TrustDock
module Callbacks
class RequestAuthentication < TrustDock::Callbacks::Base
def update
@authentication.update!(status: Authentication.statuses[@params['result']])
AuthenticationMailer.result(
authentication: @authentication,
re... |
class UserMailer < ActionMailer::Base
default :from => "admin@spark.com"
def welcome_email(email)
@email = email
mail(:to => email, :subject => "Please make your payment.")
end
end
|
require "fpm/namespace"
require "fpm/source"
require "rubygems/package"
require "rubygems"
require "fileutils"
require "tmpdir"
require "json"
class FPM::Source::Python < FPM::Source
def self.flags(opts, settings)
settings.source[:python] = "python"
settings.source[:easy_install] = "easy_install"
opts.o... |
class OrdersServicePlan < ActiveRecord::Base
belongs_to :order
belongs_to :service_plan
end
|
class GraduationThresholdsPage < SitePrism::Page
element :update_button, :xpath, ".//a[@title='Update']"
def clickButton(button)
case button
when 'Update' then
update_button.click
else
fail(ArgumentError.new("'#{button}' button is not listed!"))
end
end
def saveTasksPerSta... |
class Photo < ApplicationRecord
#Mounts paperclip image
has_attached_file :image
has_and_belongs_to_many :annotations
#refers to several tables and referred by
#This validates the type of file uploaded. According to this, only images are allowed.
validates_attachment_content_type :image, content_typ... |
module Isomorfeus
if RUBY_ENGINE == 'opal'
class << self
attr_accessor :on_browser
attr_accessor :on_ssr
attr_accessor :on_server
attr_accessor :on_desktop
attr_accessor :on_mobile
attr_accessor :on_tablet
attr_accessor :on_tv
def on_browser?
# true if runn... |
class PublisherSerializer < ActiveModel::Serializer
attributes :name, :links
#has_many :artists
#has_many :albums
def links
[{rel: :self, href: api_publisher_url(object.cached)},
{rel: :artists, href: object.cached_artists.map { |artist| {href: api_artist_url(artist)} }},
{rel: :albums, href: ob... |
require_relative '../lib/crypto'
describe "the crypto_scrapper method" do
it "the crypto_scrapper method should not be equal to nil and must be a Array" do
expect(crypto_scrapper).not_to be_nil
expect(crypto_scrapper).is_a?(Array)
end
end
|
module AdiosNaco
class Game
include DataMapper::Resource
property :id, Serial, :key => true
property :first_tick, EpochTime, :default => lambda{|r,p| Time.at(r.next_tick) }
property :version, String, :default => lambda{|r,p| AdiosNaco::VERSION }
property :player1, String... |
require 'test_helper'
class CarrersControllerTest < ActionDispatch::IntegrationTest
setup do
@carrer = carrers(:one)
end
test "should get index" do
get carrers_url
assert_response :success
end
test "should get new" do
get new_carrer_url
assert_response :success
end
test "should cre... |
# frozen_string_literal: true
RSpec.describe MockClasses::TestWorker do
let!(:arr) { %i[one] }
let!(:notifications) { [] }
let(:args) do
{
arr: arr,
notifications: notifications
}
end
describe 'run!' do
subject { described_class.run!(args) }
it { is_expected.to be_an_instance_o... |
class UIImageView
def remote_image=(value)
if !!defined?(SDWebImageManager)
@remote_image_operations ||= {}
# Cancel the previous remote operation if it exists
operation = @remote_image_operations[("%p" % self)]
if operation && operation.respond_to?(:cancel)
operation.cancel
... |
class Team < ActiveRecord::Base
belongs_to :group
has_many :match_participations
has_many :matches, through: :match_participations do
def as_home
where( match_participations: { role: 0 } )
end
def as_guest
where( match_participations: { role: 1 } )
end
end
end
|
#!/opt/chefdk/embedded/bin ruby
require 'json'
require 'rubygems'
require 'yaml'
opt_search_query = ARGV[0]
class Node
attr_accessor :node_name, :chef_environment, :host_name,:public_host_name,:os_family
def initialize (node_name,chef_environment,host_name,public_host_name,os_family)
@node_name = no... |
=begin
Write your code for the 'Rna Transcription' exercise in this file. Make the tests in
`rna_transcription_test.rb` pass.
To get started with TDD, see the `README.md` file in your
`ruby/rna-transcription` directory.
=end
class Complement
def self.of_dna dna
# check if dna includes invalid input
if dna =... |
class ActsAsDataTableGenerator < Rails::Generator::NamedBase
def manifest
record do |m|
m.file File.join('assets', 'js', 'acts_as_data_table.js'), File.join('public', 'javascripts', 'acts_as_data_table.js')
end
end
protected
def banner
"Usage: #{$0} acts_as_data_table js"
end
end
|
# frozen_string_literal: true
class ProductTeam < ApplicationRecord
validates :name, presence: true
has_many :users, dependent: :restrict_with_error
end
|
# David Lin
# Method: Just search the string step by step with word_dict.
# TLE
# @param {String} s
# @param {String[]} word_dict
# @return {String[]}
def word_break(s, word_dict)
[].tap{ |result| _search(s, word_dict, [], result) }
end
private def _search(s, word_dict, trace, result)
return result << trace.joi... |
class ImagesController < ApplicationController
before_filter :admin_filter
skip_before_filter :admin_filter, :only => [:show, :show_style]
def index
@images = Image.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @home_posts }
end
end
def show
@... |
class AddCarInformationToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :make, :string
add_column :users, :model, :string
add_column :users, :year, :date
end
end
|
# -*- encoding : utf-8 -*-
class Picture < ActiveRecord::Base
has_attached_file :photo, :styles => {
:main => "320x520",
:medium => '320x500#',
:thumb => '100x100#'
},
:url => '/system/photos/:id/:style/:filename',
:path => 'public/system/photos/:id/:style/:filename',
:dependent => :destroy
... |
class CommentsController < ApplicationController
before_filter :authorize, except: [:index, :show]
# show all comments in db
def index
@comments = Comment.all
render :index
end
# form to create new comment
# belongs to user
def new
@comment= Comment.new
render :new
end
# creates new ... |
class BidsController < ApplicationController
before_action :set_auction
# before_action :authenticate_user!
before_action :set_item
before_action :set_bid, only: [:show, :edit, :update, :destroy]
# GET /bids
# GET /bids.json
def index
@bids = @item.auction.bids
end
# GET /bids/1
# GET /bids/1.... |
class CreateAOrderDetails < ActiveRecord::Migration
def change
create_table :a_order_details do |t|
t.integer :a_order_id #订单id
t.integer :a_product_id #商品id
t.float :price #价格
t.float :o_price #原价
t.integer :count #数量
t.float :sum #总金额
t.time... |
# spec/spec_helper.rb
require 'rspec'
require 'capybara'
require 'capybara/dsl'
require 'dm-rspec'
require "rack_session_access"
require "rack_session_access/capybara"
require 'capybara/poltergeist'
ENV['RACK_ENV'] = 'test'
require File.expand_path '../../app.rb', __FILE__
module RSpecMixin
include R... |
class StaticPagesController < ApplicationController
def root
redirect_to new_session_url unless logged_in?
end
def home
end
end
|
require_relative 'app/proto/Products_services_pb'
class ProductsService < Rpc::Products::Service
include Gruf::Service
##
# @param [Demo::GetJobReq] req The incoming gRPC request object
# @param [GRPC::ActiveCall] call The gRPC active call instance
# @return [Rpc::GetProductResp] The response
#
def get... |
module Api
module V1
class MoviesController < BaseController
skip_before_action :set_resource
def index
@movies = @parser.get_movies
end
def show
movie = @parser.get_movie(params[:id])
unless movie
@errors = {
movie: 'Movie doesn\'t exists'
... |
module Fonepaisa
class PaymentRequestURL < Client
def execute
hash_key = secure_hash_key(request_params)
response = RestClient.post(
"#{BASE_URL}/getpaymentrequesturl",
request_params.merge(hash: hash_key)
)
response.body
end
end
end
|
class CreateMatches < ActiveRecord::Migration[6.1]
def change
create_table :matches do |t|
t.references :rule, null: false, foreign_key: true
t.references :eventable, null: false, :polymorphic => true
t.string :match_type, null: false
t.string :status, default: "pending"
t.timestamp ... |
# frozen_string_literal: true
module Brigitte
#
# A Deck generates and shuffles all cards except Joker.
# Joker is not used in Brigitte
class Deck
attr_accessor :cards
SIGNS = %w[♣ ♦ ♥ ♠].freeze
PREFIX = %w[2 3 4 5 6 7 8 9 10 J Q K A].freeze
def initialize
@cards = PREFIX.map do |prefix... |
class CreateAnalyses < ActiveRecord::Migration
def self.up
create_table :analyses do |t|
t.string :name, :null => false
t.string :part_name
t.string :machine_name
t.date :date
t.text :description
t.string :image_file_name
t.string :image_content_type
t.integer :imag... |
RSpec.describe Knuckles::Stages::Dumper do
describe ".call" do
it "dumps a tree of objects" do
objects = {
author: {id: 1, name: "Ernest"},
posts: [
{id: 1, title: "great"},
{id: 2, title: "stuff"},
{id: 2, title: "stuff"}
],
tags: [
{i... |
class Comment < ActiveRecord::Base
belongs_to :article
before_save { self.body = body.downcase }
validates :body, length: { minimum: 6 }
end
|
class ApiController < ActionController::Base
protect_from_forgery with: :null_session
include Pundit
include DeviseTokenAuth::Concerns::SetUserByToken
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
before_action :set_locale
def set_locale
I18n.locale = current_api_v1_user&.locale ... |
class SeeksController < ApplicationController
before_action :set_user, only: [:index, :destroy]
before_action :require_login, only: [:index, :create, :destroy]
def index
@secrets = Seek.all
end
def create
seek = Seek.new(get_seek_info)
if seek.valid?
seek.save
#"/users/#{@user.id}"
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.