text stringlengths 10 2.61M |
|---|
TwitterBootstrapOnRailsDemo::Application.routes.draw do
resources :products
root :to => 'welcome#index'
end
|
month = ["1月","2月","3月","4月","5月"]
wrong_number = [0,1,2,"3",4]
wrong_number.each do |num|
begin
puts month[num]
rescue => e
puts e.message
ensure
puts "puts"
end
end
|
module Ncr
class UnapprovedCountQuery
def find
Proposal.pending.where(client_data_type: "Ncr::WorkOrder").count
end
end
end
|
require 'spec_helper'
feature 'Managing Check ins' do
context 'as an admin user' do
background do
admin_email = 'admin@example.com'
password = 'password'
email = "John@example.com"
first_name = "John"
last_name = "Doe"
gender = "Male"
classification = "Master"
@member = Member.crea... |
module AuthorizeNet::AIM
# The AIM response class. Handles parsing the response from the gateway.
class Response < AuthorizeNet::KeyValueResponse
# Our MD5 digest generator.
@@digest = OpenSSL::Digest::Digest.new('md5')
include AuthorizeNet::AIM::Fields
# Fields to convert to/from ... |
json.array!(@segment_timings) do |segment_timing|
json.extract! segment_timing, :id, :timing, :date, :trip_segment_id, :hotel, :address
json.url segment_timing_url(segment_timing, format: :json)
end
|
#!/usr/bin/ruby
def sumOfSquares(n)
res = 0
(1..n).each {|x|
res += (x ** 2)
}
return res
end
def squareOfSum(n)
return (1..n).to_a.inject(0, :+) ** 2
end
puts squareOfSum(100) - sumOfSquares(100)
|
#!/usr/bin/env ruby
#####################################################################################
# @author Copyright 2015 Lester Claudio <lester@redhat.com>
# @author Copyright 2015 Kenneth Evensen <kenneth.evensen@redhat.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not us... |
ActiveAdmin.register InstBook, sort_order: :created_at_asc do
filter :template
includes :course_offering, :user
config.clear_action_items!
actions :all, except: [:new]
menu label: "Book Instances", parent: 'OpenDSA Books', priority: 20
permit_params :template, :title, :desc, :course_offering_id, :user_id, ... |
#!/usr/bin/env ruby
# Load the email library
require 'mail'
# Load the smtp library
require 'net/smtp'
# Load the file utils
require 'fileutils'
class Spamalot
def go!
# Clear the terminal
system("clear")
puts "Spam-a-lot by Daniel Upton (daniel@ileopard.co)"
puts "[Control - C] to quit"
puts... |
source 'https://rubygems.org'
ruby "2.0.0"
# gem 'rails', '4.0.0.beta1'
gem 'rails', github: 'rails/rails'
gem 'pg'
gem 'jquery-rails'
gem "ember-rails"
gem "twitter-bootstrap-rails"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
# gem 'sass-rails', '~> 4.0... |
class ExpressTemplate < ActiveRecord::Base
belongs_to :shop
has_many :applied_items, class_name: 'Item', dependent: :nullify
has_many :default_applied_shops,
class_name: 'Shop',
dependent: :nullify,
foreign_key: 'default_express_template_id'
validates :name, presence: true, uniqueness: { scope: ... |
module Capybara
module SessionHelper
def login(options = { :as => "user" })
user = create :user, :password => "secret", :password_confirmation => "secret", :role => options[:as]
visit login_path
fill_in "Name", :with => user.name
fill_in "Password", :with => "secret"
click_button "Lo... |
class UserMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.user_mailer.password_reset.subject
#
# The user argument here takes the self argument from the user model that is passed in UserMailer.password_reset(self).deliver
de... |
# frozen_string_literal: true
require 'rails_helper'
require 'spec_helper'
feature 'Comments can be created' do
scenario 'successfully' do
visit '/users/sign_in'
fill_in 'Email', with: 'nick@test.com'
fill_in 'Password', with: '123456'
click_button 'Log in'
visit '/posts'
fill_in 'comment-1'... |
# frozen_string_literal: true
module WasteExemptionsShared
module ApplicationHelper
def create_title(page_title)
"#{t(page_title)} - #{t('registrations.form.root_site')}"
end
# helper to return the default location of partials for a particular state
def enrollment_partial_location(state)
... |
require 'test_helper.rb'
class UpdatingAccountsTest < ActionDispatch::IntegrationTest
setup { @account = Account.create! name: 'Kosh' }
test 'update success' do
patch "/accounts/#{@account.id}",
{ account: { name: 'Kosh aka Raggedy Puppy' } }.to_json,
{ 'Accept' => Mime::JSON, 'Content-Type' => Mi... |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name, :null => false
t.string :password, :null => false
t.string :game_id
t.boolean :game_id_display, :default => false
t.string :comment
t.decimal :point, :precision => 6, :scale => 2,... |
FactoryBot.define do
factory :contact, aliases: [:owner] do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
mobile { Faker::PhoneNumber.cell_phone }
email { Faker::Internet.email }
date_of_birth { Faker::Date.birthday }
present_address { Faker::Address.full_address }... |
require 'uri'
require 'net/http'
class FactsController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :find_cat, only: [:index, :show, :create, :update, :destroy]
before_action :find_cat_fact, only: [:show, :update, :destroy]
# GET /owners/:owner_id/cats/:cat_id/facts
de... |
require "time"
class Cookie
InvalidCookie = Class.new(Exception)
attr_reader :name, :value, :attributes
protected :attributes
def initialize(name, value, attributes = {}, now = Time.now)
@name = name
@value = value
@attributes = attributes
@created_at = now
end
def self.parse(request_uri... |
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
helper_method :current_user, :auth_token
def auth_token
<<-HTML.html_safe
<input
type="hidden"
... |
# encoding: utf-8
require "helper"
describe T::RCFile do
after do
described_class.instance.reset
FileUtils.rm_f("#{project_path}/tmp/trc")
end
it "is a singleton" do
expect(described_class).to be_a Class
expect do
described_class.new
end.to raise_error(NoMethodError, /private method `... |
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |gem|
gem.name = "chargeio_tenant"
gem.version = '1.0'
gem.authors = ["Enrico Brunetta", "James Sparrow"]
gem.email = ["enrico@char... |
#
# rb_main.rb
# MountObserverRuby
#
# Created by vgod on 2/8/08.
# Copyright (c) 2008 __MyCompanyName__. All rights reserved.
#
require 'osx/cocoa'
include OSX
PID_FILE = "/var/tmp/#{ENV['USER']}-mountObserver.pid"
def rb_main_init
path = OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation
rbfile... |
class Comment < ActiveRecord::Base
belongs_to :albums
validates(:text, :album_id, {:presence => true})
validates(:text, :uniqueness => true)
end
|
module Campfire
class Message
attr_reader :id, :type, :created_at, :body
def initialize(room, attributes)
@room = room
@id = attributes["id"]
@type = attributes["type"]
@body = attributes["body"]
@created_at = attributes["created_at"]
end
def to_s
%Q[Message #{i... |
class Category < ApplicationRecord
# belongs_to :user
has_many :entries
validates :name, presence: true
validates :board_type, presence: true
validates :goal, numericality: true, presence: true
validates :current_total, numericality: true, presence: true
end
|
name 'carbon'
maintainer "WSO2, Inc."
maintainer_email "deependra@gmail.com"
license "Apache License, Version 2.0"
description "Installs/Configures carbon"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.1"
|
# # Filters added to this controller apply to all controllers in the application.
# # Likewise, all the methods added will be available for all controllers.
#
# class ApplicationController < ActionController::Base
# helper :all # include all helpers, all the time
# protect_from_forgery # See ActionController::Requ... |
# frozen_string_literal: true
module FatCore
module NilClass
# Allow nils to respond to #as_string like String and Symbol
#
# @return [String] empty string
def as_string
''
end
alias_method :entitle, :as_string
# Allow nils to respond to #tex_quote for use in TeX documents
#
... |
module Hermes
module Plugin
##
# Plugin that retrieves the weather forecast for a given location.
#
class Weather
include Cinch::Plugin
match(/weather\s*(.*)/)
set :help => 'weather [LOCATION] - Retrieves the weather forecast',
:plugin_name => 'weather'
##
# Re... |
module Hachette
class Editor
# This is a fake library for the purpose of the workshop.
# Please consider that this is an external library: do not change this file.
def initialize(editor)
@editor = editor
end
# This method implements a very complex algorithm.
# Obviously, it is so compl... |
class DiscussionsController < ApplicationController
include VoteHelper
include ContentHelper
before_action :set_discussion, :only => [:edit, :update, :destroy]
before_action :set_user
def index
cookies[:discussion_load_amount] = 15
end
def show
set_discussion
end
def new
session[:previ... |
# represent prefered language
class PreferedLanguage
include Mongoid::Document
include Mongoid::Timestamps
store_in database: 'sribulancer_development', collection: 'prefered_languages'
field :name
has_and_belongs_to_many :members
validates :name, :uniqueness => true
end
|
Gem::Specification.new do |s|
s.name = 'detached_counter_cache'
s.version = '1.0.0'
s.date = '2016-07-20'
s.summary = 'counter cache that lives in its own table'
s.description = 'counter cache that lives in its own table'
s.authors = ['Andrew Grim']
s.email = 'stopdropandre... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Events
describe Event do
let(:described) { Vedeu::Events::Event }
let(:instance) { described.new(event_name, closure, options) }
let(:event_name) { :some_event }
let(:closure) { proc { :event_triggered } }
... |
# -*- 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|
config.vm.box = "ubuntu/trusty64"
num_cpus = ENV['VAGRANTMANAGER_CPU']
mem_size ... |
class Article < ActiveRecord::Base
belongs_to :user
validates :user_id, presence: true
default_scope -> { order('created_at DESC') }
validates :title, presence: true, length: { maximum: 200 }
validates :content, presence: true
validates :genre, presence: true
has_many :comments, dependent: :destroy
de... |
module QBIntegration
module Service
# Both Spree line items and adjustments are mapped as SalesReceipt lines
#
# Return authorizations inventory units variants are alsy sync as Credit
# Memo lines
class Line < Base
attr_reader :line_items, :adjustments, :lines, :config, :item_service,
... |
class Activity < ActiveRecord::Base
has_many :pomodoros
has_many :today_activities
end
|
# coding: utf-8
FactoryGirl.define do
factory :lyric do
artist
title 'Заголовок трека'
text "Я признаю: твоя комета была яркой,\nНо при этом краткой, как любовь поэта и доярки.\nТы потух, не успев зажечься, где успех у женщин?\nТы снимаешь шлюх, чтоб суметь развлечься."
end
end
|
class ProjectUser < ActiveRecord::Base
#belongs_to :user
belongs_to :project
belongs_to :user
accepts_nested_attributes_for :user
#belongs_to :project, :inverse_of => :project_users
end
|
class AddNotificationFieldsToAnimalVaccinations < ActiveRecord::Migration
def change
add_column :animal_vaccinations, :notification_count, :integer, default: 0
add_column :animal_vaccinations, :notify, :boolean, default: true
add_column :animal_vaccinations, :notify_on, :date
AnimalVaccination.up... |
class ClassesTimetable < ApplicationRecord
belongs_to :semester
belongs_to :subgroup
has_many :lessons
def name
if !self.id.nil?
self.semester.id.to_s + ' ' + self.subgroup.name
end
end
end
|
require 'spec_helper'
require 'pry'
describe PostsController do
describe 'GET index' do
it 'return http success' do
get :index
expect(response).to be_success
end
it 'assign posts to an instance variable' do
get :index
expect(assigns(:posts)).to_not be_nil
end
end
end
|
class RepairsController < ApplicationController
before_action :logged_in_user
before_action :editor_or_admin_user, only: %i(edit update update_progress update_contacted update_delivery update_reminder)
before_action :admin_user, only: %i(data_management destroy import delete_check update_delete_check delete_confi... |
class SearchController < ApplicationController
before_filter :require_auth
before_filter :set_cache_headers, :only => [:photos]
PHOTO_SEARCH_FIELDS = %w[name cluster_name camera lens format]
def index
respond_to do |format|
format.html {
return redirect_to search_path(:q => 'recent') unless ... |
class Role < ActiveRecord::Base
has_many :users
attr_accessible :title
default_scope order(:title)
scope :public, where("title <> 'Admin'")
def admin?
self.title == 'Admin'
end
end
|
class BackofficeController < ApplicationController
before_action :authenticate_admin!
#Loading dashboard layout
layout "backoffice"
# Change current_user to pundit
def pundit_user
current_admin
end
end |
class EARMMS::GroupController < EARMMS::ApplicationController
helpers EARMMS::GroupHelpers
get '/' do
next halt 404 unless logged_in?
@title = "Your groups"
@user = current_user
@profile = EARMMS::Profile.for_user(@user)
@group_ids = get_group_ids_user_is_member(@user, :only_admin => true)
... |
#!/usr/bin/ruby
# Ruby RPM Spec Updater
#
# Simple tool to update the rpm spec of a packaged gem
# or ruby app.
#
# User should specify the location of the rpm spec to
# manipulate. Script takes an additional option to specify
# the version of the gem to update to or the location of
# the gem/gemspec/gemfile source whi... |
#!/usr/bin/env ruby
require File.expand_path('../helper', __FILE__)
class TestFormatters < Test::Unit::TestCase
generate_formatter_tests('html') do |doc|
RedCloth.new(doc['in']).to_html
end
def test_html_orphan_parenthesis_in_link_can_be_followed_by_punctuation_and_words
assert_nothing_raised { Re... |
class User < ApplicationRecord
has_secure_password
before_create { generate_token(:auth_token) }
attr_accessor :remember_me
enum verification: { Unverified: 0, Verified: 1 }
enum role: { User: 'User', Pharmacist: 'Pharmacist', Admin: 'admin' }
validates :email, uniqueness: true, presence: true
has_many :authe... |
#!/usr/bin/ruby
require 'rubygems'
gem "test-unit"
require "test/unit"
require "registration_page"
require 'watir-webdriver'
class TestRegistration < Test::Unit::TestCase
def setup
@driver = Watir::Browser.new :chrome
@driver.goto "https://www.kurrenci.com/custom/login/register.aspx"
end
def testRando... |
class Api::PromotionsController < ApplicationController
def actual_promotion
@promotion = Promotion.with_credits_positive.actual_promotion.first
render json: @promotion.to_json(), status: :ok
end
end
|
class BraintreeController < ApplicationController
# before_action :require_login
before_action :set_reservation, only: [:new,:create]
def new
@client_token = Braintree::ClientToken.generate
end
def create
nonce_from_the_client = params[:checkout_form][:payment_method_nonce]
result = Braintree::T... |
class RenameColumnsInFavorite < ActiveRecord::Migration[5.2]
def change
rename_column :favorites, :movie_id_id, :movie_id
rename_column :favorites, :user_id_id, :user_id
end
end
|
class State < ActiveRecord::Base
has_many :counties
validates :name, presence: true,uniqueness: true
end
|
class Experience < ApplicationRecord
belongs_to :user
has_many :bookings
has_many :reviews, through: :bookings
validates :title, :description, :address, :price, :photo, :capacity_min, :validity_date, :category, presence: true
mount_uploader :photo, PhotoUploader
geocoded_by :address
after_validation :ge... |
class BooksController < ApplicationController
def new
@title = "Add book"
@book = Book.new
end
def index
@title = "All Books"
@books = Book.all
end
def create
@book = current_user.books.new(:title => params[:book][:title],
:author => params[:book][:author])
... |
# -*- mode: ruby -*-
Vagrant.configure("2") do |config|
config.cache.auto_detect = true
boxes = {:es1 => "192.168.56.10",
:es2 => "192.168.56.20",
:es3 => "192.168.56.30",
:es4 => "192.168.56.40",
:es5 => "192.168.56.50"}
#boxes = {:es1 => "192.168.56.10"}
boxes.e... |
require File.dirname(__FILE__) + "/../../spec_helper"
describe Admins::MembershipsController do
let(:current_user) { Factory.stub(:admin) }
before(:each) do
controller.stub!(:current_user).and_return(current_user)
end
def mock_group(stubs={})
@mock_group ||= mock_model(Group, stubs).as_null_objec... |
cask :v1 => 'logmein-hamachi' do
version :latest
sha256 :no_check
url 'https://secure.logmein.com/LogMeInHamachi.zip'
name 'Hamachi'
homepage 'http://vpn.net'
license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder
tags :vendor => 'LogMeIn'
ins... |
# frozen_string_literal: true
module Decidim
module Opinions
# Custom helpers, scoped to the opinions engine.
#
module ApplicationHelper
include Decidim::Comments::CommentsHelper
include PaginateHelper
include OpinionVotesHelper
include ::Decidim::EndorsableHelper
include ::... |
class ApplicationController < ActionController::Base
before_action :require_login
def redirect_js(path)
render :js => "window.location.replace('<%= #{path} %>');"
end
end
|
Fabricator(:dance) do
dance_type { Faker::Lorem.word }
song_name { Faker::Lorem.word }
song_artist { Faker::Lorem.word }
timing { Faker::Lorem.word }
end
|
# frozen_string_literal: true
module Boring
module Devise
class InstallGenerator < Rails::Generators::Base
desc "Adds devise to the application"
DEFAULT_DEVISE_MODEL_NAME = "User"
class_option :model_name, type: :string, aliases: "-m",
desc: "Tell us the user model name whi... |
class PurchaseOrdersController < ApplicationController
before_filter :admin_user
def edit
@po = PurchaseOrder.find(params[:id])
@comment = @po.comment
@tags = current_organization.provider_tags.sort_by { |t| t.readable.downcase }
@checked_tags = @po.tags
end
def update
@po = PurchaseOrde... |
class Farm
include Mongoid::Document
field :farm_name, type: String
field :latitude, type: Float
field :longitude, type: Float
field :address, type: String
belongs_to :user
has_many :foods
end
|
# Public: Get the value in the nth index of an arithmetic sequence.
#
# first - The first value in the 0 INDEX.
# n - The index of the value we want.
# c - The constant added between the terms.
#
# Examples
#
# nthterm(1, 2, 3)
# # => 7
#
# nthterm(2, 2, 2)
# # => 6
#
# nthterm(-50, 10, 20)
# ... |
#
# fmw_opatch_patch
#
# Copyright 2015 Oracle. All Rights Reserved
#
Puppet::Type.type(:fmw_opatch_patch).provide(:windows) do
confine :kernel => :windows
defaultfor :kernel => :windows
def self.instances
[]
end
def install
patch_id = resource[:name]
oracle_home_dir = resou... |
BreadExpress::Application.routes.draw do
# Routes for main resources
resources :addresses
resources :customers
resources :orders
resources :items
resources :users
resources :sessions
resources :item_prices
# Authentication routes
# Semi-static page routes
get 'home' => 'home#home', as: :home
... |
class GitSnatch
class Curler
def initialize(curl)
@curl = curl
end
def build
@curl.tap do |c|
c.http_auth_types = auth_types if auth?
c.username = username if username
c.password = password if password
end
end
private
def username
GitSnatch.co... |
Rails.application.routes.draw do
mount Leasingx::Engine => "/leasingx"
end
|
class CargoTrain < Train
validate :number, :presence
validate :number, :format, TRAIN_NUMBER
def initialize(number)
super(number, 'cargo')
end
def add_carriage(carriage)
unless carriage.instance_of?(CargoCarriage)
raise 'Only freight wagons can be coupled to a freight train'
end
super(c... |
class Book < ActiveRecord::Base
belongs_to :author
belongs_to :category
has_many :ratings
validates :title, :price, :in_stock, presence: true
end
|
require 'rails_helper'
describe HotelsController, type: :routing do
it 'should route to #index' do
expect(get('/hotels')).to route_to('hotels#index')
end
it 'should route to #new' do
expect(get('/hotels/new')).to route_to('hotels#new')
end
it 'should route to #show' do
expect(get('/hotels/1')).... |
require "spec_helper"
describe UserDependentProductsController do
describe "routing" do
it "routes to #index" do
get("/user_dependent_products").should route_to("user_dependent_products#index")
end
it "routes to #new" do
get("/user_dependent_products/new").should route_to("user_dependent_pr... |
require('minitest/autorun')
require('minitest/rg')
require_relative('../song.rb')
class TestSong < MiniTest::Test
def setup
@song1 = Song.new("Bon Jovi", "Livin on a prayer")
end
def test_get_artist
assert_equal("Bon Jovi", @song1.artist)
end
def test_get_title
assert_equal("Livin on a pra... |
class FontGeorgia < Formula
version "2.05"
url "https://downloads.sourceforge.net/corefonts/georgi32.exe"
desc "Georgia"
homepage "https://sourceforge.net/projects/corefonts/files/the%20fonts/final/"
def install
(share/"fonts").install "Georgiaz.TTF"
(share/"fonts").install "Georgiab.TTF"
(share/"... |
# -*- encoding : utf-8 -*-
require 'rails_helper'
RSpec.describe AbstractMoocProviderConnector do
self.use_transactional_fixtures = false
before(:all) do
DatabaseCleaner.strategy = :truncation
end
after(:all) do
DatabaseCleaner.strategy = :transaction
end
let(:mooc_provider) { FactoryGirl.create... |
class MoveActiveFromClientsToReportingRelationships < ActiveRecord::Migration[5.1]
def up
Client.all.find_each do |client|
ReportingRelationship.find_or_create_by(
user_id: client['user_id'],
client: client
) do |rr|
rr.active = client[:active]
end
end
end
end
|
class FontCormorantGaramond < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/cormorantgaramond"
desc "Cormorant Garamond"
homepage "https://fonts.google.com/specimen/Cormorant+Garamond"
def install
(share/"fonts").install "CormorantGa... |
require "rails_helper"
primo_url = Rails.application.config_for(:testing_keys)['primo_url']
RSpec.feature "Testing Primo URL: #{primo_url}", type: :feature do
it 'Visit primo home page' do
response = RequestService.send_request(primo_url)
expect(response.code).to eq('200')
expect(response.body).to have... |
# frozen_string_literal: true
class I18nSupport
def self.locale_names
[
["English", "en"],
["Hindi", "hi"]
]
end
end
|
# frozen_string_literal: true
require 'rails_helper'
module EasyMonitor
module Util
module Connectors
RSpec.describe ActiverecordConnector do
def use_active_record(use = false)
EasyMonitor::Engine.setup do |config|
config.use_active_record = use
end
end
... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Puppet::Type.type(:cups_queue).provider(:cups) do
let(:type) { Puppet::Type.type(:cups_queue) }
let(:provider) { described_class }
describe '#while_root_allowed' do
context 'when `access` is NOT specified' do
before(:each) do
... |
require "spec_helper"
describe Adapter::Facebook::To::Schema::PersonUser do
it 'should include Virtus' do
Adapter::Facebook::To::Schema::PersonUser.ancestors.should include Virtus
end
it 'should include Discoverer::Writer' do
Adapter::Facebook::To::Schema::PersonUser.ancestors.should include Discover... |
require File.dirname(__FILE__) + '/../../lib/routing'
require_relative './register_covid_service'
require_relative './suspect_response'
require_relative './question_processor'
require_relative './smell_question'
require_relative './cough_question'
require_relative './sore_throat_question'
require_relative './breath_pr... |
class PurchaseAddress
include ActiveModel::Model
attr_accessor :postal_code, :house_number, :city, :building, :tel, :state_id, :item_id, :user_id, :purchase_id, :token
with_options presence: true do
validates :postal_code, format: { with: /\A\d{3}-\d{4}\z/, message: 'はハイフンが必要です' }
validates :tel, format:... |
module Auth
class Configuration
include Auth::BehaviorLookup
delegate :configuration_keys, :to => 'self.class'
# The array of Auth::Model instances which represent the models which will be authenticated.
# See also #authenticate
attr_accessor :authenticated_models
include Auth::Confi... |
# frozen_string_literal: true
require 'net/http'
require 'uri'
module Tikkie
module Api
# Parses and wraps the response from the Tikkie API.
class Response
attr_reader :response, :body
def initialize(response)
@response = response
@body = response.body ? parse_body(response.body... |
require 'spec_helper'
describe StaticContent::Content do
describe "validation" do
[:text, :slug].each do |attribute|
it { should validate_presence_of(attribute) }
end
context "uniqueness" do
before do
StaticContent::Content.from_slug(:awesome, default: "Okay")
end
[:sl... |
# Pseudo-Code for a method that returns the sum of two integers.
=begin
START of program
SET variable_one for the first number argument
SET variable_two for the second number argument
RETURN the expression of adding variable_one and variable_two
END of program
=end
# Translation of Pseudocode to Ruby code
def add... |
RSpec.configure do |config|
# Run JS tests with truncation, not transactions,
# otherwise the data we set up may not be visible inside the
# headless browser running the tests.
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.befo... |
class DropTableWeathers < ActiveRecord::Migration[5.2]
def up
drop_table :weathers
end
def down
raise 'cannot go back'
end
end
|
class NtPort < ActiveRecord::Base
validates :node_type_id, :s_port, :t_port, presence: true
validates :t_port, uniqueness: {scope: [:node_type_id, :tcp]}
validates :t_port, :s_port, numericality:{greater_than:0,less_than:65536}
belongs_to :node_type
end
|
class CreatePwintyOrderWorker
include Sidekiq::Worker
sidekiq_options retry: 5
sidekiq_retries_exhausted do |msg, ex|
order = Order.find_by(id: msg["args"].first)
return if order.blank? || order.state != "ongoing"
order.update(state: "error")
RefundOrderWorker.perform_async(order.id)
begin... |
class CreateThumbnails < ActiveRecord::Migration
def change
create_table :thumbnails do |t|
t.text :thumb_post
t.string :thumb_title
t.string :thumb_image
t.timestamps
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.