text stringlengths 10 2.61M |
|---|
# encoding: UTF-8
require 'spec_helper'
RSpec.configure do |config|
config.platform = 'centos'
config.version = '6.4'
end
describe 'chef-dev-workstation::linux_setup' do
let(:adminuser) { 'admin' }
let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
before do
stub_command("rpm -q gcc").a... |
# app/inputs/wday_input.rb
# class WdayInput < SimpleForm::Inputs::Base
# def input
# @builder.select(attribute_name, I18n.t(:"date.day_names").each_with_index.to_a)
# end
# end
class DatePickerInput < SimpleForm::Inputs::Base
def input(wrapper_options)
@builder.text_field(attribute_name,input_html_optio... |
module ApplicationHelper
def avatar_attached?(id)
User.find(id).avatar.attached?
end
end
|
require 'minitest/autorun'
require File.expand_path("../../lib/cfiber.rb", __FILE__)
$DEBUG = false
class TestFiberInstance < MiniTest::Unit::TestCase
def setup
@fiber = Fiber.new do |first_resume|
puts first_resume
puts Fiber.yield(puts(1))
puts 'NEXT'
puts Fiber.yield(puts(2))
p... |
# frozen_string_literal: true
require 'tempfile'
require 'kubernetes-deploy/common'
require 'kubernetes-deploy/renderer'
module KubernetesDeploy
class RenderTask
def initialize(logger: nil, current_sha:, template_dir:, bindings:)
@logger = logger || KubernetesDeploy::FormattedLogger.build
@template_... |
# frozen_string_literal: true
class CoupeCarriage < Carriage
validates :top_seats, presence: true
end
|
require "spec_helper"
describe "The number allocator" do
before :each do
TestIds.send(:reset)
end
def a(name, options = {})
TestIds.current_configuration.allocator.allocate(name, options)
options
end
it "is alive" do
TestIds.configure do |config|
config.numbers.include << 3
end
... |
# encoding: utf-8
class Address < ActiveRecord::Base
# ASSOCIATIONS
belongs_to :addressable, :polymorphic => true
# ATTRIBUTES
attr_accessor :bypass_validation
attr_accessible :address1, :address2, :addressable_id, :addressable_type, :city, :country, :postal_code, :province, :bypass_validation
# VALID... |
require_relative '../spec_helper'
module PacketGen
module Plugin
class IKE
describe IDi do
describe '#initialize' do
it 'creates a IDi payload with default values' do
id = IDi.new
expect(id.next).to eq(0)
expect(id.flags).to eq(0)
expect(id.... |
class SearchController < ApplicationController
before_action :authenticate_user!
def index
if params[:search]
@articles = Article.search(params[:search])
.includes('hash_tags')
.includes('user')
else
@articles = Article.all
... |
#---
# Excerpted from "Rails 4 Test Prescriptions",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit ... |
class ChangeProjectsColumnDefaults < ActiveRecord::Migration
def up
change_column_default :projects, :how_to_url_block, '<a href="/docs/NITRO-Competitions_Instructions.pdf" title="NITRO-Competitions Web Site Instructions/Help/HowTo">Site instructions</a>'
change_column_default :projects, :rfp_url_block, '<a h... |
class RemoveCommutingStopReportIdId < ActiveRecord::Migration
def change
remove_column :commuting_stop_events, :commuting_stop_report_id_id, :integer
end
end
|
# frozen_string_literal: true
class AddApprovedAndVerfiedToAmbassadors < ActiveRecord::Migration[5.2]
def change
add_column :ambassadors, :approved, :boolean, default: false
add_column :ambassadors, :verified, :boolean, default: false
end
end
|
# frozen_string_literal: true
require 'sequel'
module MLBAtBat
module Database
# Object-Relational Mapper for games
class GameOrm < Sequel::Model(:games)
many_to_one :schedule,
class: :'MLBAtBat::Database::ScheduleOrm'
plugin :timestamps, update_on_create: true
end
e... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# The method of using a YAML config file for the actual VMs is heavily
# based on:
# https://github.com/miguno/wirbelsturm
# http://www.michael-noll.com/blog/2014/03/17/wirbelsturm-one-click-deploy-storm-kafka-clusters-with-vagrant-puppet/
#
Vagrant.require_version ">= 1.7.2"
... |
# $Id$
# My own little additions/fixes to ruby
# try() added in Rails 2.3 - use this till then
class Object
##
# @person ? @person.name : nil
# vs
# @person.try(:name)
def try(method)
unless self.nil?
send method if respond_to? method
end
end
end
# Possessify noun
# exmample:
# "John".... |
DataMapper.setup(:default, "sqlite://#{Dir.pwd}/db.sqlite")
class User
include DataMapper::Resource
include BCrypt
property :id, Serial, key: true
property :email, String, length: 128, format: :email_address, unique: true, message: 'Enter valid email'
property :phone_number, String, length: 64
property :g... |
# frozen_string_literal: true
#
# Copyright 2016 Infogroup, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applic... |
class FoodItem < ActiveRecord::Base
def image_url
if remote_image_url.present?
remote_image_url
else
"http://loremflickr.com/360/240/#{CGI.escape name}"
end
end
def self.search(search)
if search
where('name ILIKE ?', "%#{search}%")
else
all
end
end
end
|
class Api::V1::TokensController < ApplicationController
skip_before_filter :authenticate_user!
#skip_before_filter :verify_authenticity_token
respond_to :json
#To create (sign in) send an HTTP POST with http://localhost:3000/api/v1/tokens.json
#Content-Type: application/x-www-form-urlencoded
#Body:... |
class ChangeColumnToOrder < ActiveRecord::Migration[5.2]
def change
change_column :orders, :order_status, :integer, default: 0, null: false
change_column :order_items, :item_status, :integer, default: 0, null: false
end
end
|
Gem::Specification.new do |s|
s.name = 'cjsv'
s.version = '2.0.0'
s.date = '2014-04-28'
s.summary = "Coffeescript Views"
s.description = "HAML-like syntax that parses to a cs object"
s.authors = ["Pedro Bernardes"]
s.email = 'phec06@gmail.com'
s.files = ['lib/cjsv.r... |
require 'singleton'
module Swine
module Core
module Cache
class CacheBase
def initialize
@cache = Rails.cache
end
def exist?(key)
@cache.exist?(key)
end
def set(key, value)
@cache.write(key, value)
end
... |
require 'minitest/autorun'
require_relative 'spec_helper.rb'
require_relative '../myvocabulary_wordlist_scrapper.rb'
describe 'My Vocabulary Category' do
before do
VCR.insert_cassette 'myvocabulary'
end
after do
VCR.eject_cassette
end
it 'should return a list of categories bigger than 0' do
scr... |
require 'spec_helper'
describe Akephalos::Client, :platform => :jruby do
context "browser version" do
it "defaults to Firefox 3.6" do
client = Akephalos::Client.new
client.browser_version.should ==
HtmlUnit::BrowserVersion::FIREFOX_3_6
end
it "can be configured in the initializer" ... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :reload_rails_admin, if: :rails_admin_path?
include SessionsHelper
helper_method :current_user,
... |
namespace :puma do
desc 'Start puma'
task :start do
on roles(:app), in: :sequence, wait: 5 do
within current_path do
execute :bundle, "exec puma #{start_options} start", :pty => false
end
end
end
desc 'Stop puma'
task :stop do
on roles(:app), in: :sequence, wait: 5 do
w... |
# -*- 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|
# Vagrant box we are building off of
config.vm.box = "precise64"
# The url from where the 'config.vm.box... |
# frozen_string_literal: true
# rubocop:todo all
require 'lite_spec_helper'
describe Mongo::Monitoring::Event::ServerHeartbeatFailed do
let(:address) do
Mongo::Address.new('127.0.0.1:27017')
end
let(:monitoring) { double('monitoring') }
let(:cluster) do
double('cluster').tap do |cluster|
allo... |
require 'test_helper'
class GroupTest < ActiveSupport::TestCase
def setup
@group = Group.new(name: "Example Group Name")
end
test "should be valid" do
assert @group.valid?
end
test "name should be present" do
@group.name = " "
assert_not @group.valid?
end
test "name should be reson... |
require_relative '../synacor_vm.rb'
describe SynacorVm do
let(:input) { "9,32768,32769,4,19,32768" }
let(:vm) { SynacorVm.new(input) }
describe '#new' do
it "inits eight registers" do
expect(vm.registers.count).to eq(8)
expect(vm.registers[0]).to eq(0)
end
it "inits a program" do
... |
class Workout < ActiveRecord::Base
belongs_to :user
before_validation :set_defaults
validates :run, :bike, :swim, numericality: {greater_than_or_equal_to: 0}
validate :date_cannot_be_in_the_future
def date_cannot_be_in_the_future
if date > Date.today
errors.add(:date, "can't be in the future")
... |
require 'net/http'
require 'time'
require 'securerandom'
require 'uri'
require 'base64'
require 'hmac-sha1'
require 'json'
module Aliyun
class Service
attr_accessor :access_key_id, :access_key_secret
attr_accessor :options
attr_accessor :endpoint_url
attr_accessor :service
def initialize(options... |
class AddEmailSettingsToFirstSetup < ActiveRecord::Migration
def change
add_column :first_setups, :email_choice, :string
add_column :first_setups, :email_mailgun_api_key, :string
add_column :first_setups, :email_mailgun_domain, :string
end
end
|
require 'spec_helper'
RSpec.describe CommentsHelper do
let(:post) { double :post }
let(:comment) { double :comment }
before :each do
allow(helper).to receive(:post).and_return post
end
describe '#destroy_comment_link' do
it 'should return destroy comment link if user has ability' do
allow(hel... |
# encoding: utf-8
class TrackerResult < ActiveRecord::Base
attr_accessible :come, :day, :entry
validates :day, presence: true
def self.tracker_codes( d = Date.today )
self.where( created_at: d.beginning_of_day..d.end_of_day ).group(:tracker_code).pluck(:tracker_code)
end
def self.aggrigation( day = Da... |
# // --- Directions
# // Write something that accepts a string. It should
# // capitalize the first letter of each word in the string then
# // return the capitalized string.
# // --- Examples
# // capitalize('a short sentence') --> 'A Short Sentence'
# // capitalize('a lazy fox') --> 'A Lazy Fox'
# // capit... |
require 'test_helper'
class Payment
include GpWebpay::Payment
end
class PaymentTest < Minitest::Spec
let(:payment) { Payment.new }
it 'have all public methods' do
assert payment.respond_to?(:pay_url)
assert payment.respond_to?(:success?)
end
describe '#digest_verification' do
let(:params) do
... |
class Template < ActiveRecord::Base
belongs_to :user
mount_uploader :attachment, AttachmentUploader
mount_uploader :image, ImageUploader
validates :name, presence: true
validates :description, presence: true
end
|
# frozen_string_literal: true
module Raven
VERSION = "3.1.2"
end
|
class CreateDefaultNakkiTypeInfos < ActiveRecord::Migration
def up
NakkitypeInfo.create({:title => "Ticket Sales", :description => "You will sell tickets and count every sold ticket."})
NakkitypeInfo.create({:title => "Kiosk", :description => "You will sell/give refreshments. This is the most hectic Nakki."})... |
class Country < ActiveRecord::Base
self.table_name = "country"
def to_builder
Jbuilder.new do |country|
country.name name
end
end
end |
module SiteMapper
# Handles logging
class Logger
# Choose what logger to use by type.
# @return [Object] returns the appropiate logger.
# @param [Symbol] type of logger class to be used
def self.use_logger_type(type)
fail 'Logger already set' if defined?(@@log)
@@log = case type.to_s
... |
require 'spec_helper_acceptance'
test_name 'Augeasproviders Grub'
describe 'grub_test class' do
manifests = [
"class { 'grub_test::working': }",
"class { 'grub_test::failing': }"
]
manifests.each do |manifest|
let(:manifest){ manifest }
context "default parameters for #{manifest}" do
hos... |
class ContentTextsUser < ApplicationRecord
belongs_to :user
belongs_to :content_text
validates :user_id, uniqueness: { scope: :content_text_id }
validates :user, :content_text, presence: true
end
|
class CustomPagesController < ApplicationController
# GET /custom_pages
# GET /custom_pages.xml
def index
@custom_pages = CustomPage.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @custom_pages }
end
end
# GET /custom_pages/1
# GET /custom_page... |
include Adminpanel::RouterHelper
Adminpanel::Engine.routes.draw do
Adminpanel.displayable_resources.each do |resource|
case resource
when :analytics
resources :analytics, only: [:index] do
collection do
get :instagram, to:'analytics#instagram'
post "instagram/#{I... |
require "fog/core/collection"
require "fog/google/models/pubsub/subscription"
module Fog
module Google
class Pubsub
class Subscriptions < Fog::Collection
model Fog::Google::Pubsub::Subscription
# Lists all subscriptions that exist on the project.
#
# @return [Array<Fog::Goo... |
class ForzarUnicidadEnPrestamos < ActiveRecord::Migration
def change
add_index :prestamos, [:libro_id, :prestatario_id], unique: true
end
end
|
class AddSlugs < ActiveRecord::Migration
def self.up
add_column(:bus_line_places, :bairro_slug, :string, :size => 40)
add_column(:bus_line_places, :logradouro_slug, :string, :size => 35)
add_column(:bus_lines, :name_slug, :string, :size => 70)
begin
remove_index(:bus_line_places, :bairro)
... |
# -*- coding: utf-8 -*-
FactoryBot.define do
factory :program do
sequence(:program_name) { |n| "n#{n}_#{Time.now.to_i}" }
program_title 'MyString'
program_url 'MyString'
email 'test@test.com'
association :creator, factory: :user
created_ip '127.0.0.1'
created_at Time.now
end
end
|
class AddColumnStatusToRelease < ActiveRecord::Migration[5.0]
def change
add_column :releases, :status, :integer
end
end
|
module BestInPlace
module ControllerExtensions
def respond_with_bip(obj)
obj.changed? ? respond_bip_error(obj) : respond_bip_ok(obj)
end
private
def respond_bip_ok(obj)
if obj.respond_to?(:id)
klass = "#{obj.class}_#{obj.id}"
else
klass = obj.class.to_s
end
... |
require 'spec_helper'
describe "/questions/index.html.erb" do
include QuestionsHelper
before(:each) do
assigns[:questions] = [
stub_model(Question,
:prompt => "value for prompt",
:activity_id => 1
),
stub_model(Question,
:prompt => "value for prompt",
:activit... |
module LocationSteps
def current_path_should_be(expected_path)
expected_searches = searches(expected_path)
actual_searches = searches
current_path = [current_pathname]
if actual_searches.present?
actual_searches.each do |k, v|
actual_searches[k] = '*' if expected_searches[k] == '*'
... |
class AddTypeToSimpletask < ActiveRecord::Migration[5.0]
def change
add_column :simpletasks, :type, :string
end
end
|
# $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-... |
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.
require 'console/filter'
module MySubject
end
describe Console::Filter do
let(:output) {Console::Capture.new}
let(:logger) {Console::Logger.new(output)}
with '#off!' do
def before
super
logger.off!
... |
class Schema
def initialize(config)
@klass = define_class(config)
@schemas = {}
@connection = @klass.connection
@connection.tables.each do |table_name|
add_to_schema(config, table_name)
end
end
# Return names of all table columns
def get_table_attributes(table_name)
... |
require 'minarai/errors/base'
module Minarai
module Errors
class InvalidActionTypeError < Base
def initialize(name)
@name = name
end
def to_s
"`type` is required @ #{@name}"
end
end
end
end
|
# frozen_string_literal: true
require_relative '../rest/utils'
require_relative '../instance'
module Mastodon
module REST
module Instances
include Mastodon::REST::Utils
# Retrieve the current instance. Does not require authentication
# @return [Mastodon::Instance]
def instance
p... |
class FeaturedDrinksController < ApplicationController
def index
@drinks = Drinks.featured.page
end
end
|
class UsersController < ApplicationController
before_filter :authenticate_user!
def edit
@user = current_user
end
def update
@user = current_user
@user.from_language_id = user_params[:from_language_id]
@user.to_language_id = user_params[:to_language_id]
@user.full_name = user_params[:full... |
class CreateGsClusterSyncLogEntries < ActiveRecord::Migration
def self.up
create_table :gs_cluster_sync_log_entries do |t|
t.integer :gs_node_id
t.string :class_name
t.string :action
t.text :content
t.string :status
t.string :history
t.timestamps
end
end
def self... |
# Base class for asynchronous queue processing. Ensures that connections are
# cleaned up and active before your job actually executes. Note that you will
# need to implement perform_job in order for your wor to be executed.
class AsyncJob
class << self
def perform(*args)
ActiveRecord::Base.verify_a... |
require 'puppet/provider/f5'
Puppet::Type.type(:f5_pool).provide(:f5_pool, :parent => Puppet::Provider::F5) do
@doc = "Manages f5 pool"
mk_resource_methods
confine :feature => :ruby_savon
defaultfor :feature => :ruby_savon
def initialize(value={})
super(value)
@property_flush = {}
end
def sel... |
class Board
attr_accessor :cells
def initialize
self.reset!
end
def reset!
@cells = Array.new(9, " ")
end
def display
row = "------------"
puts " #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} "
puts row
puts " #{self.cells[3]} | #{self... |
FactoryBot.define do
factory :patient do
sequence(:name) { |n| "name#{n}" }
sequence(:date_of_birth) { |n| "#{n}/#{n}/#{n}" }
sequence(:address) { |n| "Apartment #{n}, Tyrone House" }
user
end
end
|
require 'adcenter_wrapper_entities'
require 'CustomerBillingService.rb'
require 'soap/mapping'
module AdCenterWrapper
module CustomerBillingServiceMappingRegistry
EncodedRegistry = ::SOAP::Mapping::EncodedRegistry.new
LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new
NsAdapiMicrosoftCom = "https://adapi.mi... |
class MathProblemsController < ApplicationController
def show
@math_problem = MathProblem.find(params[:id])
end
def create
@math_problem = MathProblem.new(params[:math_problem].merge({:owner => current_user }))
respond_to do |format|
if @math_problem.save
format.html { redirect_to(@... |
require 'rspec'
require_relative '../lib/imperium'
require_relative 'spec_helper'
describe 'All scenes implementations common behaviour' do
# all classes in the specified folder should include module 'Scene'
it 'should include Scene module' do
# load all classes from the specified folder in project
Dir['l... |
class SerializableMessage < JSONAPI::Serializable::Model
type 'messages'
link(:self) { @url_helpers.message_url(@model.id) }
attribute :content
attribute(:date) { @model.created_at }
has_one :sender do
link(:related) { @url_helpers.user_url(@model.sender_id) }
end
has_one :receiver do
link(:r... |
module Boxzooka
# Corresponding to the <Response> entity on the Order Cancellation Response.
class OrderCancellationResponseResponse < BaseElement
root node_name: 'Response'
scalar :order_id, node_name: 'OrderID'
scalar :status
scalar :error_message
end
end
|
require_relative "tree_node"
require "byebug"
class KnightPathFinder
attr_reader :root_node, :considered_positions
def initialize(pos)
@root_node = PolyTreeNode.new(pos)
@considered_positions = [pos]
build_move_tree(@root_node)
end
def self.valid_moves(pos)
y,x = pos
... |
#!/usr/bin/env ruby
=begin
Author: github.com/c2h2
get your data files from: http://yann.lecun.com/exdb/mnist/
Thanks for ruby bitmap code from: http://rosettacode.org/wiki/Bitmap
ubyte data structures from: data website.
TRAINING SET LABEL FILE (train-labels-idx1-ubyte):
[offset] [type] [value] ... |
class CreateVisitDiagnoses < ActiveRecord::Migration
def self.up
create_table :visit_diagnoses do |t|
t.references :diagnosis, :null => false
t.references :visit, :null => false
t.references :diagnosis_method, :null => false
t.references :diagnoser, :null => false, :references => :research... |
require "rubygems/cli/command"
require "rubygems/requirement"
module Gem
module CLI
# Command superclass encapsulating release, prerelease, and
# version filters.
class Filtered < Gem::CLI::Command
# Any version requirements specified on the command line.
attr_reader :requirements
... |
# frozen_string_literal: true
Rails.application.routes.draw do
devise_for :users
# API End Points
namespace :api, constraint: { subdomain: 'api' } do
namespace :v1 do
resources :ideas do
resources :comments
resources :reviews
end
end
end
end
|
#
# Helper that tries to find out what test suite is running (for SimpleCov.command_name)
#
module SimpleCov::CommandGuesser
def self.guess(command)
case command
when /#{'test/functional/'}/
"Functional Tests"
when /#{'test/integration/'}/
"Integration Tests"
when /#{'test/'}/
... |
class ExperimentsController < ApplicationController
before_filter :authenticate_user!
def search
authorize! :read, Experiment, :message => 'Not authorized.'
@keyword = params[:q]
@result = Experiment.find(:all, :conditions => ['title LIKE ?', "%#{@keyword}%"])
respond_to do |format|
format.js... |
class InitialTables < ActiveRecord::Migration[5.2]
def change
create_table :selfies do |t|
t.string :ip_address # only show 1 selfie per ip
t.string :token
t.string :selfie_url
t.datetime :created_at
end
end
end
|
class MP3Importer
attr_accessor :path
def initialize(path)
@path = path
end
def import
files.each do |file|
song = Song.new_by_filename(file)
end
end
def files
@filenames = Dir.entries(@path).select{|f| File.file?(@path+"/"+f)}
end
end
|
#***************************************************************************
# The PackMule Rakefile v0.1
# PackMule can run tests, build packages and gems, manually install,
# generate rdocs, and publish them. CVS support might be added later.
#
# In general, layout your project directory as follows:
# - lib/
# - ... |
module Gretel
class Crumb
# Initializes a new crumb from the given +key+.
# It finds the breadcrumb created in +Gretel::Crumbs.layout+ and renders the block using the arguments supplied in +args+.
def initialize(context, key, *args)
if key.class.respond_to?(:model_name)
# Enables calling `br... |
# == Schema Information
#
# Table name: opportunities
#
# id :integer not null, primary key
# listing_id :integer not null
# user_id :integer not null
# status :string default("favorited"), not null
# created_at :datetime not null
# updated_at :datetime ... |
class Post < ActiveRecord::Base
validates_presence_of :assunto, :resumo, :texto
has_many :comments
has_many :tags
end
|
module Closeio
class Client
module CustomField
def list_custom_fields
get(custom_field_path)
end
def find_custom_field(id)
get("#{custom_field_path}#{id}/")
end
def create_custom_field(options = {})
post(custom_field_path, options)
end
def updat... |
class LoginPage < SitePrism::Page
element :campo_email, '#input9'
element :campo_senha, '#Password'
element :botao_entrar, '#SubmitButton'
def abrirUrl
visit'http://homologacao.painel.agrohub.com.br/'
end
def logar(dados)
campo_email.set dados [:Email]
campo_senha.s... |
class SubcategoriesController < ApplicationController
def show
@category = Category.find_by_alias(params[:category])
@subcategory = Subcategory.find_by_alias(params[:subcategory])
if @subcategory.category_id == @category.id
@products = @subcategory.products
else
render :file => 'public/404.html', :statu... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... |
class AddDealsDealNotify < ActiveRecord::Migration
def self.up
add_column :deals_notifications,:deals,:string
end
def self.down
remove_column :deals_notifications,:deals
end
end |
class AddWhatsappConversationsToMonthlyTeamStatistic < ActiveRecord::Migration[6.1]
def change
add_column :monthly_team_statistics, :whatsapp_conversations, :integer
end
end
|
require 'nokogiri'
require 'open-uri'
class Web
attr_reader :doc
def initialize(url)
@doc = Nokogiri::HTML(URI.open(url))
end
end
|
class SiTfChoice < SubItem
attr_accessible :question, :tf_choice_assets_attributes
acts_as_citier
has_many :si_tf_choice_options, :dependent => :destroy, :order => 'created_at ASC'
has_many :tf_choice_assets
accepts_nested_attributes_for :tf_choice_assets, :allow_destroy => true
validates :question, pres... |
require 'active_support/core_ext/string/output_safety'
module UnobtrusiveFlash
module ControllerMixin
protected
def prepare_unobtrusive_flash
return unless flash.any?
# TODO: replace configuration based on overriding methods with a conventional config block
cookies[:flash] = {
valu... |
class Term < ActiveRecord::Base
has_and_belongs_to_many(:children,
class_name: 'Term',
join_table: 'children',
foreign_key: 'term_a_id',
association_foreign_key: 'term_b_id')
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'User interacts with Student Tags' do
include_context 'login_with_global_admin'
describe 'Create Tag' do
before :each do
@org = create :organization
@tags = create_list :tag, 3, organization: @org
end
it 'navigates to ta... |
require 'sinatra'
require 'sinatra/reloader' if development?
require 'mongoid'
require 'haml'
require 'sass'
require 'redcarpet'
configure :development do
enable :logging, :dump_errors, :run, :sessions
Mongoid.load!("config/mongoid.yml")
end
class Page
include Mongoid::Document
field :title, type: Strin... |
class County < ApplicationRecord
belongs_to :state
has_one :county_data
def region
self.state.region
end
def division
self.state.division
end
def string
"#{self.name}, #{self.state.name}"
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.