text stringlengths 10 2.61M |
|---|
class ConvertRemainingNotes < ActiveRecord::Migration
def self.up
rename_column :database_instances, :notes, :description
rename_column :racks, :notes, :description
rename_column :statuses, :notes, :description
# Table for acts_as_commentable
create_table "comments", :force => true do |t|
t.... |
#
# Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com)
# Copyright:: Copyright (c) 2016 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# 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 th... |
require "spec_helper"
RSpec.describe "Day 2: Bathroom Security" do
let(:runner) { Runner.new("2016/02") }
let(:input) do
<<~TXT
ULL
RRDDD
LURDL
UUUUD
TXT
end
describe "Part One" do
let(:solution) { runner.execute!(input, part: 1) }
it "enters a code from the instructio... |
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
namespace :test do
Rake::TestTask.new(:units) do |t|
t.libs << "test"
t.pattern = 'test/unit/**/*_test.rb'
t.verbose = true
end
Rake::TestTask.new(:units_ups) do |t|
t.libs << "test"
t.pattern = 'test/unit/**/ups_t... |
module FacilitiesManagement
module Procurements
class DocumentsProcurementHelper
def self.review_docs
@review_your_contract_static_files = [
'Attachment 1 - About the Direct Award.docx',
'Attachment 2 - Statement of Requirements - Annex A - Standards and Processes (DA).docx',
... |
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "dry/matcher/version"
Gem::Specification.new do |spec|
spec.name = "dry-matcher"
spec.version = Dry::Matcher::VERSION
spec.authors = ["Tim Riley"]
spec.email = ["tim@icela... |
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
match "/delayed_job" => DelayedJobWeb, :anchor => false, via: [:get, :post]
# The main job of the routes:
# You map a request to A controller with an action
# providing the :as option will give ... |
#!/usr/bin/env ruby
require 'mruby/bindings'
require 'fileutils'
require 'csv'
require 'pp'
discovery = MRuby::Bindings::DiscoveryIndex.new
summary = MRuby::Bindings::SummaryIndex.new
$output_dirname = './mruby-bindings.out/blueprint'
$interface_blueprint_file = "#{$output_dirname}/interface.csv"
FileUtils.mkdir_p ... |
class AlbumCommentsController < ApplicationController
before_action :set_album_comment, only: [:show, :edit, :update, :destroy]
# GET /album_comments
# GET /album_comments.json
def index
@album_comments = AlbumComment.all
end
# GET /album_comments/1
# GET /album_comments/1.json
def show
end
#... |
Given /^a btc value of "(.*?)"$/ do |btc_value|
@btc = btc_value
end
When /^I ask for it to be converted to satoshi$/ do
@satoshi = Mpex::Converter.btc_to_satoshi(@btc)
end
Then /^it should return "(.*?)" satoshi$/ do |satoshi_amount|
@satoshi.should eq satoshi_amount
end
Given /^a satoshi value of "(.*?)"$/ d... |
class CaseStudy < ApplicationRecord
belongs_to :category
mount_uploader :photo, PhotoUploader
validates_presence_of :title, :summary, :description
validates :priority, inclusion: { in: [nil, 1, 2, 3, 4, 5, 6], message: "must be a number between 1 and 6" }
end
|
module SimpleJsonapi::SerializerMethods
# @!visibility private
def self.included(base)
class << base
# @return [Definition::Resource,Definition::Error]
attr_accessor :definition
def inherited(subclass)
subclass.definition = definition&.dup
end
end
end
# @return [Definit... |
require "formula"
class Wfproxynext < Formula
homepage "https://www.wavefront.com"
url "http://wavefront-cdn.s3-website-us-west-2.amazonaws.com/brew/wavefront-proxy-10.0.0.zip"
sha256 "b0bba11eceba7df0c8b8ffd4a7f7deae2781799c86ea2fce5991a25c6c61005d"
bottle :unneeded
depends_on "telegraf" => :optional
d... |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'fileutils';
broken = false;
filename = ARGV[0];
IO.foreach(filename) { |line|
if( line =~ /^@TRIPOS<SUBSTRUCTURE>/ )
broken = true;
break;
end
}
if( broken )
tmpname = filename + ".fix.tmp";
... |
class List < ActiveRecord::Base
validates :name, presence: true
validates :name, length: { minimum: 2 }
validates :category, length: { minimum: 2 }
validates :category, presence: true
validates :price, presence: true
validates :size, presence: true
validates :size, inclusion: %w(small medium large Small Medium L... |
#encoding:utf-8
module Merchant
class MerchantCategoriesController <JsonController
def index
@merchant_categories = Merchant::MerchantSubCategory.includes(sub_category: [:parent_category]).where(:merchant_store_id => params[:merchant_store_id])
@count =@merchant_categories.count
if paging_reques... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/files'
require 'bolt_spec/pal'
require 'bolt_spec/config'
require 'bolt/pal'
require 'bolt/inventory/inventory'
require 'bolt/plugin'
describe 'Result DataType' do
include BoltSpec::Files
include BoltSpec::PAL
include BoltSpec::Config
be... |
# daily_double.rb
# Write a method that takes a string argument and returns a new string that
# contains the value of the original string with all consecutive duplicate
# characters collapsed into a single character. You may not use
# `String#squeeze` or `String#squeeze!`.
# Pseudo-code:
# Data Structure:
# input: s... |
# Copyright (c) 2009-2011 VMware, Inc.
$:.unshift File.join(File.dirname(__FILE__), '..')
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
ENV["RACK_ENV"] = "test"
require "rubygems"
require "bundler"
Bundler.require(:default, :test)
require 'rspec'
require 'bundler/setup'
require 'json'
require 'logger'
re... |
class OwnerPreferencesController < ApplicationController
layout 'preferences'
before_filter :authenticate_owner!
before_filter :set_preferences
def show
@show = 'account'
end
def update
@owner.require_current_password
@owner.attributes = params[:owner]
if @owner.save
flash[:noti... |
require "spec_helper"
module Hangman
describe Game do
context "#initialize" do
it "accepts a 'Word' object" do
game = Game.new(Word.new)
expect(game.word).to be_a Word
end
it "returns the word value" do
game = Game.new(Word.new)
expect(game.word.value).to be_a String
end
end
end
... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# name :string(255)
# reset_password_token :string(2... |
class ResolutionsController < ApplicationController
before_action :set_resolution, only: [:show, :edit, :update, :destroy]
# GET /resolutions
# GET /resolutions.json
def index
@resolutions = Resolution.where(user_id: current_user.id)
end
# GET /resolutions/1
# GET /resolutions/1.json
def show
en... |
require 'spec_helper'
require 'shoulda/matchers'
RSpec.describe Card, type: :model do
describe 'associations' do
[:artworks, :properties, :card_effects].each do |association|
it { is_expected.to have_many association }
end
end
describe 'attributes' do
[:id, :name, :serial_number, :description,... |
class Image < ActiveRecord::Base
belongs_to :article
has_attachment :storage => :file_system,
:max_size => 1.megabytes,
:thumbnails => { :thumb => '80x80>', :preview => '250x250>' },
:processor => :ImageScience, # attachment_fu looks in this order: ImageScienc... |
require 'ostruct'
commands = "value 5 goes to bot 2
bot 2 gives low to bot 1 and high to bot 0
value 3 goes to bot 1
bot 1 gives low to output 1 and high to bot 0
bot 0 gives low to output 2 and high to output 0
value 2 goes to bot 2"
$pattern_value = /value (\d) goes to bot (\d)/
$pattern_give = /bot (\d) gives low... |
class Project < ApplicationRecord
has_and_belongs_to_many :users
has_many :tasks
validates_uniqueness_of :key
validates_presence_of :name
before_create :sanitize_key
scope :search_name, ->(project_name) { where("name ilike ?", "%#{sanitize_sql_like(project_name)}%") }
private
def sanitize_key
... |
# frozen_string_literal: true
require 'forwardable'
require 'pathname'
module TTY
class Tree
# A representation of tree node
#
# @api private
class Node
extend Forwardable
# The base name for the directory or file
attr_reader :name
# The parent directory path
attr_rea... |
class FontRokkittVfBeta < Formula
head "https://github.com/google/fonts/raw/main/ofl/rokkittvfbeta/RokkittVFBeta.ttf", verified: "github.com/google/fonts/"
desc "Rokkitt VF Beta"
homepage "https://fonts.google.com/specimen/Rokkitt+VF+Beta"
def install
(share/"fonts").install "RokkittVFBeta.ttf"
end
test... |
class CreateMasterDiscountReports < ActiveRecord::Migration
def self.up
create_table :master_discount_reports do |t|
t.date :date
t.integer :master_fee_discount_id, :null => false
t.integer :student_id, :null => false
t.integer :batch_id, :null => false
t.decimal :amount, :default =>... |
class Movie < ActiveRecord::Base
belongs_to :rating
belongs_to :studio
has_many :location_times
has_many :locations, through: :location_times
has_many :time_slots, through: :location_times
validates :name, presence: true
validates :description, presence: true
validate :length_greater_than_zero
... |
require 'nokogiri'
begin
require 'active_support/all'
rescue LoadError
require 'active_support'
end
require 'almodovar/version' unless defined?(Almodovar::VERSION)
require 'almodovar/digest_auth'
require 'almodovar/http_client'
require 'almodovar/http_accessor'
require 'almodovar/resource'
require 'almodovar/resou... |
class Url < ActiveRecord::Base
# Remember to create a migration!
before_create :validate_url
def self.make_short()
chars = ('a'..'z').to_a.join + ('A'..'Z').to_a.join + ('0'..'9').to_a.join
while true do
result = ''
7.times do
result = result + chars[rand(chars.length)]
end
... |
class BookingsController < ApplicationController
def index
@bookings = Booking.all
end
def show
@booking = Booking.find(params[:id])
end
def create
@booking = Booking.new(booking_params)
@pet = Pet.find(params[:booking][:pet_id])
if @pet.available?(@booking)
@booking.pet = @pet
... |
# frozen_string_literal: true
libx = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(libx) unless $LOAD_PATH.include?(libx)
require 'rubygems'
require 'bundler/setup'
require 'date'
require 'json'
require 'logger'
require 'aws-sdk-s3'
require 'aws-sdk-sqs'
class Cleanup
FLOW = {
"inbound": "screened",
... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = "ever_mid"
s.version = "0.0.3"
s.platform = Gem::Platform::RUBY
s.authors = ["ken"]
s.email = ["block24block@gmail.com"]
s.homepage = "https://github.com/turnon/ever_mid... |
class Activity < ActiveRecord::Base
belongs_to :user
belongs_to :effect_user, foreign_key: "effect_user_id", class_name: "User"
scope :order_desc_created_at, ->{order "created_at DESC"}
class << self
def user_edit_profile! user
Activity.create! user_id: user.id, effect_user_id: user.id , temtype: "EDIT... |
require 'test_helper'
class NlsControllerQuotaTest < ActionDispatch::IntegrationTest
def setup
super
Quota.reset_cache
interpretation = interpretations(:weather_forecast)
@agent = interpretation.agent
Nlp::Interpret.any_instance.stubs('send_nlp_request').returns(
status: '200',
body... |
class ApplicationController < ActionController::API
before_action :authenticate_user_from_token!
before_action :require_user_session!
private
def authenticate_user_from_token!
authorization_header = request.headers['Authorization']
return unless authorization_header.present?
user_id, user_token =... |
class Membership < ApplicationRecord
validates :member_id, :channel_id, presence: true
validates :channel_id, uniqueness: { scope: :member_id }
belongs_to :user,
foreign_key: :member_id,
class_name: :User
belongs_to :channel,
foreign_key: :channel_id,
class_name: :Chan... |
class Api::V0::ApiController < ApplicationController
skip_before_action :verify_authenticity_token
rescue_from ActiveRecord::RecordNotFound do
render 'record_not_found.json'
end
end
|
class User < ApplicationRecord
class Index < Trailblazer::Operation
include Collection, Policy
policy UserPolicy, :index?
def model!(params)
users_scope.page(params[:page])
end
protected
def users_scope
User.alphabetically
end
end
end
|
class FormaDePago < ActiveRecord::Base
has_many :receipts
belongs_to :user
end
|
require 'rails_helper'
RSpec.describe "browsing Products", type: :feature do
before :each do
FactoryGirl.create(:product, available_on: 1.year.ago, name: "Pikachu Side Table", slug: "pikachu-side-table")
end
it "shows a Product" do
visit "store/products/pikachu-side-table"
expect(page).to have_conte... |
class Menu < ActiveRecord::Base
include HasUniqueSlug
validates_presence_of :name
has_and_belongs_to_many :recipes
accepts_nested_attributes_for :recipes
belongs_to :created_by, class_name: "User", foreign_key: "created_by_user_id"
def to_param
slug
end
end
|
class Api::V1::UserSettingsController < ApplicationController
def create
user_setting = UserSetting.new(user_setting_params)
if user_setting.save
do_render("notice", "messages.created", 1)
else
do_render("error", "messages.not_create", 0)
end
end
def update
user_setting = UserSet... |
class User < ActiveRecord::Base
acts_as_authentic
before_create :populate_oauth_user
private
def populate_oauth_user
unless oauth_token.blank?
@response = UserSession.oauth_consumer.request(:get, '/account/verify_credentials.json',
access_token, { :scheme => :query_string })
case @res... |
# This migration comes from refinery_auditions (originally 1)
class CreateAuditionsAuditions < ActiveRecord::Migration
def up
create_table :refinery_auditions do |t|
t.string :firstname
t.string :lastname
t.string :dorm
t.string :voice
t.string :room
t.string :email
t.st... |
$:.push File.expand_path('../lib', __FILE__)
require 'snp_best_practices/version'
Gem::Specification.new do |s|
s.name = 'snp-best-practices'
s.version = SnpBestPractices::VERSION
s.platform = Gem::Platform::RUBY
s.summary = 'Simple best practices, used by S&P backend engineers in ruby proje... |
class Squares
def initialize(n)
@n = n
end
def square_of_sum
sum = [*1..@n].inject(0, &:+)
sum * sum
end
def sum_of_squares
[*1..@n].inject(0) {|sum, i| sum + (i * i) }
end
def difference
square_of_sum - sum_of_squares
end
e... |
class Order < ActiveRecord::Base
include AASM
include OrderMethods
include StateMachineMethods
attr_accessor :current_step, :order_accepted, :flash_notice
belongs_to :user
belongs_to :credit_card, autosave: true
belongs_to :billing_address, class_name: "Address", autosave: true
belongs_to :shipping_add... |
require 'spec_helper'
describe RCleaner::DslEvaluator do
describe '#initialize' do
before do
File.stub(:read) { "" }
end
it 'takes the file as a param' do
evaluator = described_class.new('s')
evaluator.filename.should == 's'
end
end
describe 'loading files' do
let(:copyfil... |
module Blueprints
class FixturesConverter
def initialize(options = {})
@format = "fixtures"
@source_files = options[:source_files]
@output_file = options[:output_file]
@blueprints_data = ""
raise "No source files given" unless @source_files
raise "No output file given" u... |
class CreateSection < ActiveRecord::Migration[5.2]
def change
create_table :sections do |t|
t.string :name, null: false, unique: true
t.integer :shelf_id, null: false
t.timestamps
end
add_index :sections, :shelf_id
end
end
|
require "sunspot"
require "rsolr/synchrony_connection"
module Sunspot
class Session
private
# override connection to return a synchrony ready connection
def connection
@connection ||=
self.class.connection_class.connect(RSolr::SynchronyConnection,
... |
class CreateTransactionsTable < ActiveRecord::Migration[5.1]
def change
create_table :game_transactions do |t|
t.integer :turn_action_id, null: false
t.integer :deed_id
t.string :transaction_type, null: false
t.integer :sender_id, null: false
t.integer :receiver_id
t.integer :a... |
module ApplicationHelper
def logged_in?
!current_user.nil?
end
end
|
require 'rails_helper'
feature 'User completes Procedure', js: true do
scenario 'and sees the blue button with white glyphicon denoting notes present' do
given_i_have_added_a_procedure_to_an_appointment
when_i_start_the_appointment
when_i_complete_the_procedure
then_i_should_see_the_notes_button
e... |
class AddIsFlaggedToSubmissionsAndComments < ActiveRecord::Migration[6.1]
def change
add_column :submissions, :is_flagged, :boolean, default: false
add_column :comments, :is_flagged, :boolean, default: false
end
end
|
class Future < ActiveRecord::Base
attr_accessible :quantity, :trade_id, :user_id, :trade_date, :lots, :entry_price, :quote, :year, :month
validates :trade_id, uniqueness: { :scope => :user_id }, presence: true
before_validation :assign_trade_id
before_save :assign_version
before_save :add_defaults
def a... |
RSpec.describe Tools::ArmstrongNumber do
it 'validates 6 as Armstrong number.' do
armstrong = Tools::ArmstrongNumber.new(6)
expect(armstrong.valid?).to be true
end
it '64 is not an Armstrong number.' do
armstrong = Tools::ArmstrongNumber.new(64)
expect(armstrong.valid?).to be false
end
it 'd... |
Rails.application.routes.draw do
root 'pages#home'
resources :merchants, only: [:index, :show] do
resources :products, except: [:destroy]
end
resources :reviews, only: [:create]
resources :orders, only: [:show, :edit, :update]
resources :products, only: [:index, :show, :update, :create]
resources :c... |
RSpec.describe "Diaper Drives", type: :system, js: true do
include DateRangeHelper
before do
sign_in @user
@url_prefix = "/#{@organization.id}"
end
context "When visiting the index page without parameters" do
let(:subject) { @url_prefix + "/diaper_drives" }
around do |example|
travel_to... |
class TicTacToe
attr_accessor :symbol, :turn_counter, :player1, :player2, :board, :winner
def initialize
@turn_counter = 0
@player1 = []
@player2 = []
@board = draw_board
@symbol = ""
@winner = ""
end
WINNING_COMBOS = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
... |
class CreateControlps < ActiveRecord::Migration
def change
create_table :controlps do |t|
t.time :horario_arme_desarme
t.time :horario_interfone
t.time :tempo_arme_automatico
t.timestamps null: false
end
end
end
|
require 'spec_helper'
describe MultiPurge do
describe :version do
subject { MultiPurge::VERSION }
it { should be_kind_of(String) }
end
end
|
cask :v1 => 'wiznote' do
version '2.1.13'
sha256 '5735502f06e93013f1350df89dd0423c1c250da798d7e5970d18a67034bb032f'
url 'http://release.wiz.cn/wiznote-macos-2014-09-25.dmg'
homepage 'http://www.wiznote.com/'
license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated... |
# frozen_string_literal: true
class FilterGenerator < Rails::Generators::NamedBase
source_root File.expand_path('templates', __dir__)
def generate_files
template 'filter.erb', "app/filters/#{file_name}_filter.rb"
template 'enum.erb', "app/graphql/enums/#{file_name}_field_enum.rb"
template 'input.erb',... |
def name(names) #creating the name method with a paramter equal to the names array
names.sample #the sample element will return a random element from the calling array
end
def activity(activities)
activities.sample
end
def sentence(name, activity) #creating a sentence method with two parameters, which returns a... |
require 'json'
require 'benchmark'
def measure(&block)
no_gc = (ARGV[0] == '--no-gc')
if no_gc
GC.disable
else
# collect memory allocated during library loading # and our own code before the measurement
GC.start
end
memory_before = `ps -o rss= -p #{Process.pid}`.to_i/1024
gc_stat_before = GC.stat
time =... |
require 'minitest/autorun'
require 'salesforceable'
class SalesforceableTest < Minitest::Test
class MyClass
attr_accessor :name
attr_accessor :email
attr_accessor :salesforce_id
attr_accessor :save_called
def save!
self.save_called = true
end
# This mimetize an ActiveRecor... |
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_one :profile
has_many :items
# I am ... |
module UserDecorator
# birthdayの値を元に年齢を計算する
def age
date_format = "%Y%m%d"
(Date.today.strftime(date_format).to_i - birthday.strftime(date_format).to_i) / 10000
end
# 学歴関連情報を学歴(学校名 詳細)の形で表示する
def academic_background_info
if self.academic_background.present? && self.school_detail.present?
"#{... |
module ApplicationHelper
def flash_alert flash
if flash.present?
message = flash[:error] || flash[:notice] || flash[:success] || flash[:alert]
flash_class = "danger" if flash[:error]
flash_class = "info" if flash[:notice]
flash_class = "success" if flash[:success]
flash_class = "ale... |
module NotionOrbit
module NotionObjects
module BlockTypes
class Paragraph < Block
def to_markdown
super + "\n"
end
def indent_children?
false
end
end
end
end
end |
require 'open3'
module Cb
extend ActiveSupport::Concern
def self.request(amount, type, id)
file = File.join(Rails.root, 'bin')
param = "merchant_id=014213245611111"
param = "#{param} merchant_country=fr"
param = "#{param} amount=#{amount}"
param = "#{param} currency_code=978"
param = "#... |
class User < ActiveRecord::Base
has_secure_password
validates :name, presence: true
validates :email, presence: true, :uniqueness => { :case_sensitive => false }
validates_format_of :email,:with => /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
validates :password, presence: true
validates :password , confirmation:true
... |
class SwatchesController < ApplicationController
def index
@user = User.find_by_username(params[:user_id])
@swatches = @user.nil? ? Swatch.recent : @user.swatches
respond_to do |format|
format.html
format.json { render json: @swatches.as_json }
end
end
def create
color = Color.fi... |
# frozen_string_literal: true
module Api::V1::Videos
class ViewController < ::Api::V1::ApplicationController
def create
api_action do |m|
m.success do
head 202
end
m.failure(:create) do
head 202
end
end
end
def destroy
api_action do ... |
class CreateMenuItems < ActiveRecord::Migration
def self.up
create_table :menu_items do |t|
t.column :text, :string
t.column :image, :string
t.column :path, :string
t.timestamps
end
end
def self.down
drop_table :menu_items
end
end
|
class Role < ActiveRecord::Base
has_many :role_assignments
has_many :users, through: :role_assignments
end
|
class PostSub < ApplicationRecord
validates :sub_id, :post_id, presence: true, unique: true
has_and_belongs_to_many :posts
has_and_belongs_to_many :subs
end |
class TailgatesController < ApplicationController
before_filter :authenticate_user!, only: [:new, :edit, :create, :update, :destroy]
cache_sweeper :sitemap_sweeper
# GET /tailgates/search.js
def search
thePage = params[:page] ? params[:page].to_i : 1
if (params[:team_id] && params[:team_id].length > ... |
require 'screenplay/stage'
describe Screenplay::Stage do
subject do
class Tester
include Screenplay::Stage
end
Tester.new
end
describe '.included' do
it 'adds the base includer class to the internal list of stages' do
Screenplay::Environment.stages.should_receive(:<<).with('tester'... |
class AddReferrals < ActiveRecord::Migration
def self.up
create_table :referrals do |t|
t.string :code, :referrable_type
t.integer :user_id, :referrable_id
end
add_index :referrals, [:referrable_id, :referrable_type]
add_index :referrals, :code
add_index :referrals, :user_id
end
d... |
class Page < ApplicationRecord
validates_uniqueness_of :permalink
def to_param
permalink
end
end
|
module I18nHelper
def t? key
I18n.t key, raise: true rescue false
end
def current_lang
lang(I18n.locale.to_s)
end
def current_locale
case I18n.locale.to_s
when 'uk' then :us
else I18n.locale
end
end
def lang(locale)
case locale.to_s
when 'se' then 'Svenska'
when 'us' then 'English (US)'... |
Rails.application.routes.draw do
mount_devise_token_auth_for 'User', at: 'api/auth'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
namespace :api do
resources :artists do
resources :interactions
resources :photos
resources :events
... |
class Forecasts::CashRevenuesController < ApplicationController
before_action :set_cash_revenue, only: [:show, :edit, :update, :destroy]
# GET /cash_revenues
# GET /cash_revenues.json
def index
@forecast = Forecast.find(params[:forecast_id])
@cash_revenues = CashRevenue.where(user_id: current_user.id)
... |
class Event < ActiveRecord::Base
validates_presence_of :title, :date, :description
end
|
class PageSerializer < ActiveModel::Serializer
attributes :name, :relative_path, :data_type, :slug
has_many :sub_pages, each_serializer: :sub_page_serializer
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: settings
#
# id :bigint(8) not null, primary key
# mc_only :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not null
#
require 'rails_helper'
RSpec.describe Setting, type... |
=begin
Report.for(:monthly_spend).run(Date.new(2018,1,1), Date.new(2018,1,31))
=============
Monthly Spend
=============
Total Value Categories
-XXX.00 Bills,Council Tax
-XX.00 Bills,Mobile Phone
Paid In: XXXX.XX
Paid Out: -XXXX.XX
Balance: -XXX.XX
=end
module BankStatements
mo... |
class Api::V1::DislikesController < ApplicationController
def index
dislikes = Dislike.all
render json: dislikes
end
end
|
class CrawlerRefactor
require 'open-uri'
def initialize(args)
args = defaults.merge(args)
@max_pages = args[:max_pages]
@urls = [args[:url]]
@starting_url_object = run_domainatrix(args[:url])
@completed_urls = []
@html_documents = []
@pages_crawled = 0
end
def run
raise Argumen... |
module Ncr
START_OF_NEW_6X_APPROVAL_POLICY = "2016-07-05 00:00".in_time_zone("America/New_York")
class ApprovalManager
def initialize(work_order)
@work_order = work_order
end
def system_approvers
if %w(BA60 BA61).include?(work_order.expense_type)
ba_6x_approvers
else
... |
require 'rails_helper'
describe "login user express intent to join a event", js: true do
let!(:event) { create :event }
context "when login user click '参加する' in the event detail page" do
before do
visit root_path
click_link 'Twitterでログイン'
visit event_path, event
click_on '参加する'
end
... |
require 'test_helper'
class StockindicesControllerTest < ActionDispatch::IntegrationTest
setup do
@stockindex = stockindices(:one)
end
test "should get index" do
get stockindices_url
assert_response :success
end
test "should get new" do
get new_stockindex_url
assert_response :success
... |
COCKTAILS = [
"Godfather",
"Ti’ Punch",
"Nuage noir",
"Hanky Panky",
"Old Cuban",
"Champagne Cocktail",
"Jungle Bird",
"White Russian",
"Vesper",
"Amaretto Sour",
"Painkiller",
"Long Island Iced Tea",
"Vodka Martini",
"Bramble",
"Sidecar",
"Mint Julep",
"Paloma",
"Cuba Libre",
"Americano",
"Cosmopolitan",
"French 75",
... |
class ChangeLikesDislikesInAnswers < ActiveRecord::Migration[5.1]
def change
change_column :answers ,:likes,:integer, default: 0
change_column :answers ,:dislikes,:integer, default: 0
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.