text stringlengths 10 2.61M |
|---|
class Shuttle::User
# API for accessing information on the current and other users.
attr_accessor :id, :name, :short_name, :sortable_name, :primary_email, :login_id
attr_accessor :sis_user_id, :sis_login_id
attr_accessor :avatar_url, :calendar, :time_zone, :locale
attr_accessor :saved
def initialize(*args)
... |
class User < ApplicationRecord
has_many :reviews
has_many :reservations
has_many :restaurants, through: :reservations
end
|
class CreateExactTargetMessages < ActiveRecord::Migration
def self.up
create_table :exact_target_messages do |t|
t.column :type, :string
t.column :request, :string, :limit => ExactTargetMessage::REQUEST_MAX_LENGTH,
:null => false
t.column :response, :string, :limit => ExactTarget... |
class MedicalCat < ApplicationRecord
has_paper_trail
belongs_to :professional_detail
has_many :hospital_admission_histories, dependent: :destroy
accepts_nested_attributes_for :hospital_admission_histories
rails_admin do
create do
field :professional_detail_id, :enum do
... |
#!/usr/bin/env ruby
require "git"
log = Dir.home + "/.push_dotfiles.log"
dotfiles_dir = Dir.home + "/dotfiles/"
File.open(log, "a") do |file|
file.puts "\n---\n"
file.puts "Attempted push at " + Time.now.to_s
begin
dotfiles = Git.init(dotfiles_dir)
dotfiles.add(:all=>true)
dotfiles.commit_all("Auto... |
class AddProductTags < ActiveRecord::Migration[5.2]
def change
create_table :product_tags do |t|
t.string :name
t.integer :product_tag_group_id
end
create_table :product_tag_groups do |t|
t.string :name
end
create_table :product_tag_aliases do |t|
t.integer :product_tag_i... |
class Page < ActiveRecord::Base
belongs_to :project
has_attached_file :picture, styles: { large: "1000x565>", medium: "300x300>", thumb: "100x100>" },
:path => ":rails_root/private/images/:id/:style.:extension",
:url => "#{ActionController::Base.relative_url_root}/image_server/:id/:style/:extension"
val... |
class CreatePieces < ActiveRecord::Migration
def change
create_table :pieces do |t|
t.belongs_to :model
t.belongs_to :size
t.float :price, precision: 8, scale: 2
t.timestamps null: false
end
end
end
|
class CreateImages < ActiveRecord::Migration
def change
create_table :images do |t|
t.string :path
t.integer :object_id
t.string :object_type, limit: 50
t.timestamps null: false
end
end
end
|
class <%= class_name %>Controller < PublicRescue::PublicErrorsController
# 404
def not_found
end
# 500
def internal_server_error
end
def conflict
render :action => :internal_server_error
end
def not_implemented
render :action => :internal_server_error
end
def method_not_allowed
ren... |
require "spec_helper"
describe Player do
let(:player) { Player.new }
it "initializes with 10 lives" do
expect(player.lives).to eq 10
end
it "allows you to set lives" do
player = Player.new(5)
expect(player.lives).to eq 5
end
describe "#new_guess" do
it "creates a Guess object and sends t... |
class OptionsMcq < ApplicationRecord
belongs_to :options
belongs_to :mcqs
end
|
class CardSetSerializer < ActiveModel::Serializer
# cache key: 'card_set'
attributes :id, :name, :release_date, :code
has_many :cards
end
|
require 'bundler/setup'
require 'sexpistol'
require 'pry'
require 'tilt'
require 'erb'
def rest(expression)
copy = expression.dup
copy.shift
copy
end
module Ugh
class BashLiteral
def initialize(expr)
@expr = expr
end
def to_bash
@expr.to_s
end
end
module Util
def self.pa... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ScoresController, type: :controller do
before do
@user = FactoryBot.create(:user)
@score = FactoryBot.create(:score, user: @user)
session[:user_id] = @user.id
end
describe 'GET #index' do
it 'returns http success' do
get ... |
class CourtsController < ApplicationController
def show
@court = Court.find(show_params[:id])
render layout: false
end
private
def show_params
params.permit(:id)
end
end |
class FplService
class << self
def base_url
"https://fantasy.premierleague.com"
end
def update_gameweek_score(player_ids, gw)
Parallel.each(player_ids, in_threads: 8) do |player_id|
score = gameweek_score(player_id, gw)
FplPlayer.find_by(fpl_id: player_id).update_attributes("g... |
class MapQuest
class Request < RestClient::Resource
RestClient.log =
Object.new.tap do |proxy|
def proxy.<<(message)
Rails.logger.info message
end
end
# The base url of the mapquest api
API_ROOT = 'http://%smapquestapi.com/%s/v%s/%s'
def initialize(method)
isOMQ = method[:om... |
class Donation < ApplicationRecord
belongs_to :donor, class_name: "User", foreign_key: "donor_id"
belongs_to :dancer, class_name: "User", foreign_key: "dancer_id"
validates :amount, presence: true, numericality: { greater_than: 0 }
validates :donor_id, :dancer_id, presence: true
def date
created_at.to... |
class EventsController < ApplicationController
def index
@title = 'I nostri eventi'
@breadcrumb = '<span class="current_crumb">Eventi</span>'
@events = Event.all
@first = Event.first()
end
def show
@event = Event.find(params[:id])
@title = @event.name
@breadcrumb = '<a href=' + events... |
class ApplicationHelper::Button::GenericObjectDefinitionButtonButtonGroupNew < ApplicationHelper::Button::Basic
def visible?
@actions_node || @record.kind_of?(GenericObjectDefinition)
end
end
|
class Array
def into(n = 3)
groups = []
n.times { groups << [] }
elements = self
counter = 0
while !elements.empty? do
groups[counter % n] << elements.shift
counter += 1
end
groups
end
end
|
class Main
helpers do
def cached_file_id( uploader )
uploader.file.path.gsub(uploader.cache_dir + '/', '')
end
def generate_unique_filename( filename )
[ UUID.sha1, File.extname(filename).downcase ].join
end
def assert_valid_cache_id!( cache_id )
unless cache_id.match(Format::C... |
#encoding: utf-8
class Cache
include Mongoid::Document
include Mongoid::Timestamps
store_in collection: "cache", database: "dishgo"
field :website, type: String
field :menu, type: String
field :network_menu, type: String
field :api_menu, type: Hash, default: {}
belongs_to :restaurant, index: true
def self... |
require 'test_helper'
class DoorsControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
def setup
user = FactoryBot.create(:user)
sign_in user
@door = FactoryBot.create(:door, organization: user.organization)
end
test "#index" do
get doors_path
res = JSO... |
class CreateDb < ActiveRecord::Migration
@@test_fulltext_migrations = false
def self.up
## User
create_table :users do |t|
t.column :email, :string, :null => false, :limit => User::EMAIL_MAX_LENGTH
t.column :screen_name, :string, :limit => User::SCREEN_NAME_MAX_LENGTH
t.column :... |
When(/^the current date is after the due date$/) do
on(PaymentsDetailsPage).due_date_element.visible?.should be true
(Date.today.to_s > Date.parse(on(PaymentsDetailsPage).due_date).to_s).should be true
end
And(/^current balance is between the minimum payment allowed amount and the maximum payment allowed amount$/)... |
#!/run/nodectl/nodectl script
# Add IP addresses to all local VPS configs on the current node.
require 'nodectld/standalone'
require 'ipaddress'
db = NodeCtld::Db.new
cfg = nil
vps_id = nil
db.prepared(
'SELECT vpses.id AS vps_id, pools.filesystem, netifs.name AS netif,
ips.ip_addr AS route_addr, ips.pre... |
# encoding: UTF-8
#
# Copyright © 2012-2015 Cask Data, 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 applicab... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
# this test performs direct network connections without retries.
# In case of intermittent network issues, retry the entire failing test.
describe Mongo::Socket::SSL do
retry_test
clean_slate_for_all
require_tls
let(:host_name) { 'localho... |
require 'spec_helper'
describe ChunkyPNG::Palette do
it "should preserve the palette correctly" do
filename = resource_file('palette1.png')
image = ChunkyPNG::Image.from_file(filename)
pal = image.palette
# The palette should not get reduced simply becayuse the colors are unused
# or dup... |
class PollsController < ApplicationController
before_filter :check_admin_key_and_load_poll, :only => [:edit, :update, :destroy]
before_filter :load_poll_and_ballot, :only => [:show]
# GET /polls
def index
@polls = Poll.all
end
# GET /polls/1
def show
end
# GET /polls/new
def new
@poll = P... |
step "a table of :x units wide by :y units high" do |x, y|
@table = Table.new(x.to_i, y.to_i)
end
step "a robot" do
@robot = Robot.new(@table)
end
step "a robot placed at :x,:y facing north" do |x, y|
@robot = Robot.new(@table)
position = Position.new(x.to_i, y.to_i)
orientation = Orientation::NORTH
place... |
module MembersHelper
#VARIABLES
@@accept = "application/vnd.mx.api.v1+json"
@@content_type = "application/json"
@@base_url = "https://int-api.mx.com"
def list_institutions(page = 1, records_per_page = 1000)
HTTP.headers(:accept => @@accept)
.basic_auth(:user => ENV["API_USERNAME"] ,
:... |
require "rails_helper"
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
describe 'User', js: true do
context 'New User' do
it 'can click the signup link and be directed to sigup page' do
visit root_path
within(:css, "p.navbar-text") d... |
# 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 < ActiveRecord::Base
belongs_to :user
has_many :parameters
accepts_nested_attributes_for :parameters, :allow_destroy => true
end
|
module Hexagonal
module Runners
class DeleteRunner
pattr_initialize :listener, :user, :id
delegate :unauthorized, :deleted_successfully, to: :listener
attr_writer :policy, :repository
def run
authorize!
delete!
deleted_successfully target
rescue Hexagonal::... |
#
# Cookbook Name:: volumes
# Description:: Format the volumes listed in node[:volumes]
# Recipe:: format
# Author:: Philip (flip) Kromer - Infochimps, Inc
#
# Copyright 2011, Philip (flip) Kromer - Infochimps, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License"... |
class Admin::SettingsController < Admin::ApplicationController
load_and_authorize_resource
helper_method :permission
def index
if request.post?
if !params[:setting].blank?
Setting.app_name = params[:setting][:app_name]
Setting.app_keywords = params[:setting][:app_keywords]
Setting.app_descri... |
xml.instruct!
xml.DenikReferendum do
@articles.each do |article|
next if article.name.nil? or article.perex.nil? or article.text.nil? or article.publish_date.nil?
xml.Article do
xml.ArtID article.id
xml.date article.publish_date.to_formatted_s(:cz_date)
xml.title article.name
... |
module Searches
class TwitterUserService
class << self
def find_tweets_for(source)
last = source.last.try(&:provider_id)
params = "from:#{source.key} -rt"
TwitterProvider.client.search(params).take(100).each do |tweet|
break if reached_limit? tweet.id, last
begi... |
require 'active_record/base'
module Kantox
module Refactory
module Model
class PinceNez
attr_reader :model, :children
# Defines unique records percent to decide whether grouping might be interesting on that column
# @default 10 whether total amount of records divided by unique reco... |
class DailyDigest
attr_reader :mailing_list
def initialize
@mailing_list = Person.where(daily_digest: true)
end
def send_digest
mailing_list.each do |person|
updated_conversations = retrieve_updated_conversations(person)
unless updated_conversations.empty?
Notifier.daily_digest(pe... |
require 'rails_helper'
RSpec.describe "citizens/edit", type: :view do
before(:each) do
@citizen = assign(:citizen, create(:citizen))
end
it "renders the edit citizen form" do
render
assert_select "form[action=?][method=?]", citizen_path(@citizen), "post" do
assert_select "input[name=?]", "ci... |
require File.expand_path(File.join(File.dirname(__FILE__), "..", "test_helper.rb"))
module Core
class EnrichedStringTest < ActiveSupport::TestCase
setup do
I18n.locale = Rich::I18n::Engine.init :nl
end
test "current locale" do
assert_equal I18n.locale, :nl
end
test "to_output" do
... |
# frozen_string_literal: true
class UpdateLessonSkillSummariesToVersion2 < ActiveRecord::Migration[5.2]
def change
update_view :lesson_skill_summaries, version: 2, revert_to_version: 1
end
end
|
class BoatTypesController < ApplicationController
def index
redirect_to controller: 'boats', action: 'index'
end
def show
@boat_type = BoatType.find_by(slug: params[:id])
redirect_to root_path and return if !@boat_type
fixed_params = params.slice(:order, :page).merge(
params[:id] == 'RIB... |
class Admin::SeetingsController < InheritedResources::Base
def new
@seeting = Seeting.new(company_id: @current_company.id)
end
def update
update! do |success, failure|
success.html { redirect_to edit_adimin_seeting(@seeting) }
end
end
def create
@seeting = Seeting.new(permitted_params... |
require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品出品登録' do
context '商品出品登録がうまくいくとき' do
it "すべての項目が存在すれば登録できる" do
expect(@item).to be_valid
end
end
context '商品出品登録がうまくいかないとき' do
it "画像が空だと出品できない" do
... |
require_relative 'test_helper'
module AdequateSerializer
class Associations < Minitest::Spec
def test_no_associations
peggy = Person.new
PersonSerializer.new(peggy).associations.must_equal({})
end
def test_entity_association
peggy = Person.new
roger = Person.new(id: 2, name: 'Ro... |
class Course < ApplicationRecord
def star_number
self.star.blank? ? 1 : self.star
end
def cover
self.image.blank? ? "default.png" : self.image
end
end
|
class AvatarAdapter
attr_accessor :user, :client
def initialize(user)
@user = user
end
def client
@client ||= begin
Twitter::REST::Client.new(
consumer_key: Rails.application.secrets.twitter_api,
consumer_secret: Rails.application.secrets.twit... |
require 'pry'
class SongsController < ApplicationController
get '/songs' do
@songs = Song.all
erb :"songs/index"
end
get '/songs/new' do
erb :"songs/new"
end
post '/songs' do
song = params[:song]
genres = song[:genres]
title = song[:title]
artist_name = song[:artist]
song = ... |
require 'childprocess'
require 'shellwords'
module BankScrapToolkit
class Mitmproxy
TEMPLATE = <<-TEMPLATE.freeze
from __future__ import print_function
import json, sys
def start(context, argv):
context.output = open(argv[1], 'w')
context.join = None
print('[', file=context.output)
def done(cont... |
# Determines purchase permissions for a user and IAP environment.
class PurchaseEnvironmentPolicy
# Assuming only itunes for now I guess
APPLE_TEST_ACCOUNTS = ['flyflyerson@gmail.com', 'apply_cvsxqwq_appleton@tfbnw.net']
class Error < StandardError
attr_reader :user, :receipt
def initialize(user:, recei... |
class WordsController < PrivateController
def index
@words = Word.search(params[:word])
@word = Word.new(params.require(:word).permit(:text)) if params[:word].present?
@word = Word.new if !params[:word].present?
end
def new
@word = Word.new()
end
def create
# 登録する
@word = Word.new(pa... |
require 'time'
feature 'Showing the list of all peeps' do
before(:each) do
user = User.create(email: 'alice@example.com',
password: 'aliali',
username: 'useruser',
name: 'alice')
Peep.create(text: 'I am a peep',
date: Time.parse('2016-02-14 09... |
class Game
attr_reader :game_id,
:season,
:type,
:date_time,
:away_team_id,
:home_team_id,
:away_goals,
:home_goals
def initialize(game_data)
@game_id = game_data[:game_id].to_i
@season = game_data[... |
class GameBoard
def initialize
random_no = rand(5)
change_locations [random_no, random_no + 1, random_no + 2]
end
def check_yourself num
num = num.to_i
if @locations.include?(num)
@guessed << num unless @guessed.include?(num)
@no_of_hits += 1
if @locations.all? {|e| @guessed.in... |
require 'spec_helper'
describe Nymphia::DSL do
describe '#run' do
context 'when -f is given' do
subject(:cli) { Nymphia::CLI.new(['-f', 'examples/base.rb']) }
it 'contains nymphia header in stdout' do
expect { subject.run }.to output(/# This config is generated by Nymphia/).to_stdout_from_an... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name =>... |
class Gem::Commands::RepoCommand < Gem::Command
def initialize
super("repo", "Open github repository")
end
def execute
repo = options[:args].first
system "open http://github.com/#{repo}"
end
end |
require 'rails_helper'
feature 'signing-up' do
scenario 'visitor is able to sign up' do
visit root_path
within('#new_user') do
fill_in('First name', :with => 'Foo')
fill_in('Last name', :with => 'Bar')
fill_in('Email', :with => 'foo@bar.com')
fill_in('Password', :with => 'foobar123'... |
require "administrate/base_dashboard"
class ExtraPageDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throu... |
require('pg')
require('pry-byebug')
require_relative('../db/sql_runner')
class Book
attr_accessor :id, :title, :author_id, :buy_price, :sell_price
def initialize(options)
@id = options['id'].to_i
@title = options['title']
@author_id = options['author_id']
@buy_price = options['buy_price'].to_f
... |
# == Schema Information
#
# Table name: alerts
#
# id :bigint not null, primary key
# severity :integer default("info"), not null
# start_date :datetime
# end_date :datetime
# alertable_type :string
# alertable_id :bigint
# created_at :datetime not nul... |
require 'spec_helper'
describe DataColumn do
# let(:array) { [1, 0, nil] }
let!(:column) { DataColumn.new([1, 0, nil])}
describe "sum" do
it "should return the sum of the non-nil values" do
column.sum.should == 1
end
end
describe "count" do
it "should return the number of non-nil values" d... |
# frozen_string_literal: true
class AddMlidsToChapters < ActiveRecord::Migration[6.0]
def up
execute <<~SQL
CALL update_records_with_unique_mlids('chapters', 2, 'organization_id');
SQL
end
def down
execute <<~SQL
ALTER TABLE chapters DROP COLUMN mlid;
SQL
end
end
|
require 'rails_helper'
RSpec.describe "Doctors", type: :request do
describe "GET /doctors" do
it "Recieve Status 200 in /GET Doctors" do
get doctors_path
expect(response).to have_http_status(200)
end
it "Recieve a JSON Array response in /GET Doctors" do
get doctors_path
parsed_bod... |
module GithubLabels
LABELS_AND_COLOURS = {
"beginner friendly":"C2E0C6",
"Good First Issue":"D02AD6",
"Type: Question":"CC317C",
"Type: Feature/Redesign":"84B6EB",
"Type: Documentation":"5319E7",
"Type: Content Change":"663399",
"Type: Bug":"E11D21",
"Status: On Hold":"E11D21",
"St... |
module TwirpRails
module ActiveRecordExtension
extend ActiveSupport::Concern
class_methods do
# Using to set twirp class used by to_twirp method
# @example
# twirp_message TwirpModel
def twirp_message(message_class)
@twirp_message = message_class
end
def twirp_mes... |
shared_examples "a class highjacker" do
context 'class highjacking' do
let(:highjacked_class_name) { "Liquid::#{described_class.demodulized_name}" }
def highjacked_class
highjacked_class_name.split('::').inject(Object) { |klass, const_name| klass.const_get(const_name) }
end
after :each do
... |
class AddShippingCurrenciesToProducts < ActiveRecord::Migration
def change
add_column :products, :usd_domestic_shipping, :decimal, :precision => 8, :scale => 2
add_column :products, :usd_foreign_shipping, :decimal, :precision => 8, :scale => 2
rename_column :products, :domestic_shipping, :cad_domestic_shi... |
class City < ActiveRecord::Base
has_many :neighborhoods
has_many :listings, through: :neighborhoods
extend Searchable
include Searchable::ListingHelpers
end
|
class Game
attr_reader :player1, :player2, :turn
def initialize(player1, player2)
@player1 = player1
@player2 = player2
@turn = 1
end
def attack
if @turn == 1
@turn = 2
attack_p2
else
@turn = 1
attack_p1
end
end
private
def attack_p1
@player1.reduce_... |
require 'spec_helper'
require 'erb'
describe TmuxStatus::Wrappers::Ifconfig do
before do
string = File.read("spec/fixtures/ifconfig_iface_#{iface_status}.txt")
template = ERB.new(string)
output = template.result(binding)
described_class.any_instance.stubs(ifconfig: output)
end
context 'when ppp... |
require 'nokogiri'
module Peel
class Item
attr_accessor :uid, :arg, :valid, :autocomplete, :title, :subtitle, :mod_subtitles, :icon, :type, :object
def initialize(title, opts = {})
if title.length == 0 then raise ArgumentError.new('title must be non-zero') end
@uid = opts[:uid]
@arg = opts[:arg]
... |
# frozen_string_literal: true
module Videos
# Service to get video
class GetService
def initialize(article, user)
@video = article
@user = user
end
def perform
Response::Success.new(@video)
end
private
def raise_errors
render nothing: true, status: 404 unless @vi... |
# This class is responsible for handling
# Requests from Com::Nbos::Core::MediaController.
# It will create the request based on Controller request params and
# send that request to Wavelabs API server and return the response back.
# While sending respose back to receiver it will create the virtual models
# from Com::... |
class Brand < ActiveRecord::Base
has_and_belongs_to_many :stores
validates(:name, {:presence => true, :length => {:maximum => 100}})
end
|
require 'rspec'
require 'arabic_numeral'
#Test cases:
#Convert Arabic Number to Roman Numeral
#Number Numeral
#1 I
#3 III
#9 IX
#1066 MLXVI
#1989 MCMLXXXIX
RSpec.describe ArabicNumeral do
#Test error case
it 'to_roman_numeral errors out on unknown numbers' do
bad_arabic_number = ArabicNumeral.new(-1)
exp... |
class CreateSchemaGamedesk < ActiveRecord::Migration[5.2]
def change
execute "CREATE SCHEMA IF NOT EXISTS gamedesk"
end
end
|
# -*- encoding: utf-8 -*-
module OpenCalais
module Configuration
VALID_OPTIONS_KEYS = [
:api_key,
:adapter,
:endpoint,
:user_agent
].freeze
# this you need to get from open calais - go register!
DEFAULT_API_KEY = nil
# Adapters are whatever Faraday supports - I like exc... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :current_user, :signed_in?, :sign_in, :sign_out, :auth
def current_user
return nil unless session[:session_token]
@current_user ||= User.find_by(session_token: session[:session_token])
end
def s... |
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
before_action :set_course
before_action :authenticate_admin!, only: [:create, :update, :destroy]
def index
end
def show
end
def new
@post = @course.posts.new(params[:post])
@post.adm... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Slack::RealTime::Store do
it 'can be initialized with an empty hash' do
store = described_class.new(Hashie::Mash.new)
expect(store.self).to be_nil
expect(store.groups.count).to eq 0
expect(store.team).to be_nil
expect(store.teams.... |
require 'github/markup'
class TaggedMarkdown < Struct.new(:string, :section_class)
def to_markdown
string.to_markdown.to_s rescue string.to_s
end
def to_html
'<section class="%s">%s</section>' % [Rack::Utils.escape_html(section_class), render_markdown(to_markdown)]
end
def render_markdown(s)
... |
class ChangePartsQuantity < ActiveRecord::Migration[5.0]
def change
change_column :parts, :quantity, :decimal
end
end
|
class User < ApplicationRecord
validates :name, presence: true
validates :email, presence: true, format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i, message: "Email invalid" },
uniqueness: { case_sensitive: false },
length: { minimum: 4, maximum: 254 }
validates :email, uniqueness: tru... |
require 'mechanize'
module AmazonSellerCentral
class Mechanizer
MASQUERADE_AGENTS = ['Mac Safari', 'Mac FireFox', 'Linux Firefox', 'Windows IE 9']
attr_reader :agent
def initialize
@logged_in = false
end
def login_email
AmazonSellerCentral.configuration.login_email
end
def ... |
class SubscriptionsController < ApplicationController
before_action :authenticate_user!
before_action :find_media, only: [:create, :destroy]
def index
media = Media.where(user_ids: current_user.id).page(subscription_params[:page])
data = render_to_string partial: 'media/subscription', collection: media
... |
class PagesController < ApplicationController
def about
@title = 'Sobre nosotros'
@content = 'Somos una empresa que lleva 38 años en el mercado.'
end
end
|
class Category < ActiveRecord::Base
belongs_to :bookmark_file
has_many :categories, dependent: :destroy
belongs_to :category
has_many :links, dependent: :destroy
def self.match?(str)
/\<H\d.*\>(.*)\<\/H\d\>/.match str
end
def self.match_ending?(str)
/\<\/DL/.match str
end
def parse(str)
... |
class UserGridWithCustomizedFormFieldsWindow < MasterWindow
js_properties :title => "User grid with customized form fields"
def default_config
{
:name => "User grid with customized form fields",
:width => 500,
:height => 350,
:minimizable => true,
:maximizabl... |
require 'csv'
require_relative 'csv_file'
require_relative 'game_statistics'
require_relative 'game_team'
require_relative 'game'
require_relative 'team'
require_relative 'team_statistics'
require_relative 'season_statistics'
require_relative 'league_statistics'
class StatTracker
include Csv
attr_reader :game_ta... |
require_relative 'spec_helper'
require_relative '../tile_bag'
# KNK: I had initially thought that we'd want to start with a hash, where the keys are the letters and the values are the number of that particular tile. However, after chatting with Danielle, I think that the collection instance variable SHOULD actually be... |
class ChangeColumnName < ActiveRecord::Migration
def change
rename_column :activities, :hours, :hours
end
end
|
json.array!(@lendings) do |lending|
json.extract! lending, :id, :day_borrow, :day_estimated_return, :day_actual_return, :media_id, :user_id, :review
json.url lending_url(lending, format: :json)
end
|
class Links::Misc::DobberLineCombinations < Links::Base
def site_name
"Dobber Hockey"
end
def description
"Line Combinations"
end
def url
"http://www.dobberhockey.com/frozenpool_last3gamelines.php"
end
def group
3
end
def position
0
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.