text stringlengths 10 2.61M |
|---|
# encoding: utf-8
$: << 'RspecTests/Generated/string'
require 'generated/body_string'
include StringModule
describe String do
before(:all) do
@base_url = ENV['StubServerURI']
dummyToken = 'dummy12321343423'
@credentials = MsRest::TokenCredentials.new(dummyToken)
client = AutoRestSwagger... |
# frozen_string_literal: true
RSpec.shared_examples 'a Hyrax User' do
describe '#ability' do
it 'has abilities managed by Ability' do
expect(user.ability).to be_a Ability
end
end
describe '#email' do
it 'is the set email' do
expect { user.email = 'example.user@test.com' }
.to chan... |
require 'active_support/all'
module StateManager
module DSL
module State
# Specifies a state that is a child of the current state
def state(name, klass=nil, &block)
# If no base class is specified we look for a class inside the current
# state's class which has the same name as the s... |
#!/usr/bin/ruby
module CommandProtocol
attr_reader :command_line
attr_accessor :scheme_target,
:command,
:using_sync,
:current_dir,
:repo_base,
:checkout_base,
:build_base
def initialize(cl)
@command_line = cl
... |
class CreateWeather < ActiveRecord::Migration[6.0]
def change
create_table :weathers do |t|
t.date :date
t.float :lat
t.float :lon
t.string :city
t.string :state
t.json :temperatures
end
end
end
|
Rails.application.routes.draw do
resources :forecasts
root to: 'device#index'
end
|
require 'test_helper'
class EventsControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
@admin = users(:alice)
@user = users(:bob)
@event = events(:festival)
@event_params = {
content: 'Test content',
start: 3.days.from_now,
latitude: -1,
longitude: -1,
name: 'New ... |
class ChangeQuestionFiveToSeven < ActiveRecord::Migration[5.2]
def change
rename_column :questionaires, :question_five, :question_seven
end
end
|
class Event < ActiveRecord::Base
include Sluggable
validates :event_type, presence: true
validates :date, presence: true
validates :name, presence: true
validates :name, uniqueness: true
validates :slug, uniqueness: true
has_many :event_users
has_many :users, through: :event_users
has_one :client
... |
# frozen_string_literal: true
## --- BEGIN LICENSE BLOCK ---
# Copyright (c) 2016-present WeWantToKnow AS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including wit... |
# frozen_string_literal: true
require 'test_helper'
class ImagesControllerTest < ActionDispatch::IntegrationTest
setup do
# gets out test img from fixtures
@image = images(:img)
end
test 'should get index' do
get images_url
assert_response :success
end
test 'should get search' do
get se... |
require 'rails_helper'
feature 'Identity views Report tab', js: true, enqueue: false do
scenario 'and sees a list of Protocol reports' do
protocol = create_data
visit protocol_path(protocol)
click_button "study_schedule_report_#{protocol.id}"
click_link 'Reports'
expect(page).to have_css 'table... |
require('rspec')
require('go_fish')
describe(Game) do
describe('#player1') do
it('returns player1') do
player1 = Player.new("bob")
player2 = Player.new("sue")
test_game = Game.new(player1, player2)
expect(test_game.player1()).to(eq(player1))
end
end
describe('#player2') do
it(... |
# encoding: utf-8
require 'htph';
require 'json';
require 'logger';
require 'traject';
require 'traject/alephsequential_reader';
require 'traject/macros/marc21';
require 'traject/macros/marc21_semantics';
require 'traject/marc_reader';
require 'traject/ndj_reader';
require 'zlib';
require_relative '../ext/icu4j-56_1.ja... |
require 'integration_spec_helper'
describe 'File download' do
context 'given a public mega url (a small file)' do
let(:url) { 'https://mega.nz/file/muAVRRbb#zp9dvPvoVck8-4IwTazqsUqol6yiUK7kwLWOwrD8Jqo' }
it 'downloads the related file' do
Rmega.download(url, temp_folder)
related_file = File.jo... |
class Comment < ActiveRecord::Base
belongs_to :user
def to_s
'Comment'
end
end
|
require_relative('../db/sql_runner')
class Ticket
attr_reader :id
attr_accessor :customer_id, :movie_id, :cost
def initialize( options )
@id = options['id'].to_i if options['id']
@movie_id = options['movie_id'].to_i
@customer_id = options['customer_id'].to_i
@cost = options['cost']
end
# ... |
# frozen_string_literal: true
require 'sauce_bindings'
require 'rspec'
describe 'Browser Options' do
before { WebMock.allow_net_connect! }
it 'creates session' do
# 1. Create Selenium Browser Options instance
browser_options = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
# 2. Create Sa... |
require "./payment_refactor.rb"
describe 'refactoring' do
describe 'original methods with pay_by intercepted' do
before :each do
@order = double :order
stub!(:pay_by)
end
it 'should invoke nothing for pay_by_visa' do
ccn = double :ccn
pay_by_visa @order , ccn
end
... |
require 'rails_helper'
RSpec.describe 'Sedes API', type: :request do
# initialize test data
let(:user) { create(:user) }
let!(:sedes) { create_list(:sede, 10) }
let(:sede_id) { sedes.first.id }
let(:headers) { valid_headers }
# Test suite for GET /sedes
describe 'GET /sedes' do
# make HTTP get req... |
class AnswersController < ApplicationController
def create
@question = Question.find(params[:question_id])
@answer = @question.answers.build(answer_params)
@answers = @question.answers
if @answer.save
flash[:success]="投稿しました"
redirect_to @question
else
... |
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRa... |
# This is mostly lorem seeding, intended only for testing purposes. Seeding is created in the
# following order.
#
# 1) Clear up the databse just in case.
# 2) CONSTANTS
# 3) SECTION seeding
# 4) STORY seeding
# 5) SIMPLECONTENT seeding
# 6) QUOTECONTENT seeding
# 7) POSITIONS seeding
# 7a) RELATED STORIES seeding
#... |
require 'rspec'
class BeginTest
def pre_test_msg
"Alright, I'm going to ask you a series of questions, just relax and answer them as simply as you can."
end
def test_loop
questions = ["question 1", "question 2", "question 3"]
if questions.each { |question| puts question }
true
else
f... |
class Car < ActiveRecord::Base
def self.by_model
order(:model)
end
def self.by_make
order(:make)
end
def self.by_price(high = false)
if high
order(price: :desc)
else
order(:price)
end
end
def info
{make: self.make, model: self.model, price: self.price,... |
require File.expand_path '../../spec_helper.rb', __FILE__
RSpec.describe Report do
describe '#send' do
before do
Mail::TestMailer.deliveries.clear
described_class.new.send('https://google.com', '200', '500')
end
it { is_expected.to have_sent_email }
it { is_expected.to have_sent_email.f... |
class ReaddItemsToInteractions < ActiveRecord::Migration[5.2]
def change
remove_reference :interactions, :item
add_reference :interactions, :item, foreign_key: true
end
end
|
class Board < ActiveRecord::Base
extend FriendlyId
friendly_id :name
belongs_to :boards_group
has_many :topics, dependent: :destroy
validates :name, format: { with: /\A\w+\z/ }, uniqueness: true
def destroy_old_topics
max_topics_in_board = Settings.topic.max_topics_in_board
if (max_topics_in_bo... |
class ContactController < ApplicationController
def new
end
def create
begin
@contact = Contact.new(params[:contact])
@contact.request = request
if @contact.deliver
flash.now[:notice] = 'Thank You for Your Message!'
render :action => :new
else
redirect_to :action => :new
... |
class AddPurchaseDateToItems < ActiveRecord::Migration[5.0]
def change
add_column :items, :purchase_date, :date
end
end
|
ShopDemo::Application.routes.draw do
devise_for :users
root "listings#index"
resources :listings do
resources :orders
end
resources :purchases, only: :index
resources :sales, only: :index
get '/seller', to: "users#show", as: 'seller'
end
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
include SaltHelper
describe SaltHelper do
include SaltHelper
describe "#index_results_box" do
it "should call index_group_results if there's a grouping facet" do
helper.stub(:grouping_facet => 'year_facet')
expect(he... |
# frozen_string_literal: true
require "graphql/pagination/relation_connection"
module GraphQL
module Pagination
class MongoidRelationConnection < Pagination::RelationConnection
def relation_offset(relation)
relation.options.skip
end
def relation_limit(relation)
relation.options... |
module CDI
module V1
class GameItemAnswerSerializer < SimpleGameItemAnswerSerializer
has_one :game_item, serializer: SimpleGameItemSerializer
has_one :user, serializer: SimpleUserSerializer
end
end
end
|
class Driver
attr_reader :name
@@all =[]
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def rides
Ride.all.select {|ride| ride.driver == self}
end
def passenger_names
passengers = rides.map {|ride| ride.passenger.name}
passengers.uniq
end
... |
class User < ActiveRecord::Base
validates :name, presence: { message: "Name field cannot be blank." }
validates :email, presence: { message: "Email field cannot be blank." }
validates :email, uniqueness: { case_sensitive: false,
message: "There is an account with this email." }
validates :email, format: {... |
class RoomsController < ApplicationController
before_action :set_room, only: %i[ show edit update destroy ]
protect_from_forgery except: :show_additionally
def first_room
redirect_to "/rooms/#{Room.first.id}"
end
# GET /rooms or /rooms.json
def index
@rooms = Room.all.order(created_at: :desc)
... |
require "byebug"
require 'colorize'
require_relative "./tile.rb"
class Board
attr_reader :board
def initialize(difficulty)
if difficulty == "b"
@board = Array.new(9) { Array.new(9) }
@num_bombs = 10
elsif difficulty == "i"
@board = Array.new(16) { Array.new(... |
class Event < ActiveRecord::Base
validates :title, presence: true
attachment :image, type: :image
end
|
require 'digest/sha1'
class User < ActiveRecord::Base
validates_presence_of :name, :password, :password_confirmation
validates_uniqueness_of :name
validates_length_of :password, :within => 5..40
validates_confirmation_of :password
attr_accessible :name, :password, :password_confirmation
attr_accessor :pa... |
module NxtPipeline
class Pipeline
def self.call(acc, configuration: nil, resolvers: [], &block)
new(configuration: configuration, resolvers: resolvers, &block).call(acc)
end
def initialize(configuration: nil, resolvers: [], &block)
@steps = []
@error_callbacks = []
@logger = Logge... |
class Article < ActiveRecord::Base
has_many :comments
validates :title, :content, :presence => true
def to_param
"#{id}-#{title.gsub(/[\s]+/, '-')}"
end
end
|
class CreateWordCategories < ActiveRecord::Migration[5.0]
def change
create_table :word_categories do |t|
t.references :word, foreign_key: true, null: false
t.references :category, foreign_key: true, null: false
t.timestamps
end
end
end
|
require_relative '../../../../spec_helper'
describe 'base::supported_kernel', :type => :class do
describe 'disabled on trusty (default)' do
let(:facts) {{ 'lsbdistcodename' => 'trusty' }}
it do
is_expected.to contain_package('update-manager-core')
is_expected.not_to contain_package('linux-ge... |
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Opinions
describe OpinionActivityCell, type: :cell do
controller Decidim::LastActivitiesController
let!(:opinion) { create(:opinion) }
let(:hashtag) { create(:hashtag, name: "myhashtag") }
let(:action_log) do
... |
class Expertise < ApplicationRecord
belongs_to :user
has_many :missions, dependent: :destroy
geocoded_by :address
after_validation :geocode, if: :will_save_change_to_address?
include PgSearch
pg_search_scope :search_by_category_and_description,
against: [:category, :description],
associated_agains... |
class Answer < ActiveRecord::Base
include Votable
default_scope { order ('best DESC , created_at ASC') }
belongs_to :question
belongs_to :user
has_many :attachments, as: :attachable, dependent: :destroy
has_many :comments, as: :commentable, dependent: :destroy
validates :body, :user_id, :question_id, pr... |
require 'rails_helper'
RSpec.describe 'Volunteer managing asylum application drafts for shared friends', type: :feature, js: true do
let!(:volunteer) { create(:user, :volunteer) }
let!(:shared_friend) { create(:friend) }
let!(:not_shared_friend) { create(:friend) }
let!(:user_friend_association) { create(:user... |
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
include_recipe 'ecryptfs::default'
unless node['ecryptfs']['passphrase']
# if no passphrase but a signature, fail the run cause something is wrong
if node['ecryptfs']['signature']
Chef::Application.fatal!("Passphrase without Signature!")
else
# I... |
# == Schema Information
#
# Table name: main_champions
#
# id :integer not null, primary key
# championid :string
# created_at :datetime not null
# updated_at :datetime not null
#
class MainChampion < ApplicationRecord
has_many :champion_score, dependent: :destroy
validates_pre... |
require 'spec_helper'
describe 'redis', :type => 'class' do
let :facts do
{
:osfamily => 'Debian'
}
end # let
context "On a Debian OS with default params" do
it do
should compile.with_all_deps
should contain_class('gcc')
should contain_class('wget')
should contain_f... |
module RunPal
class CreateChallenge < UseCase
def run(inputs)
# Challenge-specific properties
inputs[:sender_id] = inputs[:sender_id] ? inputs[:sender_id].to_i : nil
inputs[:recipient_id] = inputs[:recipient_id] ? inputs[:recipient_id].to_i : nil
inputs[:user_id] = inputs[:user_id] ? inpu... |
class UserMailer < ApplicationMailer
def signup(user)
@user = user
mail(to: @user.email, subject: "welcome!")
end
def password_reset(username)
@user = User.find_by(name: username)
mail(to: @user.email, subject: "password reset")
end
def share(post, email)
@post = post
mail(to: email... |
#using output method instead of normal puts so that transition to GUI is easier
require 'colorize'
module Messager
def self.output(string)
string
end
def self.invalid
'invalid choice'
end
def self.welcome
"Welcome to MASTERMIND".colorize(:light_green)
end
def self.instructions
"You w... |
class RemoveUserIdFromComments < ActiveRecord::Migration
def change
remove_reference :comments, :user_id, index: true
remove_foreign_key :comments, :user_ids
end
end
|
class NFL < ActiveRecord::Base
has_many :players, through: => :teams
end |
class Unit < ActiveRecord::Base
attr_accessible :health, :kills, :player, :unitNumber, :species, :weapon, :armour
validates :kills, :presence => true
validates :player, :presence => true
validates :unitNumber, :presence => true
end
|
def substrings_at_start str
out_arr = []
index = 0
while index < str.length
sub_index = 0
while sub_index <= index
if !out_arr[index]
out_arr[index] = str[sub_index]
else
out_arr[index] << str[sub_index]
end
sub_index += 1
end
index += 1
end
return out_... |
class Player
include Drawable
attr_accessor :x, :y
def initialize(args={})
defaults.merge(args)
.each { |k,v| instance_variable_set("@#{k}",v) }
@color = "#733c00"
@bg_color = "#9c671a"
@string = "`X`"
end
def defaults
{
x: 0,
y: 0,
}
end
end
|
require 'rails_helper'
# As a user
# When I visit "/"
# And I fill in a search box with "80202" and click "search"
# Then my current path should be "/search" (ignoring params)
# And I should see stores within 25 miles of 80202
# And I should see a message that says "17 Total Stores"
# And I should see exactly 15 resul... |
require_relative 'module/firmwares.rb'
class Part
TYPE_FORMAT = /^[п][а][с][с][а][ж][и][р][с][к][и][й]$|^[г][р][у][з][о][в][о][й]$/
include Firmware
attr_reader :type
def initialize(type)
@type = type
validate!
end
def validate!
#проверка типа
raise 'Номер не может быть пустым' if type.... |
class AddDefaultValueToAssetsValue < ActiveRecord::Migration
def up
change_column :assets, :value, :float, default: 0.0
end
def down
change_column :assets, :value, :float
end
end
|
class PlayersController < ApplicationController
def show
@player = Player.find(params[:id])
render json: @player
end
def index
@players = Player.all
render json: @players
end
def new
@player = Player.new
end
# def edit
# @player ... |
require 'test_helper'
class GraphicRequestsControllerTest < ActionDispatch::IntegrationTest
setup do
@graphic_request = graphic_requests(:one)
end
test "should get index" do
get graphic_requests_url
assert_response :success
end
test "should get new" do
get new_graphic_request_url
assert... |
require 'httparty'
require 'json'
# This class represents a world traveller who knows what languages are spoken in each country
# around the world and can cobble together a sentence in most of them (but not very well)
class Multilinguist
TRANSLTR_BASE_URL = "http://bitmakertranslate.herokuapp.com"
COUNTRIES_BASE... |
class MatchingService
def match_all_customer_by_pet(pet)
Customer
.no_adoptions.like_age(pet.age).without_preferences
.or(Customer.no_adoptions.like_age(pet.age).like_species(pet.species))
.or(Customer.no_adoptions.like_age(pet.age).like_breed(pet.species, pet.breed))
end
def match_all_pet_... |
# https://github.com/discourse/discourse/blob/master/spec/mailers/invite_mailer_spec.rb
require "spec_helper"
describe InviteMailer do
describe "send_invite" do
let(:invite) { Fabricate(:invite) }
subject { InviteMailer.send_invite(invite) }
its(:to) { should == [invite.email] }
its(:subject) { sho... |
# == Schema Information
#
# Table name: reporter_groups
#
# id :bigint(8) not null, primary key
# section :string
# page_range :string
# leader :string
# created_at :datetime not null
# updated_at :datetime not null
# category_code :integer
#
class Reporte... |
class FontKokoro < Formula
head "https://github.com/google/fonts/raw/main/ofl/kokoro/Kokoro-Regular.ttf", verified: "github.com/google/fonts/"
desc "Kokoro"
homepage "https://fonts.google.com/specimen/Kokoro"
def install
(share/"fonts").install "Kokoro-Regular.ttf"
end
test do
end
end
|
class ScrapedBook
ATTRIBUTES = [:title, :location, :call_number, :status, :url]
attr_accessor *ATTRIBUTES
def initialize(options={})
options.each do |k,v|
self.public_send("#{k}=", v)
end
end
end
|
require 'test_helper'
class MiniUrlTest < ActiveSupport::TestCase
test "should not save without url_code" do
mini_url = MiniUrl.new
mini_url.url = "https://www.google.com/"
assert_not mini_url.save, "Saved mini_url without url_code"
end
test "should not save without url" do
mini_url = MiniUrl.n... |
module Users
class EmailPasswordReset < Mutations::Command
required do
model :user
end
def execute
self.user.update(:password_reset_token => SecureRandom.base64(64))
self.user
end
end
end |
# represent an event that change the state of a workspace
class WorkspaceStatusEvent < WorkspaceEvent
# equality for user
def ==(other)
return self.class == other.class
end
# notify the other user in the workspace
def notify
sender = self.member
receiver = self.find_receiver_from_sender_chat(sen... |
#!/usr/bin/ruby -w
# auto_manager.rb
require 'yaml'
require "file_helper"
require "auto"
#require "auto_types"
class Auto_manager
attr_reader :cars, :cars_file, :fh, :types
def initialize()
@types= ["economy", "compact", "full-size", "luxury", "convertable", "sports-car", "minivan", "pick-up-truck", "van"]... |
# Source: https://launchschool.com/exercises/77884ef5
def staggered_case(str)
str.chars.each_with_index do |val, idx|
if idx.odd?
val.downcase!
else
val.upcase!
end
end.join
end
p staggered_case('I Love Launch School!') == 'I LoVe lAuNcH ScHoOl!'
p staggered_case('ALL_CAPS') == 'AlL_CaPs'
... |
#!/usr/bin/env ruby
require 'fileutils'
require 'json'
manifest = JSON.parse(File.read('ext/manifest.json'))
name = manifest['name']
version = manifest['version']
crx_name = "#{name}-#{version}.crx"
FileUtils.mkdir_p('pkg')
product = File.join('pkg', crx_name)
# Note: $HOME/.chrome/ may not exist.
# You need to make... |
module StarterBot
class Bot < SlackRubyBot::Bot
help do
title 'starter_bot'
desc 'Just for fun'
command :say_hello do
title 'say_hello'
desc 'returns a greeting'
long_desc 'returns a greeting'
end
end
end
end
|
class AddActivationToLecturers < ActiveRecord::Migration[5.0]
def change
add_column :lecturers, :activation_digest, :string
add_column :lecturers, :activated, :boolean, default: false
add_column :lecturers, :activated_at, :datetime
end
end
|
# noinspection RubyResolve,RubyResolve
require_relative 'test_helper'
require 'logging'
Logging.logger.root.appenders = Logging.appenders.stdout
class GroupDiscountOfferTest < Minitest::Test
PRICE_TABLE = {
'S' => 20,
'T' => 20,
'X' => 17,
'Y' => 20,
'Z' => 21
}
def test_offer_em... |
require 'spec_helper'
describe "Partner pages" do
subject { page }
let(:collaborator) { FactoryGirl.create(:collaborator) }
before { sign_in collaborator }
describe "partner creation" do
before { visit new_partner_path }
describe "with invalid information" do
it "should not create a partner ... |
module PriorityTest
module Core
class TestResultCollector
attr_reader :all_tests
def initialize(all_tests)
@all_tests = all_tests
end
def add_result(test_result_hash)
identifier = test_result_hash[:identifier]
return unless identifier
@all_tests.get_test(... |
# require 'orientdb_binary/protocols/command'
# module OrientdbBinary
# module DatabaseOperations
# module Query
# def query(text, params, fetch_plan="*:0")
# class_name = 'com.orientechnologies.orient.core.sql.query.OSQLSynchQuery'
# serialized_params = OrientdbBinary::Parser::Serializer.n... |
# Pizza (Product) Classes
# Super Class
class Pizza
attr_reader :name, :dough, :sauce, :cheese, :pepperoni, :clam
def veggies
@veggies = @veggies || []
end
def toppings
@toppings = @toppings || []
end
def slice_method
@slice_method = @slice_method || "diagonal"
end
def bake
puts "Ba... |
include_recipe "apt"
# add the Zend Server repo
apt_repository "zend-server" do
uri "http://repos.zend.com/zend-server/#{node[:zend_server][:version]}/deb_ssl1.0"
distribution "server"
components ["non-free"]
key "http://repos.zend.com/zend.key"
action :add
end |
FactoryGirl.define do
factory :feedback do |f|
f.topic "Other"
f.body "Here's my idea: lorem ipsum dolor sit amet, consectetur adipisicing elit."
end
end
|
class UsersController < ApplicationController
#skip_before_action :require_login, only: [:create]
# ^ ^ Uncomment when implementing auth for require login ^ ^ (AUTH)
def index
@users = User.all
render json: @users.to_json(:include => [:mobs])
end
def create
@user = User.create(user_params)... |
class PhoneCallsController < ApplicationController
def index
@phone_calls = current_company.phone_calls
end
def new
@phone_call = PhoneCall.new
end
def create
@phone_call = current_company.phone_calls.build(phone_call_params)
if @phone_call.save
redirect_to phone_calls_path
else
... |
require 'spec_helper'
describe "clients/social_networks.html.slim" do
before(:each) do
client = Client.new(:name => "Client 1", :description => "Description", :image => "image.png")
client.save!
info = InfoSocialNetwork.new(:name => "Info Social Network Name 1", :description => "Info Social Description... |
module Gradebook
module Components
module Models
class GradeSet < Base
properties :name, :labels, :scale
end
end
end
end
|
class Customer < ActiveRecord::Base
has_many :orders
has_many :ratings
validates :email, :password, :firstname, :lastname, presence: true
def create_order
self.orders = Order.new
end
def current_order
self.orders.where(state: 'in progress').first
end
end
|
# frozen_string_literal: true
class Resource < ApplicationRecord
TYPES = { article: 'Resource::Article', sermon: 'Resource::Sermon' }.freeze
TYPES.each do |key, value|
scope key.to_s.pluralize, -> { where(type: value) }
end
extend FriendlyId
friendly_id :name, use: :slugged
has_one_attached :banner
... |
FactoryGirl.define do
factory :article do
title { Faker::Lorem.words.join(' ') }
content { Faker::Lorem.sentences(10).join("\n\n") }
end
end
|
class AddIndexToRecordsSingles < ActiveRecord::Migration
def change
add_index :records_singles, [:record_id, :single_id], :name => "index_records_singles_on_record_id_and_single_id"
end
end
|
class FacilitySetupController < ApplicationController
layout 'wizards/facility_setup'
authorize_resource class: false
before_action :validate_params, only: [:rooms_info, :room_summary, :row_shelf_info]
before_action :set_home_status
before_action :set_available_purposes, only: [:room_info, :section_info]
#... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'foods#index'
resources :foods
post '/foods/:id', to: 'foods#select_genre'
end
|
module Spree
class TrendingSearchReport < Spree::Report
DEFAULT_SORTABLE_ATTRIBUTE = :occurrences
HEADERS = { searched_term: :string, occurrences: :integer }
SEARCH_ATTRIBUTES = { start_date: :start_date, end_date: :end_date, keywords_cont: :keyword }
SORTABLE_ATTRIBUTES = []
def initialize(optio... |
require 'positional'
class Ballot
include Mongoid::Document
include Mongoid::Timestamps
field :ip
field :name
field :taste, :type => Array, :default => []
field :presentation, :type => Array, :default => []
field :creativity, :type => Array, :default => []
validates_presence_of :ip
validates_presen... |
# Time Complexity: The time complexity is O(n) because the algorithms time varies linearly with the length of the list array.
# Space Complexity: O(n) where n is the length of the array. The space complexity varies with the length of the array.
def remove_duplicates(list)
return list if list.length == 1 || list.lengt... |
class ReviewsController < ApplicationController
def new
@review = Review.new(:tour_id => params[:tour_id] , :user_id => current_user.id)
end
def create
@review = Review.new(review_params)
if @review.save
redirect_to bookings_path , :notice => "Review saved successfully"
else
render "ne... |
# frozen_string_literal: true
# Copyright (c) 2018-2020 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to us... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.