text stringlengths 10 2.61M |
|---|
class String
# take a snake_cased string and make it space separated
def unsnake
self.split('_').join(' ')
end
end
|
# Calls block with two arguments,
# the item and its index, for each item in enum.
# Given arguments are passed through to each().
hash = {}
%w(cat dog wombat).each_with_index { |item, index|
hash[item] = index
}
p hash #=> {"cat"=>0, "dog"=>1, "wombat"=>2}
|
require 'rails_helper'
# #################################################################
#
#
#
# ----------------------------------------------------------------
feature 'Collection Items' do
background do
unless Spree::Store.exists?
FactoryGirl.create(:store)
end
product = crea... |
require "spec_helper"
module Envconfig
describe "finding a provider" do
let(:env) { {} }
let(:providers) { [] }
subject(:provider) do
Provider.find(env, providers)
end
context "with assorted providers" do
class InvalidProvider
def initialize(env); end
def valid?; fa... |
require 'spec_helper'
load Rails.root.join('lib', 'tasks', 'machine_learning', 'photo.rb').to_s
describe MachineLearning::Photo do
let(:dataset) { build(:dataset) }
let(:path) { dataset.filename }
let(:photo) { described_class.new(path) }
let(:pixel) { photo.pixel(x, y) }
let(:pixels) { photo.pixels }
des... |
class ShowEpisode < ActiveRecord::Base
self.table_name = "shows_episode"
outpost_model
has_secretary
include Concern::Scopes::SinceScope
include Concern::Associations::ContentAlarmAssociation
include Concern::Associations::AudioAssociation
include Concern::Associations::AssetAssociation
include Concern... |
class UsersController < ApplicationController
before_action :authenticate_user!
def index
@arts = Art.where(user_id: current_user.id)
@rooms = Room.user_rooms(current_user.id)
end
end
|
require 'xsd/qname'
# {http://www.jin.gr.jp/~nahi/xmlns/sample/Person}Person
class Person
@@schema_type = "Person"
@@schema_ns = "http://www.jin.gr.jp/~nahi/xmlns/sample/Person"
@@schema_element = [["familyname", ["SOAP::SOAPString", XSD::QName.new(nil, "familyname")]], ["givenname", ["SOAP::SOAPString", XSD::QN... |
module ScoresHelper
BAD_WORDS = ['shit','crap','useless','poo','bad','arse','awful','sucked','balls']
# Loop over the bad words and return the result
def check_for_bad_words(tweet)
tweet_text = tweet.text
BAD_WORDS.each do |w|
if tweet_text.include? w
return true
end
end... |
class ChangeIntToFloat < ActiveRecord::Migration
def self.up
change_column :scores, :score, :float
end
def self.down
change_column :scores, :score, :integer
end
end
|
RSpec.shared_examples 'exchange_information_schema' do
let(:schema) do
{
timezone: 'UTC',
serverTime: a_kind_of(Integer),
rateLimits: [{
rateLimitType: 'REQUESTS',
interval: 'MINUTE',
limit: 1200
... |
class GraphqlController < ApplicationController
# Ignore CSRF, rely on some auth token
protect_from_forgery except: [:create]
def create
query_string = params[:query]
query_variables = params[:variables] || {}
query = GraphQL::Query.new(GraphqlSchema, query_string, variables: query_variables)
ren... |
module CDI
module V1
module SerializerConcerns
module PostAbuseSerializer
extend ActiveSupport::Concern
included do
attributes :total_abuses,
:abused
end
def abused
scope && scope.post_abuses.where(post: object).exists?
end
... |
require 'bundler'
Bundler::GemHelper.install_tasks
require "rspec/core/rake_task"
namespace :spec do
types = [:unit]
types.each do |type|
desc "Run #{type} specs only"
RSpec::Core::RakeTask.new(type) do |spec|
spec.pattern = "spec/#{type}/**/*_spec.rb"
end
end
desc "Run All Specs"
task :a... |
require_relative('../db/sql_runner')
class Album
attr_reader :id, :artist_id
attr_accessor :name, :genre
def initialize(options)
@id = options["id"].to_i if options["id"]
@name = options["name"]
@genre = options["genre"]
@artist_id = options["artist_id"].to_i
end
def save
sql = "INSER... |
class UsuariosController < ApplicationController
before_action :usuario_logado, only: [:index, :edit, :update, :destroy,
:seguindo, :seguidores]
before_action :usuario_correto, only: [:edit, :update]
before_action :usuario_admin, only: :destroy
def index
@usuarios = ... |
require 'net/http'
require 'json'
# pass in limit: 5 to get the top 5 errors
def get_honeybadger_errors(options = {})
api_token = ENV['HONEYBADGER_TOKEN']
project_id = options[:project_id]
url = "https://app.honeybadger.io/v2/projects/#{project_id}/faults?q=environment:production"
url += "&order=#{options[:or... |
require 'rails_helper'
describe 'TranslationsController', api_request: true do
let!(:sevadaar) { create :sevadaar }
describe 'listing all translations' do
let!(:baani) { create :the_verses }
api_url(:get, '/api/v1/baanis/:baani_slug/translations')
context 'when not authenticated' do
it_behaves_... |
class Sieve
attr_reader :number
def initialize(number)
@number = number
end
def primes
(2..number).select { |num| is_prime?(num) }
end
private
def is_prime?(num)
(2...num).each do |ele|
return false if num % ele == 0
end
true
end
end
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Logging
describe Debug do
let(:described) { Vedeu::Logging::Debug }
before do
File.stubs(:open).with(Dir.tmpdir + '/vedeu_profile', 'w').returns(:some_code)
end
describe '.debug' do
let(:_binding... |
class BusinessCategory < ActiveRecord::Base
belongs_to :business
belongs_to :category
validates :business_id, presence: true, length: {minimum: 1, maximum: 20 }
validates :category_id, presence: true, length: {minimum: 1, maximum: 20 }
#for now ignore the bottom code
def self.by_nameB(name)
if !name.empty?
self.... |
require 'rails_helper'
RSpec.describe "/tags", type: :request do
describe "GET" do
let!(:tags) {create_list(:tag, 10)}
before {get '/api/v1/tags'}
after {expect_code_200}
it "returns status code 200" do
end
it "returns all Tags" do
expect(response.body).to have_json_size(tags.... |
class AddAddressesTable < ActiveRecord::Migration[5.2]
def change
create_table :addaddresses do |t|
t.integer :company_id
t.string :street
t.string :street2
t.string :street3
t.string :city
t.string :state
t.string :postal_code
t.string :country
t.string :coun... |
require "formula"
require "options"
module Homebrew
def options
if ARGV.include? "--all"
puts_options Formula.to_a
elsif ARGV.include? "--installed"
puts_options Formula.installed
else
raise FormulaUnspecifiedError if ARGV.named.empty?
puts_options ARGV.formulae
end
end
d... |
class Array
def to_event
event = MessagePack.unpack(self.pack('C*'), symbolize_keys: false)[0]
{action: event[0], payload: event[1]}
end
end
class String
def to_event
event = JSON.parse(self, symbolize_keys: false)[0]
{action: event[0], payload: event[1]}
end
end
module Helpers
def config_f... |
class AddInvestmentIdToFavs < ActiveRecord::Migration
def change
add_reference :favs, :investment, index: true
add_foreign_key :favs, :investments
end
end
|
namespace :notification_system do
namespace :notifications do
# UNTESTED
desc "Creates and delivers pending notifications"
task :deliver => :environment do
begin
NotificationSystem::NotificationTypeSubscription.create_scheduled_notifications
NotificationSystem::Notification.deliver_p... |
class AddBlurbToCases < ActiveRecord::Migration
def change
add_column :cases, :blurb, :text
end
end
|
class Entities::SubEntities::InvoiceMapper
extend HashMapper
extend MapperHelper
def self.invoice_references
{
record_references: %w(person_id lines/item_id),
id_references: %w(lines/id)
}
end
STATUS_MAPPING_INV = {
'authorized' => 'AUTHORISED',
'pending' => 'DRAFT',
'paid' =... |
class Bank < ActiveRecord::Base
attr_accessible :access, :collaboration, :description, :name, :type
validates :access, :presence => true
validates :name, :presence => true
has_many :bank_files
has_many :sound_files, :through => :bank_files
has_many :luser_banks
has_many :lusers, :through => :luser_ba... |
# == Schema Information
#
# Table name: papers
#
# id :integer not null, primary key
# self_order :integer
# year :integer
# venue :text
# downloads :integer
# likes :integer
# created_at :datetime not null
# updated_at :d... |
#!/usr/bin/env ruby
=begin
RANKING POKER HANDS
This program was developed as a challenge by MoneyPool Co.
Exercise instructions
Write a program to evaluate poker hands and determine a winner.
Your program should accept hands in the following representation:
# This is a hand with
# an Ace of spades,
# a Kin... |
class Sudoku
attr_accessor :boxes, :unsolved_rows, :unsolved_columns, :unsolved_squares, :possible_solutions, :initial
def initialize(vals)
if vals.kind_of?(String)
vals = vals.split(',').map { |s| s.to_i }
end
raise ArgumentError.new('Sudokus have 81 boxes') if vals.length != 81
boxes = []
... |
require 'spec_helper'
require 'pry'
describe Adapter::Facebook::To::Schema::Like do
describe ".new" do
before do
@argument = stub 'argument'
end
it "should accept an argument" do
Adapter::Facebook::To::Schema::Like.any_instance.stub :coerce
Adapter::Facebook::To::Schema::Like.new ... |
require 'rspec'
require 'pry'
def merge_sort(array)
if array.length <= 1
return array
else
left_array = array[0...array.length/2]
right_array = array[array.length/2..-1]
return merge_sorted_arrays(merge_sort(left_array), merge_sort(right_array))
end
end
def merge_sorted_arrays(array1, array2)
... |
# Rails helper for Unobtrusive Flash Object (UFO).
#
# By Artūras Šlajus <x11@arturaz.net>
#
# $Id$
#
module Arturaz
module UfoHelper
# Makes UFO put _movie_ into _target_ div (by id). Passes _options_ to
# UFO.
#
# Default options:
# :width - 300
# :height - 120
# :... |
module Vanity
module Adapters
class << self
# Creates and returns new MockAdapter.
#
# @since 1.4.0
def mock_connection(spec)
MockAdapter.new(spec)
end
end
# Mock adapter. You can use this when running in test environment, staging,
# wherever you don't care for c... |
class CreateFamilyUsers < ActiveRecord::Migration[5.0]
def change
create_table :family_users, id: :bigserial do |t|
t.belongs_to :family, null: false, index: true
t.string :name, null: false
t.string :last_names, null: false
t.timestamps
end
add_foreign_key :family_users, :familie... |
require 'spec_helper'
describe "32386029 has_sage_flow_states takes in bootstrap badges and adds instance method to get the current object's badge type and color" do
before(:each) do
class Foo6029 < Sample
has_sage_flow_states :new, open: {badge: "warning"}, saved: {badge: "info"}, locked: {badge: "success... |
RSpec.describe "PUT /api/articles/:id", type: :request do
let(:user) { create(:user)}
let(:user_credentials) { user.create_new_auth_token}
let!(:article) { create(:article, title: 'old title', body: 'old body') }
describe "User is signed in and can update article" do
before do
put "/api/articles/#{ar... |
class RemoveDefaultSettingForCanInvite < ActiveRecord::Migration
def change
change_column :project_members, :can_invite, :boolean, :default => nil
end
end
|
# encoding: utf-8
#
# This file is part of the mamertes gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#
require "pathname"
require "simplecov"
require "coveralls"
Coveralls.wear! if ENV["CI"] ||... |
require 'actiontypedef'
require 'gamestatepawn'
class ActionQueue
attr_accessor :action_queue, :gamestatePawns
def initialize(gamestate)
@gamestate = gamestate
@pawns = Pawn.find_all_by_gamestate_id(@gamestate.id)
@action_queue = Array.new
@init_votes = Array.new
end
d... |
class LockController < ApplicationController
include SwaggerLockController
def lock
unlock_token = User.send_unlock_instructions(lock_params)
if !unlock_token.nil?
render json: {
unlock_token: unlock_token,
message: I18n.t("lock.lock")
}
else
render_error I18n.t("fail... |
require File.dirname(__FILE__) << '/test_helper'
class FilterTest < Minitest::Test
describe 'Filtering Documents' do
it 'filters through Textile' do
doc = document('text.textile', filter: 'textile')
source = doc.source(binding)
assert source.include?('\item')
end
# FIXME temporary sk... |
class CreateMeters < ActiveRecord::Migration[6.0]
def change
create_table :meters do |t|
t.integer :max_stay
t.string :meter_type
t.float :cost
t.boolean :in_use
t.float :latitude
t.float :longitude
t.string :free_time
t.timestamps
end
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commen... |
class AddLevelToUsers < ActiveRecord::Migration
def change
add_column :users, :level, :integer,default: 1, null: false
end
end
|
# frozen_string_literal: true
RSpec.describe API::Actions::Books::Unsubscribe do
let(:params) { Hash[] }
it "works" do
response = subject.call(params)
expect(response).to be_successful
end
end
|
class FavoritesController < ApplicationController
def index
# favorites = Favorite.all
# render json: favorites, include:[:user]
if params[:user_id] # from /users/:user_id/movies fetch request
user = User.find_by(id: params[:user_id])
if user
favorites = user.favorites
else
... |
class Train < ActiveRecord::Base
validates :number, presence: true
belongs_to :current_station, class_name: 'RailwayStation', foreign_key: :current_station_id
belongs_to :route
has_many :tickets
has_many :wagons
def coupe_wagons
wagons.coupe_count
end
def reserved_seat_wagons
wagons.reserved... |
class DayController < ApplicationController
before do
if !session[:logged_in]
session[:message] = {
success: false,
status: "neutral",
message: "You must be logged in to do that"
}
redirect '/users/login'
end
end
# HOME PAGE FOR USERS
get(... |
class DevBox
def DevBox.configure(config, settings)
config.vm.box = settings["box"] ||= "devbox"
config.vm.box_url = settings["box_url"] ||= "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.hostname = settings["host... |
require "fizzbuzz"
describe 'returns number' do
it "returns the argument 'number' when neither fizz, buzz or fizzbuzz is applicable" do
expect(fizzbuzz(4)).to eq 4
end
end
describe 'fizz' do
it "returns 'fizz' when multiplier of 3 is passed to number" do
expect(fizzbuzz(3)).to eq 'fizz'
end
end
des... |
require 'rubygems'
require 'rsolr'
require 'rsolr-ext'
require 'json'
module Stanford
#this script is used to verify that the proper values are in Solr.
class SolrCheckr
attr_accessor :zotero_xml
attr_accessor :zotero_ingest
attr_accessor :solr
attr_accessor :report
def initialize(zo... |
class User < ApplicationRecord
has_many :events
has_many :comments
has_secure_password
end
|
require "json"
require "rest-client"
require "darksky/version"
require "darksky/configuration"
require "darksky/client"
require "darksky/entity"
require "darksky/flag"
require "darksky/forecast"
require "darksky/forecast_period"
module Darksky
class << self
def configure
yield(configuration)
end
... |
class GoogleMaps
include ActiveSupport::Inflector
def image(lat, long)
"https://maps.googleapis.com/maps/api/staticmap?key=#{ENV['MAPS_API_KEY']}&size=400x200&markers=#{lat},#{long}&scale=2"
end
def location(location)
Rails.cache.fetch("google_maps:v2:#{parameterize(location)}", expires_in: 30.days) d... |
require 'rubygems'
require 'nokogiri'
require 'kconv'
require "open-uri"
require 'kakasi'
require 'csv'
require 'mechanize'
class String
def sjisable
str = self
#変換テーブル上の文字を下の文字に置換する
from_chr = "\u{301C 2212 00A2 00A3 00AC 2013 2014 2016 203E 00A0 00F8 203A}"
to_chr = "\u{FF5E FF0D FFE0 FFE1 FFE2 FF0D... |
require_relative '../simple_finder'
describe SimpleFinder do
describe '#include?' do
let(:board_data) do
[['F', 'A', 'N', 'G'],
['E', 'E', 'O', 'N'],
['N', 'N', 'E', 'O'],
['E', 'D', 'O', 'S']]
end
let(:board) { double("board", { :board => board_data }) }
let(:finder) { S... |
class FontTexGyreTermes < Formula
version "2.004"
sha256 "5d467d8db17c96037b04409d682f071d7cc33cf94eda35a0a0465776a2c862b2"
url "http://www.gust.org.pl/projects/e-foundry/tex-gyre/termes/qtm#{version}otf.zip"
desc "TeX Gyre Termes"
homepage "http://www.gust.org.pl/projects/e-foundry/tex-gyre/termes"
def ins... |
class Exercise < ActiveRecord::Base
has_and_belongs_to_many :trainings
has_and_belongs_to_many :categories
end
|
require 'deject'
require 'fileutils'
require 'prodder/pg'
require 'prodder/git'
module Prodder
class Project
SeedConfigFileMissing = Class.new(StandardError) do
attr_reader :filename
def initialize(filename); @filename = filename; end
end
Deject self
dependency(:pg) { |project| Prodder:... |
class Movie < ActiveRecord::Base
validates :title, :release, presence: true
validates :descrption, :length => { minimum: 25 }
validates :total_gross, numericality: {only_integer: true, greater_than: 0}
def flop?
self.total_gross.blank? || self.total_gross < 50000000
end
def self.past
where("release <= ?", Time.... |
module Antlr4::Runtime
class DiagnosticErrorListener < BaseErrorListener
def initialize(exact_only = true)
@exact_only = exact_only
end
def report_ambiguity(recognizer, dfa, start_index, stop_index, exact, ambig_alts, configs)
return if @exact_only && !exact
format = "reportAmbiguity d... |
class Booking < ActiveRecord::Base
belongs_to :flight
has_many :passengers
accepts_nested_attributes_for :passengers
end
|
require 'data_mapper' unless defined?DataMapper
require 'ysd_md_translation' unless defined?Model::Translation::Translation
module Yito
module Model
module Booking
module Translation
#
# Pickup/return place translation
#
class BookingPickupReturnPlaceTranslation
i... |
require 'rspec'
require 'number_words'
describe('#numbers_to_words') do
it("should return the word equivalent of 1") do
num = NumberWords.new(2)
expect(num.numbers_to_words(num)).to(eq('two'))
end
it("should return the word equivalent of numbers from 1 to 9") do
num = NumberWords.new(9)
expect(num.nu... |
# Controls email from the 'contact me' section
class ContactMailer < ActionMailer::Base
default from: 'contactme@matt-schneider.com'
def contact_me(message)
@message = message
mail to: 'matts3@u.washington.edu',
subject: 'matt-schneider.com Contact Message'
end
end
|
class Category < ActiveRecord::Base
belongs_to :manufacturer
has_many :products
enum presence: [:present, :absent]
validates_presence_of :title
end
|
class CreateSubSeddits < ActiveRecord::Migration
def change
create_table :sub_seddits do |t|
t.string :name, null: false
t.integer :owner_id, null: false
t.timestamps
end
add_index :sub_seddits, :name
add_index :sub_seddits, :owner_id
end
end
|
# frozen_string_literal: true
require 'colored'
# creates key for a given user
class Delete
class << self
def delete_iam_key(iam, username, keys)
keys.each do |key|
puts "Deleting #{key} key from #{username}..."
iam.delete_access_key(
access_key_id: key,
user_name: user... |
Rails.application.routes.draw do
root "static_pages#home"
resources :books, only: %i(show index) do
resources :comments, only: %i(create destroy)
end
devise_for :users
resources :users, only: :show
resources :books
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
(1..3).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.box = "centos/7"
end
config.vm.provider :libvirt do |libvirt|
libvirt.graphics_type = "none"
libvirt.memory = 2048
end
end
config.vm.pr... |
require 'spec_helper'
require 'phobos/cli'
RSpec.describe Phobos::CLI::Start do
describe '#execute' do
it 'validates config file' do
start = Phobos::CLI::Start.new(config: 'invalid/path', boot: 'phobos_boot.rb')
expect { start.execute }.to raise_error SystemExit
end
it 'calls Phobos.configur... |
class CreateCourseItems < ActiveRecord::Migration
def change
create_table :course_items do |t|
t.references :word, index: true
t.references :course, index: true
t.timestamps
end
end
end
|
class Task
attr_reader :content, :id
@@current_id = 1
def initialize(content)
@content = content
@id = @@current_id
@@current_id += 1
@completed = false
end
def complete!
@completed = true
end
def complete?
@completed = true
end
def make_incomplete!
@comple... |
module GeoCombine
##
# Mixin used for formatting metadata fields
module Formatting
##
# Sanitizes html from a text input
# @param [String] text
# @return [String]
def sanitize(text)
Sanitize.fragment(text)
end
##
# Removes line breaks from a text input
# @param [String] ... |
class Item < ApplicationRecord
mount_uploader :image_url, ImageUploader
belongs_to :campaign
def price_for_current_amount
current_amount * price
end
end
|
class CreateLearningTrackReviews < ActiveRecord::Migration
def change
create_table :learning_track_reviews do |t|
t.references :learning_track, index: true
t.references :user, index: true
t.text :comment
t.integer :review_type
t.timestamps null: false
end
add_index :learning... |
class BraintreeService
attr_reader :nonce, :amount
def initialize(nonce, amount)
@nonce = nonce
@amount = amount
end
def run
Braintree::Transaction.sale(
:amount => amount,
:payment_method_nonce => nonce,
:options => {
:submit_for_settlement => true
}
)
end
en... |
class Share < ActiveRecord::Base
belongs_to :media
belongs_to :user
validates_uniqueness_of :user_id, :scope => [:media_id]
end
|
# frozen_string_literal: true
class Resource::Connection::Author < ApplicationRecord
belongs_to :resource
belongs_to :author
end
|
def whyrun_supported?
true
end
use_inline_resources
action :create do
service "avahi-daemon" do
service_name node['avahi-daemon']['service']['name']
action :nothing
end
template "/etc/avahi/services/#{new_resource.name}.service" do
source 'service.erb'
cookbook 'avahi-daemon'
mode new_re... |
class Query
def initialize( lb, path )
@lb = lb
@path = path
@include = []
@params = {}
end
def arguments( params )
@params.merge!( params )
self
end
def query( params )
@params[:query ] = params
self
end
def include( assoc )
@params[:include] = ... |
class User < ApplicationRecord
validates_presence_of :email,
:password
has_secure_password
has_secure_token :api_key
end
|
class User < ActiveRecord::Base
TEMP_EMAIL_PREFIX = 'change@me'
TEMP_EMAIL_REGEX = /\Achange@me/
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable... |
require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user= FactoryGirl.create(:user)
end
describe "creation" do
it "can be created" do
expect(@user).to be_valid
end
it "cannot be created without first_name and last_name, phone_no" do
@user.first_name = n... |
module Playercenter::Backend
class Connection
attr_reader :auth, :graph, :devcenter, :cache
def self.create
new(
ENV['QS_AUTH_BACKEND_URL'] || 'http://auth-backend.dev',
ENV['QS_GRAPH_BACKEND_URL'] || 'http://graph-backend.dev',
ENV['QS_DEVCENTER_BACKEND_URL'] || 'http://devcent... |
module AuditProblem
class Base
include Mongoid::Document
field :_id, :type => BSON::ObjectId
embedded_in :audit, :inverse_of => :audit_problems
def self.perform(options = {})
audit = Audit.new(:type => self.to_s)
audit.started_at = Time.now
audit.problems = run(options)
... |
name 'gitlab'
maintainer 'CeSPI - UNLP'
maintainer_email 'car@cespi.unlp.edu.ar'
license 'MIT'
description 'Installs/Configures gitlab'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'apt', "~> 1.10.0"
depends ... |
#require 'elasticsearch/model'
class Event < ActiveRecord::Base
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "150x150>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
validates :category, :location, :country, :... |
feature 'infrastructure test' do
scenario 'can run app and check page content' do
visit('/')
expect(page).to have_content ""
end
end
|
class UserMailer < ApplicationMailer
default from: "no-reply@jungle.com"
def order_receipt(current_user, order)
@user = current_user
@order = order
mail(to: @user.email, subject: "Thanks for ordering! Here's your receipt and order number: #{@order.id}.")
end
end
|
class CreateAdoptions < ActiveRecord::Migration[5.2]
def change
create_table :adoptions do |t|
t.references :customer, foreign_key: true
t.references :pet, foreign_key: true
t.integer :status, limit: 2, null: false, default: 1, :unsigned => true
t.timestamps
end
add_index :adoptio... |
class Character < ActiveRecord::Base
has_and_belongs_to_many :users, association_foreign_key: 'fb_user_id'
has_many :scenes, dependent: :destroy
validates :name, presence: true
validates :age, presence: true
validates :gender, presence: true
validates :description, presence: true
validates :add_on, inclusion: {... |
class CreateCarts < ActiveRecord::Migration
def change
create_table :carts do |t|
t.datetime :submitted_at
t.datetime :processing_payment_at
t.datetime :payment_processed_at
t.datetime :authorizing_payment_at
t.datetime :cancelled_at
t.float :payment_amount
t.belongs_to :... |
class FoundPetComment < ApplicationRecord
belongs_to :user
belongs_to :found_pet
end
|
class WelcomeController < ApplicationController
skip_before_action :is_signed_in, only: [:index]
def index
render 'games/index' unless current_user.nil?
end
end
|
# frozen_string_literal: true
module Gauss
# Gauss::Context holds errors, payload and messages of service ops
class Context
attr_reader :success, :errors, :messages, :payload
def initialize
@success = true
@errors = []
@messages = []
end
def fail!(error:)
@success = false
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.