text stringlengths 10 2.61M |
|---|
class AddDiscussionQuestionsToEssay < ActiveRecord::Migration
def change
add_column :essays, :discussion_questions_id, :integer
add_index :essays, :discussion_questions_id
end
end
|
class AddRentTypeToRealEstate < ActiveRecord::Migration[5.0]
def change
add_column :real_estates, :rent_type, :string
end
end
|
class Seller < ActiveRecord::Base
has_many :products
has_many :categories
end
|
class Offer < ActiveRecord::Base
validates :title, :text, :price, :seller, presence: true
validates :title,
length: {
minimum: 5,
maximum: 80,
#tokenizer: lambda { |str| str.scan(/\w+/) },
#too_short: "must have at least %{count} words",
#too_long: "must have at most %{count} words... |
# frozen_string_literal: true
class Subject < ActiveRecord::Base
# attr_accessible :title
has_many :subject_teacher_sets, dependent: :delete_all
has_many :teacher_sets, through: :subject_teacher_sets
MIN_COUNT_FOR_FACET = 5
end
|
# Helper Method
def position_taken?(board, location)
!(board[location].nil? || board[location] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
]
def won?(board)
WIN_COMBINATIONS.find do |win_combination... |
class Teeth
attr_reader :clean
def initialize
@clean = false
end
def clean?
if true
puts "The teeth should now be clean"
else
puts "The teeth should NOT be clean."
end
clean
end
def brush
@clean = true
end
end
|
require "rails_helper"
describe MedicalHistory, type: :model do
describe "Associations" do
it { should belong_to(:patient).optional }
end
describe "Validations" do
it_behaves_like "a record that validates device timestamps"
it { should validate_presence_of(:device_updated_at) }
end
describe "Sc... |
CheckoutController.class_eval do
before_filter :only_allow_active_country, :only => :update
# ---------------------------------------------------------------------------------------------------------------------
# This is a copy of paypal_payment from spree_paypal_express, with a change to catch extra errors... |
require "sandthorn/version"
require "sandthorn/errors"
require "sandthorn/aggregate_root"
require 'yaml'
require 'securerandom'
module Sandthorn
class << self
def configuration= configuration
@configuration = configuration
end
def configuration
@configuration ||= []
end
def serialize... |
class Api::V1::MeasurementsController < ApplicationController
def index
plant_name = 'iot_test2'
dynamodb = Aws::DynamoDB::Client.new
params = {
table_name: 'GardenPartyPi',
key: {
Plant: plant_name
}
}
response = dynamodb.get_item(params)
render json: resp... |
class AddOpenStatesUpdatedToBill < ActiveRecord::Migration[5.1]
def change
add_column :bills, :open_states_updated_at, :date
end
end
|
When(/^any FAQ link is clicked on Enter Payment Details page, a new FAQ modal is opened$/) do
on(PaymentsDetailsPage).wait_for_payment_page_load
random_value = rand(1..3)
if random_value == 1
on(PaymentsDetailsPage).faq_1
elsif random_value == 2
on(PaymentsDetailsPage).faq_2
elsif random_value == 3
... |
ActiveAdmin.register_page "Faturamento" do
menu priority: 2
content do
columns do
column do
panel "Faturamento Ofertas" do
offers = Offer.all.reverse
table_for offers do
th "N"
th "Produtor"
th "Data"
th "Bairro"
th "... |
#!/usr/bin/env ruby
# Add lib path to LOAD_PATH
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
require 'optparse'
require 'ostruct'
require 'rdkafka'
class RebalanceListener
attr_accessor :params
def initialize(params)
@params = params
end
def on_partitions_assigned(consumer, list)
s... |
module LoremIpsumNearby
class Customers
##
# Override the defaults value to match the customers
# Accept named parameters
#
def initialize(search_radius: nil, search_radius_unit: nil, data_file_path: nil, center_point: nil)
@search_radius = search_radius || ::LoremIpsumNearby.config.search_r... |
class TagCorrector < Formula
desc "corrects ID3 tags"
homepage "https://gitlab.com/lukasdanckwerth/ID3Corrector"
url "git@gitlab.com:lukasdanckwerth/ID3Corrector.git", :using => :git, :tag => "0.0.5"
version "0.0.5"
def install
if MacOS::Xcode.installed?
system "xcodebuild install"
system "d... |
require File.dirname(__FILE__) + '/../spec_helper'
describe TheCityAdmin::ApiReader do
it "should include City headers" do
headers = "X-City-RateLimit-Limit-By-Ip: 2200\r\nX-City-RateLimit-Remaining-By-Ip: 2199\r\n"
TheCityAdmin.stub(:admin_request).and_return(TheCityResponse.new(200, {}.to_json, headers))
... |
class CreateKundens < ActiveRecord::Migration[6.0]
def change
create_table :kundens do |t|
t.string :firma
t.string :strasse
t.integer :hausnummer
t.integer :postleitzahl
t.string :stadt
t.timestamps
end
end
end
|
require 'test_helper'
class TripsControllerTest < ActionDispatch::IntegrationTest
test "can create a new trip that has trails and campgrounds and parks" do
post session_path, params: { email: "test@gmail.com", password: "password" }
current_user = User.find(users(:allie).id)
trail = Trail.find(trails(:lo... |
class AddRepoToGithubIssues < ActiveRecord::Migration
def change
add_column :github_issues, :repository, :string
end
end
|
require_relative 'FieldFormatable'
class CheckField
attr_accessor :description1, :description2, :description3, :category, :sub_category, :tertiary_category, :field, :calculated, :db_type, :sign
include FieldFormatable
def initialize
@subtraction = false
@description1 = ""
@description2 = ""
@de... |
class Resolution < ActiveRecord::Base
validates :title, presence: true, length: { maximum: 115 }
has_many :goals, dependent: :destroy
has_many :reminders, dependent: :destroy
belongs_to :user
FORGOTTEN_THRESHOLD = 30.days.ago
def self.completed
where(finished: true)
end
def self.current
where... |
require 'spec_helper'
describe Immutable::List do
describe '#break' do
it 'is lazy' do
-> { Immutable.stream { fail }.break { |item| false } }.should_not raise_error
end
[
[[], [], []],
[[1], [1], []],
[[1, 2], [1, 2], []],
[[1, 2, 3], [1, 2], [3]],
[[1, 2, 3, 4], [1,... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe PropertiesController, type: :controller do
let(:landlord1) { create(:landlord) }
let(:landlord2) { create(:landlord) }
let(:params) { {} }
describe 'GET #advertised_monthly_rent' do
context 'when user is not logged in' do
subject {... |
class GetTranslationGroups
def self.call(args)
new(**Hash[args.map { |k, v| [k.to_sym, v] }]).call
end
attr_reader :project,
:translation_repository
def initialize(project:, translation_repository: TranslationRepository.new, context: nil)
@project = project
@translation_repository = ... |
require 'fastlane_core'
module Fastlane
module Sftp
# Provides available options for the commands generator
class Options
def self.general_options
return [
FastlaneCore::ConfigItem.new(
key: :server_url,
short_option: '-r',
optional: false,
... |
class RtfConcept < ActiveRecord::Base
belongs_to :concept
validates :weight, :numericality => {:greater_than_or_equal_to => 0.001}
end
|
# frozen_string_literal: true
module Super
class MemoryCache
class Lock
def initialize
@locks = {
global: Mutex.new,
fetch: Mutex.new
}
end
def synchronize(type = :global)
current_lock = @locks[type]
current_lock.lock unless current_lock.owne... |
class GamesCreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string :code, null:false
t.integer :duration, default:0
t.text :options
end
add_index :events, :code, unique:true
end
end
|
class Post < ApplicationRecord
belongs_to :user
has_many :comments
has_many :rating_averages, class_name: :RatingCache, foreign_key: :cacheable_id do
def with_dimension(dimension)
where(dimension: dimension).first
end
end
mount_uploader :image, ImageUploader
ratyrate_rateable "favorite"
end
|
class FullMangaController < ApplicationController
def show
manga = Manga.find params[:id]
render json: manga, serializer: FullMangaSerializer
end
def update
manga = Manga.find(params[:id])
version = manga.create_pending(current_user, full_manga_params)
# if this user is admin, apply the chang... |
module Authentication
extend ActiveSupport::Concern
include BCrypt
PASSWORD_MIN_LENGTH = 6
included do
validates :password_digest, presence: true
validates :session_token, presence: true, uniqueness: true
validates :password, length: { minimum: PASSWORD_MIN_LENGTH, allow_nil: true }
attr_rea... |
require 'dalli'
module LatencyStats
class Dalli < Backend
attr_reader :action_metrics, :overview_histogram
def initialize(settings)
@settings = settings
@dalli = ::Dalli::Client.new(LatencyStats.dalli_server, LatencyStats.dalli_options)
if !@dalli.get('started_at')
@dalli.set('s... |
class BookingMailer < ApplicationMailer
default from: "admin@tandemtech.com"
def confirmation(booking)
@booking = booking #@user will be whatever user we pass in to the 'welcome' method
mail( :to => @booking.student.email, :subject => "Confirmation - 1:1 Session Booking (the link to join session is in the email!... |
# frozen_string_literal: true
# Model to store pageviews
class Pageview < ActiveRecord::Base
belongs_to :visit
default_scope { order(timestamp: :asc) }
before_create :set_position
def set_position
self.position = visit.pageviews.count + 1
end
end
|
require 'test_helper'
class ScaffoldsControllerTest < ActionController::TestCase
setup do
@scaffold = scaffolds(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:scaffolds)
end
test "should get new" do
get :new
assert_response :success
... |
require 'uri'
require 'net/http'
require 'json'
require 'sql_formatter_web_interface/version'
# Usage: `SqlFormatterWebInterface.new(sql).format(options)`
class SqlFormatterWebInterface
API_URI = 'https://sqlformat.org/api/v1/format'.freeze
HEADERS = { 'Content-Type' => 'application/x-www-form-urlencoded' }.freez... |
# frozen_string_literal: true
class GithubUser
attr_reader :name, :link, :picture, :email
def initialize(params = {})
@name = params[:login]
@link = params[:html_url]
@picture = params[:avatar_url]
@email = params[:email]
end
end
|
require 'spec_helper'
describe Solid::LiquidExtensions::IfTag do
it_should_behave_like 'a tag highjacker'
context 'when Liquid::If is replaced' do
before :each do
described_class.load!
end
after :each do
described_class.unload!
end
it 'should allow complex expression inside an i... |
# http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net
require 'rack'
require 'rack/contrib/jsonp'
require 'sinatra'
require 'pcapr_local/db'
require 'pcapr_local/scanner'
require 'pcapr_local/xtractr'
require 'mu/scenario/pcap'
module PcaprLocal
class Server < Sinatra::Base
set :app_file... |
module RubySerializer
class Field
attr_reader :field, :as, :from, :value, :namespace
def initialize(field, namespace, options)
@field = field.to_sym
@as = options[:as] || @field
@from = options[:from] || @field
@value = options[:value]
@only = options... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class Event < ApplicationRecord
scope :today, -> { where(start_date: Date.today)}
scope :past_now, -> { where('start_date >= ?', Time.now)}
scope :latest, -> { order('start_date DESC') }
scope :by_start_date, -> (start_date) { where('start_date >= ?', start_date)}
after_update do |event|
ActionCable... |
class AvailController < ApplicationController
before do
payload_body = request.body.read
if(payload_body != "")
@payload = JSON.parse(payload_body).symbolize_keys
end
end
# get all avail route
get '/' do
avails = Avail.all
{
success: true,
message: 'avails found',
avails: avails
... |
require File.expand_path(File.join(File.dirname(__FILE__), *%w[.. spec_helper]))
describe Deployment do
describe 'attributes' do
before :each do
@deployment = Deployment.new
end
it 'should have a deployable id' do
@deployment.should respond_to(:deployable_id)
end
it 'should ... |
require 'rails_helper'
describe Leagues::Matches::PickBansController do
let(:user) { create(:user) }
let(:pick_ban) { create(:league_match_pick_ban, kind: :pick, team: :home_team, deferrable: true) }
let(:match) { pick_ban.match }
let(:map) { create(:map) }
describe 'PATCH submit' do
it 'succeeds for au... |
class OneOnOne < ActiveRecord::Base
validates_presence_of :student, :date
end
|
Pod::Spec.new do |s|
s.name = "ReactNativeIbeaconSimulator"
s.version = "1.0.10"
s.summary = "A cool package for simulate your iOS devices as beacon"
s.homepage = "https://github.com/williamtran29/react-native-ibeacon-simulator.git"
s.license = { :type => "MIT" }
s.authors = ... |
class Document < ApplicationRecord
enum document_type: { 'Passport' => 0,
'Driving license' => 1,
'ID' => 2 }
belongs_to :user
validates :number, :expired_at, :user, :country, :document_type, :issued_at, presence: true
validates :country, inclusion: { in: ISO3166... |
# Validates that an email address is well-formed
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || 'is not a valid email address') unless
GalleryLib.valid_email?(value)
end
end
|
$:.unshift File.expand_path("../lib", __FILE__)
require 'rubygems'
require 'pidfile'
require 'rake/testtask'
begin
require 'rake/gempackagetask'
rescue
require 'rubygems/package_task'
end
lib_dir = File.expand_path('lib')
test_dir = File.expand_path('test')
gem_spec = Gem::Specification.new do |s|
s.name = "p... |
class MP3Importer
attr_accessor :path
@@all = []
def initialize (file_path)
@path = file_path
self.class.all << self
end
def self.all
@@all
end
def files
file_path = Dir.entries("spec/fixtures/mp3s")
file_path.delete(".")
file_path.dele... |
Mingpai::Admin.controllers :games do
get :index do
@title = "Games"
@games = Game.all
render 'games/index'
end
get :new do
@title = pat(:new_title, :model => 'game')
@game = Game.new
render 'games/new'
end
post :create do
@game = Game.new(params[:game])
if @game.save
@t... |
# frozen_string_literal: true
# require 'base64'
RSpec.describe HelpScout::Attachment do
describe '.create' do
let(:conversation_id) { ENV.fetch('TEST_CONVERSATION_ID') }
let(:thread_id) { ENV.fetch('TEST_THREAD_ID') }
let(:attachment_file) { 'attachment/file.txt' }
let(:params) do
{
... |
class AddReleasedOnAndPurchasedOnToMakingTools < ActiveRecord::Migration[5.2]
def change
add_column :making_tools, :released_on, :date
add_column :making_tools, :purchased_on, :date
end
end
|
module DataMetaXtra
# Useful glyphs that can be used on the console and beyond
module Glyphs
# a version of an arrow pointing right
SPEAR = '➤'
# a version of an arrow pointing right
RTRI = '►'
# a version of an arrow pointing left
LTRI = '◄'
# a version of an arrow pointing right
RR... |
require 'oauth'
require 'json'
require 'base64'
module NowPlaying
class Twitter
UPLOAD_URI = 'https://upload.twitter.com/1.1/media/upload.json'
UPDATE_URI = 'https://api.twitter.com/1.1/statuses/update.json?'
def initialize
consumer = OAuth::Consumer.new(
ENV['TWITTER_API_KEY'],
EN... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Mongo::Collection#indexes / listIndexes prose tests' do
let(:collection) do
authorized_client['list-indexes-prose']
end
before do
collection.drop
collection.create
collection.indexes.create_one({name: 1}, name: 'si... |
# U2.W6: PezDispenser Class from User Stories
# I worked on this challenge by myself.
# 1. Review the following user stories:
# - As a pez user, I'd like to be able to "create" a new pez dispenser with a group of flavors that
# represent pez so it's easy to start with a full pez dispenser.
# - As a pez user, I... |
class CreateProperties < ActiveRecord::Migration[5.2]
def change
create_table :properties do |t|
t.string :title
t.string :property_type
t.string :offer
t.string :rental_period
t.string :property_price
t.decimal :propert_area
t.integer :property_room
t.text :descrip... |
#!/usr/bin/env ruby
$LOAD_PATH.unshift( File.expand_path( File.dirname( __FILE__ ) + "/../lib/" ) )
require "lucie/utils"
require "optparse"
class DecryptArguments
attr_reader :password
attr_reader :dry_run
def initialize args
opts = OptionParser.new do | opts |
opts.summary_indent = " "
... |
class Bips::ContentController < ApplicationController
def index
find_project
render :json => @project.bips_content(params[:section_id])
end
private
def find_project
@project = Project.find(params[:project_id])
end
end
|
class Fluentd
module SettingArchive
class BackupFile
include Archivable
attr_reader :note
FILE_EXTENSION = ".conf".freeze
def self.find_by_file_id(backup_dir, file_id)
note = Note.find_by_file_id(backup_dir, file_id) rescue nil
new(file_path_of(backup_dir, file_id), note)... |
class SessionsController < ApplicationController
def index
end
def new
@session = User.new
@scope = params[:scope]
end
def create
user_mgr = UserManager.new
user_mgr.subscribe(self)
user_mgr.authenticate(cred: params, client_id: session[:client_id])
end
def destroy
au... |
puts "before require"
require 'bundler'
Bundler.require
#require_relative "lib/clj"
if ARGV.size < 1
puts "usage: [-c] database_name"
exit
else
create = false
if ARGV.size == 2 && ARGV[0] == "-c"
create = true
database_name = ARGV[1]
elsif ARGV.size == 1
database_name = ARGV[0]
else
pu... |
require 'spec_helper'
describe Teller do
it "has a factory" do
expect(FactoryGirl.create(:teller)).to be_valid
end
it "is invalid without a name" do
expect(FactoryGirl.build_stubbed(:teller, name: nil)).to_not be_valid
end
end
|
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = "curb-fu"
s.version = "0.6.1"
s.author = "Derek Kastner, Matt Wilson"
s.email = "development@greenviewdata.com"
s.summary = "Friendly wrapper for curb"
s.files = Dir.glob('lib/**... |
require "bcrypt"
require "json"
require "sequel"
require "time"
def db_filepath
{
"development" => "sqlite:///tmp/hivemind-development.db",
"production" => "sqlite:///opt/hivemind/fs/hivemind-production.db",
}.fetch(ENV.fetch("RACK_ENV", "development"))
end
DB = ENV["RACK_ENV"] == "test" ? Sequel.sqlite :... |
# frozen_string_literal: true
FactoryBot.define do
factory :game do |game|
game.name '練習試合'
association :sport, factory: :sport
end
trait :with_scores do
transient do
left_side_scores_count 10
right_side_scores_count 9
end
after :create do |game, evaluator|
create_list(
... |
# -*- encoding : utf-8 -*-
class Cms::VenuesController < Cms::BaseController
def index
@venues = Venue.includes(:city).page(params[:page])
end
def show
@venue = Venue.find(params[:id])
end
def new
@venue = Venue.new
end
def edit
@venue = Venue.find(params[:id])
end
def c... |
require 'rails_helper'
RSpec.describe 'shelters edit page', type: :feature do
it 'can edit shelter' do
shelter1 = Shelter.create(name: 'Sherms Spikey Friends',
address: '1489 Balake Ave.',
city: 'Denver',
state: 'CO',
... |
module RobotSimulator
class Place
def initialize(robot, table, position)
@robot = robot
@table = table
@position = position
end
def execute
if @table.is_valid_position?(@position)
@robot.position = @position
end
end
end
end
|
module Golds
module Employees
class GrossSalary < Struct.new(:monthly)
def yearly
monthly * 14
end
end
end
end
|
# frozen_string_literal: true
class AddActiveToSchoolsTable < ActiveRecord::Migration[4.2]
def change
add_column :schools, :active, :boolean, default: false
end
end
|
Rails.application.routes.draw do
# # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
# get '/tasks', to: 'tasks#index'
# # Adding the root to task#index, to redirect to index without using/index"
# root :to => 'tasks#index'
# get '/tasks/new', to: 'tasks#new'... |
class Api::V1::RecipesController < ApplicationController
before_action :authorized
before_action :find_recipe, only: [:show, :update, :destroy]
def index
@recipes = Recipe.where(user_id: @user.id)
render json: @recipes
end
def show
render json: @recipe
end
def create
@recipe = Recipe.new(recipe_params... |
class Deck < ApplicationRecord
validates_presence_of :cards
end
|
json.array!(@petclub_memberships) do |petclub_membership|
json.extract! petclub_membership, :id, :primary_contact, :pet_name, :petclub_id, :owner_id
json.url petclub_membership_url(petclub_membership, format: :json)
end
|
class Menu < ApplicationRecord
# has_many :menu_dishes
has_many :contacts
end
|
class CreateUserWidgets < ActiveRecord::Migration
def change
create_table :user_widgets do |t|
t.integer :user_id, :null => false
t.integer :widget_id, :null => false
t.string :container, :limit => 64
t.integer :order, :null => false, :default => 1000
t.timestamps
end
end
end
|
# frozen_string_literal: true
require 'test_helper'
class MlnHelperTest < MiniTest::Test
extend Minitest::Spec::DSL
include LogWrapper
include MlnResponse
include MlnException
include MlnHelper
describe 'validate input params' do
it 'validate empty value' do
input_params = [{ value: [], error_m... |
# frozen_string_literal: true
require 'test_helper'
class Editor::HappeningsControllerTest < ActionDispatch::IntegrationTest
setup do
@editor_happening = editor_happenings(:one)
end
test 'should get index' do
get editor_happenings_url
assert_response :success
end
test 'should get new' do
g... |
# frozen_string_literal: true
require 'spec_helper'
require './lib/anonymizer/model/database.rb'
require './lib/anonymizer/model/database/json.rb'
RSpec.describe Database::Json, '#eav' do
it 'should exists class Json' do
expect(Object.const_defined?('Database::Json')).to be true
end
context 'work with fir... |
# == Schema Information
#
# Table name: directors
#
# id :integer not null, primary key
# bio :text
# dob :date
# image :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Director < ApplicationRecord
validate... |
class GuaranteedContact
def self.find(id)
Contact.find(id) || MissingContact.new
end
def self.find_by_email(email)
Contact.find_by(email_address: email) || MissingContact.new
end
end |
# frozen_string_literal: true
module Apartment
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
def copy_files
template 'apartment.rb', File.join('config', 'initializers', 'apartment.rb')
end
end
end
|
# frozen_string_literal: true
# Hamming : compare strand
class Hamming
def self.compute(strand1, strand2)
raise ArgumentError if strand1.size != strand2.size
strand1.each_char.zip(strand2.each_char).count { |a, b| a != b }
end
end
|
class CreateAppearances < ActiveRecord::Migration[5.1]
def change
create_table :appearances do |t|
t.string :image_background
t.string :theme_name
t.string :language
t.string :time_zone
t.string :setting_id
t.timestamps null: false
end
add_index :appearances, :setting_... |
module ActionView
module Helpers
module NumberHelper
def number_to_currency_with_rubles(number, options = {})
defaults = {
:unit => ' руб.',
:precision => 0,
:separator => ',',
:delimiter => ' ', #thousands delimiter
:format => "%n %u" } #put a space be... |
class AddSignatureToDeliveries < ActiveRecord::Migration[5.2]
def change
add_column :deliveries, :signature, :string
end
end
|
require 'rails_helper'
RSpec.describe 'admin zone create', settings: false do
subject(:zone) { DNS::Zone.first }
before :example do
sign_in_to_admin_area
end
it 'creates new zone' do
expect { post admin_zones_path, zone: attributes_for(:zone) }
.to change { DNS::Zone.count }.from(0).to(1)
end... |
require 'syslog_protocol'
module Fluent
class Papertrail < Fluent::BufferedOutput
class SocketFailureError < StandardError; end
attr_accessor :socket
# if left empty in fluent config these config_param's will error
config_param :papertrail_host, :string
config_param :papertrail_port, :integer
... |
class OrderDetail < ApplicationRecord
belongs_to :order
belongs_to :product
validates :quantity, presence: true,
numericality: {only_integer: true, greater_than: 0}
validate :product_present
validate :order_present
before_save :finalize
def unit_price
if persisted?
self[:unit_price]
els... |
# IpmiController Class; a simple wrapper around the ipmitool interface that provides
# a mechanism for gathering information from an underlying BMC using the BMC's IPMI
# interface
require 'singleton'
require 'timeout'
# time to wait for an external command (in milliseconds)
begin
EXT_COMMAND_TIMEOUT = 2000 unless ... |
class StoriesController < ApplicationController
# show all stories in the db
def index
@stories = Story.all
render :index
end
# form to create new goal that belongs to current_user
def new
@story = Story.new
render :new
end
# creates new story in db that belongs to current_user
def... |
require 'spec_helper'
module Categoryz3
describe Category do
let(:category) { FactoryGirl.build(:category) }
context "parent association" do
it "should have an association with category as parent" do
child_category = FactoryGirl.build(:category, :child, parent: category)
child_categor... |
# Plugin's routes
# See: http://guides.rubyonrails.org/routing.html
get 'portfolios', :to => 'portfolios#index'
|
module SocialShareButton
class << self
attr_accessor :config
def configure
yield self.config ||= Config.new
config.allow_sites.each do |name|
SocialShareButton::Helper.send :define_method, "#{name}_button_tag" do |title = "", opts = {}|
opts[:allow_sites] = [name]
wrap... |
class RecordtgmtsController < ApplicationController
before_action :set_recordtgmt, only: [:show, :edit, :update, :destroy]
# GET /recordtgmts
# GET /recordtgmts.json
def index
@recordtgmts = Recordtgmt.all
end
# GET /recordtgmts/1
# GET /recordtgmts/1.json
def show
end
# GET /recordtgmts/new
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.