text stringlengths 10 2.61M |
|---|
class CreateRedirects < ActiveRecord::Migration[5.1]
def change
create_table :redirects do |t|
t.string :from_path
t.string :to_url
t.timestamps
end
end
end
|
# write a program that prompts the user for two positive integers
# and then prints the results of the following operations
# on those two numbers: addition, subtraction, product
# quotient, remainder and power
# do not worry about validating input
# Example:
#
# ==> Enter the first number:
# 23
# ==> Enter the seco... |
# --- Day 8: Space Image Format ---
# The Elves' spirits are lifted when they realize you have an opportunity to reboot one of their Mars rovers, and so they are curious if you would spend a brief sojourn on Mars. You land your ship near the rover.
#
# When you reach the rover, you discover that it's already in the pro... |
# frozen_string_literal: true
require 'spec_helper'
provider_class = Puppet::Type.type(:powerdns_zone_private).provider(:pdnsutil)
describe provider_class do
let(:resource) do
Puppet::Type::Powerdns_zone_private.new(
name: 'example.com',
provider: described_class.name,
)
end
let(:provider)... |
class AddClicksToRedirects < ActiveRecord::Migration[5.1]
def change
add_column :redirects, :clicks, :integer, default: 0
end
end
|
module Selectize::Ajax::Core
class Settings
def initialize(options = {})
@options = options
end
def call
::OpenStruct.new(default_options.merge(@options))
end
private
def default_options
{
collection: [],
required: true,
add_modal: nil,
add_... |
require "ruby2d"
require_relative "Shape"
# * Shape integration
# * Map outline
# * Shape collision
class MyMap
attr_accessor :map_size_x, :map_size_y, :map
def initialize(map_size_x, map_size_y)
@map = Array.new(map_size_y) { Array.new(map_size_x, 0)}
@map_size_x = map_size_x
... |
json.projects do
json.array! @projects, partial: 'api/v1/projects/project', as: :project
end
json.pagination do
json.page @page
json.slice "#{((@page - 1) * Project.per_page) + 1} to #{@page * Project.per_page}"
json.per_page Project.per_page
json.pages (Project.where('hearted > 0').count / Project.per_page).... |
class WelcomeMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.welcome_mailer.welcome.subject
#
def welcome(user)
@greeting = "Hi #{user.name.titleize},"
@user = user
mail( to: @user.email, subject: 'Welcome to Trea... |
describe "ActsAsTaggableOn" do
let(:tenant) { Tenant.find_or_create_by!(:name => "default") }
let(:source) { Source.find_or_create_by!(:name => "OCP", :uid => "9a874712-9a55-49ab-a46a-c823acc35503", :tenant => tenant) }
context "common tagging operations" do
it "is taggable" do
expect(source.is_taggabl... |
Rails.application.routes.draw do
namespace :jsonapi do
jsonapi_resources :courses, only: %i[show index create]
jsonapi_resources :rounds, only: %i[show index create]
jsonapi_resources :scorecards, only: %i[show index]
jsonapi_resources :turns, only: %i[show index update]
jsonapi_resources :users, ... |
require 'minitest/autorun'
require_relative 'solution'
class SolutionTest < Minitest::Test
def test_dist
assert_equal([0, 3, 5], [[1, 5], [4, 22], [6, 55]].distances)
end
def test_compress
c = [[1, nil, nil, nil],
[nil, 2, 5, nil],
[6, nil, nil, 7],
[nil, 3, nil,... |
class AddEvaluationlvlToOrder < ActiveRecord::Migration
def change
add_column :orders, :evaluationlvl, :string
add_column :orders, :evaluationcon, :text
end
end
|
$LOAD_PATH.unshift File.dirname(__FILE__)
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'libs')
require 'parseconfig'
require 'auto_telnet_run'
alias org_puts puts
def puts output_string
$output_file << output_string << "\n"
org_puts output_string
end
def main
setting = ParseConfig.new('setting.i... |
require 'spec_helper'
describe 'Command Client' do
before do
@output_path = "spec/commands/output"
@file_path = "#{@output_path}/simple1.txt"
end
it 'Can use' do
command_list = CompositeCommand.new
command_list.add(CreateFile.new("#{@output_path}/file1.txt", "Hello World\n"))
command_list.ad... |
require "plane"
describe Plane do
let(:plane) {Plane.new}
it "has a 'flying' status when created and is in the air" do
plane.flying!
end
it "flies when it's on the air" do
expect(plane.flying!).to be_true
end
it "doesn't fly after landing" do
expect(plane.landed!).to be_false
end
it "changes its st... |
module OAuth
class Base
class << self
def fetch_user(code)
token_response = fetch_access_token_response(code)
return { error: token_response['error'] } if error?(token_response)
profile_response = fetch_profile_response(token_response['access_token'])
return { error: profil... |
require "test_helper"
describe Work do
let(:album1) { works(:album1) }
let(:user) { users(:one) }
let(:vote1) { votes(:vote1) }
let(:vote2) { votes(:vote2) }
it "must be valid" do
value(album1).must_be :valid?
end
describe "topten" do
it "will return top votes" do
results = Work.topten("b... |
require 'rails_helper'
describe Api::V1::GoalsController, :type => :controller do
before(:each) do
user_params = {
:email => "test@goat-app.com",
:name => "Goaty McGoatface",
:password => "iamthegoat",
:token => SecureRandom.base58(24)
}
@user = User.create(user_params)
exer... |
require "ostruct"
class Main
include Cfnresponse
def lambda_handler(event:, context:)
puts("Received event: " + json_pretty(event))
case event['RequestType']
when "Create"
# create logic
send_response(event, context, "SUCCESS")
end
end
end
RSpec.describe Cfnresponse do
let(:event... |
require 'rails_helper'
describe 'Footer', type: :feature do
before do
visit root_path
end
scenario 'contains sharing menu items' do
expect(page.first('ul.list-inline.mb-25').text).to have_content I18n.t('navigation.home')
expect(page.first('ul.list-inline.mb-25').text).to have_content I18n.t('... |
# Copyright 2014 Square 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 applicable law or agreed ... |
# Write a method, reverse_map, which invokes a block on each of the elements in reverse order,
# and returns an array of their results.
#
# reverse_map(1, 2, 3) { |i| i * 2 } # => [6, 4, 2]
def reverse_map(*elements, &block)
elements.map{|element| block.call(element)}.reverse # can also write yield(element)
en... |
class Category < ActiveRecord::Base
# has_and_belongs_to_many :departments
#Validation
before_validation :strip_whitespace
validates :name, :presence => true
validates_uniqueness_of :name, :case_sensitive=>false, :if=>Proc.new {|u| !u.name.blank?}
scope :active, where(:is_active => true, :deleted => fals... |
=begin
Script qui charge les data d'un film
@recoit :film_id Identifiant du film
@return :film_data Les data générales du film
=end
require_model 'film'
film = Film.new(param(:film_id))
if film.exists?
RETOUR_AJAX[:film_data] = film.data
else
raise "Le film #{param(:film_id)} est introuva... |
require('minitest/autorun')
require('minitest/reporters')
require_relative('../client.rb')
require_relative('../karaoke_room.rb')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
class TestKaraokeRoom < Minitest::Test
#Setup method for test data
def setup()
@karaoke_room1 = KaraokeRoom.new("Room... |
module Goodreads
module Reviews
# Recent reviews from all members.
#
# params[:skip_cropped] - Select only non-cropped reviews
#
def recent_reviews(params={})
skip_cropped = params.delete(:skip_cropped) || false
data = request('/review/recent_reviews', params)
if data['reviews'] ... |
class AddPriceToChallenges < ActiveRecord::Migration[5.0]
def change
add_column :challenges, :price, :text
end
end
|
FactoryGirl.define do
factory :event, :class => Event do
name "TFN Bible Study"
date_and_time DateTime.new(2020, 10, 3)
cars_going [1, 2, 3]
people_going [1, 2, 3, 4, 5, 6, 7]
end
end
|
class Comment < ActiveRecord::Base
has_many :posts, :dependent => :destroy, :order => "created_at ASC" # when getting the posts the "oldest" one is returned first and assumed to be the "first reply"
validates_presence_of :title
validates_presence_of :body
end
|
# frozen_string_literal: true
module Application
module RateLimit
module ClassMethods
def rate_limit!(namespace, only: nil, except: nil)
before_action(only: only, except: except) { rate_limit!(namespace) }
end
end
def self.included(klass)
klass.extend(ClassMethods)
end
p... |
require 'webex/meeting/presenter'
require 'webex/meeting/attendee'
require 'webex/meeting/action'
require 'webex/meeting/schedule'
require 'webex/meeting/registration'
require 'webex/meeting/report'
module Webex
# comment
module Meeting
PATH_URL = 'm.php'.freeze
def post_url
URI.join(CONFIGURATION.ho... |
# Read about factories at http://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :release do
name "Release"
description "My little description"
finished_date "2012-01-24"
started_date "2012-01-24"
project
end
end |
# == Schema Information
#
# Table name: essay_images
#
# id :integer not null, primary key
# photo_essay_id :integer not null
# essay_image_asset :string(255) not null
# text :text
# created_at :datetime not null
# updated_at :datetime ... |
control "V-72983" do
title "PostgreSQL must provide audit record generation capability for
DoD-defined auditable events within all DBMS/database components."
desc "Without the capability to generate audit records, it would be
difficult to establish, correlate, and investigate the events relating to an
incide... |
class User < ApplicationRecord
has_many :pin
has_many :comment, through: :pin
end
|
# frozen_string_literal: true
module Jidoka
module Validatable
extend ActiveSupport::Concern
included do
attr_reader :message, :error
##
# This is a Hash of required argument keys and their expected class
class_attribute :argument_types, :errors
def validate!
validate... |
Given(/^I am a user$/) do
@user = create(:user)
end
When(/^I click on the link in my confirmation email$/) do
host = Capybara.current_session.server.host
port = Capybara.current_session.server.port
visit user_confirmation_path(
confirmation_token: @user.confirmation_token,
redirect_url: "http://#{host}... |
require 'chef'
require 'cheffish/rspec/chef_run_support'
require_relative '../../libraries/hive_metastore'
describe 'hive_metastore_database' do
extend Cheffish::RSpec::ChefRunSupport
let :resource do
recipe do
hive_metastore_database "run #{the_action}" do
root_password 'therootpassword'
... |
# frozen_string_literal: true
module Boring
module Tailwind
class InstallGenerator < Rails::Generators::Base
desc "Adds Tailwind CSS to the application"
source_root File.expand_path("templates", __dir__)
class_option :skip_tailwind_init_full, type: :boolean, aliases: "-sif",
... |
#in questa stampa la variante fa da spacca pagina
require "rubygems"
require "prawn"
#require 'barby'
#require 'barby/barcode/code_39'
require 'barby/outputter/svg_outputter'
require 'prawn-svg'
require 'fileutils'
#permette l'inserimento di caratteri speciali
Encoding.default_external = 'UTF-8'
$nome_f... |
require 'test_helper'
class InviteTest < ActiveSupport::TestCase
def setup
@invite = Invite.new email: "asd@asd.asd"
end
test "valid" do
assert @invite.valid?
end
test "invalid without email" do
@invite.email = " "
assert_not @invite.valid?
end
test "invalid with this emails" do
e... |
# Problem 198: Ambiguous Numbers
# http://projecteuler.net/problem=198
# A best approximation to a real number x for the denominator bound d is a rational number r/s (in reduced form) with s ≤d, so that any rational number p/q which is closer to x than r/s has q >d.
#
# Usually the best approximation to a real number... |
require "spec_helper"
describe OrderLineItemsController do
describe "routing" do
it "routes to #index" do
get("/order_line_items").should route_to("order_line_items#index")
end
it "routes to #new" do
get("/order_line_items/new").should route_to("order_line_items#new")
end
it "route... |
class Api::V1::ExerciseTypesController < Api::V1::BaseController
def index
exercise_types = ExerciseType.all
render :json => exercise_types.as_json
end
def create
exercise_type = ExerciseType.new(exercise_params)
if exercise_type.save
render :json => exercise_type.as_json
else
re... |
class Order < ApplicationRecord
has_many :order_items
has_many :dishes, through: :order_items
end
|
#encoding: utf-8
module MomentumCms
class Internationalization
@lookup = {
'en' => ['English', ''],
'af' => ['Afrikaans', ''],
'ar' => ['Arabic', ''],
'az' => ['Azerbaijani', ''],
'bg' => ['Bulgarian', ''],
'bn' => ['Bengali, Bangla', ''],
'bs' => ['Bosnian', ''],
'... |
module ApplicationHelper
def navbar(*menus)
menus.reduce('') { |a, e| a << menu_html(e) }
end
def menu_html(value)
"<li class='#{'active' if current_page?(value[1])}'>
#{link_to value[0], value[1]}
</li>"
end
def controller_action
"#{params[:controller]}-#{params[:action]}"
end
end... |
require 'rails_helper'
describe Api::V1::UsersController do
let(:user_1) { create(:user) }
let(:user_2) { create(:user) }
let(:user_3) { create(:user) }
let(:no_headers) { {'HTTP_ACCEPT': 'application/json'} }
let(:headers) { {'HTTP_X_USER_EMAIL': user_1.email, 'HTTP_X_USER_TOKEN': user_1.authentication_token... |
require_relative './car'
class ParkError < StandardError; end
class Slot
attr_accessor :slot_number, :car
def initialize (slot_number)
@slot_number = slot_number.to_i
end
def park(car_reg_number, car_colour)
if self.car
raise ParkError
else
self.car = ::Car.new(car_reg_number, car_colo... |
class AddExchangeRateIdToNotesAndUserWineCellarItems < ActiveRecord::Migration
def change
add_column :user_wine_cellar_items, :exchange_rate_id, :int, :default => nil
add_column :notes, :exchange_rate_id, :int, :default => nil
end
end
|
=begin
#===============================================================================
Title: Effect: State Action
Author: Hime
Date: Mar 13, 2013
--------------------------------------------------------------------------------
** Change log
Mar 13, 2013
- Initial release
--------------------------------------... |
module CTA
class Extension < ::Middleman::Extension
option :cta_directory, 'cta', 'Directory containing your CTA images'
option :cta_data, 'cta', 'Details of each CTA in YML or JSON format'
def initialize(app, options_hash={}, &block)
super
end
def after_configuration
app.logger.inf... |
require_relative "bot_management_service/state"
require_relative "bot_management_service/ask_me"
class BotManagementService
attr_reader :state
def initialize(state)
@state = State.new(state)
end
def process
if state.context["need_new_question"]
AskMe.call(state)
end
state
end
end
|
require 'rails_helper'
RSpec.describe 'Admin Dashboard', type: :feature do
let(:admin) { create :user, :admin }
it 'allows listing, searching, viewing, editing and deleting users' do
log_in admin
# Index
expect(page).to have_current_path admin_users_path, ignore_query: true
within('h1') { expect... |
require 'spec_helper'
describe RedPenTeacher::JsMarker do
describe '#mark' do
it 'returns return boolean value of passed js' do
marker = RedPenTeacher::JsMarker.new 'return "hoge";'
result = marker.mark 'https://www.google.co.jp'
expect(result).to be_truthy
end
it 'can access values... |
class RemoveTypeFromEnrollments < ActiveRecord::Migration[6.1]
def change
remove_column :enrollments, :type, :string
end
end
|
class InvoicePayment < Transaction
validate :valid_invoice
alias :invoice :auxilliary_model
def pays_in_full?
amount >= invoice.amount_billed
end
private
def valid_invoice
invoice.is_a? Invoice
end
end
|
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.datetime :happened_at, null: false
t.string :source, null: false
t.string :external_reference, null: false
t.timestamps null: false
end
add_index :events, [:source, :external_reference], unique: ... |
class Publication < ActiveRecord::Base
attr_accessible :journal, :title, :year, :professor_ids
has_and_belongs_to_many :professors
end
|
json.array!(@revenue_categories) do |revenue_category|
json.extract! revenue_category, :id, :user_id, :main_category, :sub_category
json.url revenue_category_url(revenue_category, format: :json)
end
|
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'playercenter-backend/version'
Gem::Specification.new do |gem|
gem.name = "playercenter-backend"
gem.version = Playercenter::Backend::VERSION
gem.authors = ["T... |
class AddLatitudeAndLongitudeToTask < ActiveRecord::Migration
def change
add_column :tasks, :lat, :decimal, :precision => 11, :scale => 7, :default => 0.0
add_column :tasks, :lon, :decimal, :precision => 11, :scale => 7, :default => 0.0
end
end
|
# -*- encoding : utf-8 -*-
module ModelMacros
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def it_should_validate_presence_of(*attributes)
attributes.each do |attribute|
it "should not be valid without #{attribute}" do
model = described_class.new
... |
class Captain < ActiveRecord::Base
has_many :boats
def self.catamaran_operators
joins(boats: [:classifications]).where("classifications.name = ?", "Catamaran")
end
def self.sailors
joins(boats: [:classifications]).where("classifications.name = ?", "Sailboat").distinct
end
def self.talented_seamen... |
class Candidate < ActiveRecord::Base
validates :candidate_lastname, :presence => true
validates :candidate_lastname, :uniqueness => true
validates :block,:interview_on,:usmle_1, :presence => true
mount_uploader :photo, PhotoUploader
has_many :ratings
has_many :users, :through => :ratings
end
|
#!/usr/bin/env ruby
require 'erb'
class MyVars
def initialize(class_name, class_name_underscore)
@class_name = class_name
@class_name_underscore = class_name_underscore
end
end
class_name = ARGV[0]
# Dirt simple way to convert 'AbcDef' to 'abc_def'
class_name_underscore = class_name.gsub(/(.)(... |
begin
require 'plist'
rescue LoadError
puts 'To use the mplayer bundler you must install the plist gem:'
puts 'gem install plist'
exit
end
require 'packager'
require 'dylibpackager'
class MPOSXBinPgkr < Packager
def plist(options = {})
options[:name] ||= "mplayer2"
options[:description] ||= "MPlayer... |
class UsersController < ApplicationController
# POST /users
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
else
format.html { render :new }
end
end
end
pr... |
# frozen_string_literal: true
module Vedeu
module Borders
# Allows the storing of interface/view borders independent of the
# interface instance.
#
# @api private
#
class Repository < Vedeu::Repositories::Repository
null Vedeu::Borders::Border, enabled: false
real Vedeu::Border... |
require './spec/helper'
describe HtmlIndexFormatter do
let(:result) {
instance_double(CoverageResult, coverable_files: COVERAGE_50_70)
}
let(:formatter) { HtmlIndexFormatter.new([], result) }
let(:index) { formatter.format }
describe 'API' do
specify { expect(formatter).to respond_to :format }
end... |
# frozen_string_literal: true
class Appointment
class << self
def new(from, to)
from_t = parse_date_time(from)
to_t = parse_date_time(to)
{ from: from_t, to: to_t }
end
def parse_date_time(str)
DateTime.parse(str)
rescue StandardError => _e
DateTime.now
end
end
e... |
json.array!(@devices) do |device|
json.extract! device, :id, :device_code, :serial_no, :model_no, :manufacturer, :first_use_date, :verify_date, :company_id
json.url device_url(device, format: :json)
end
|
class CreateInterests < ActiveRecord::Migration[5.0]
def change
create_table :interests do |t|
t.string :n_empenho
t.string :aplicacao
t.string :rsrp
t.text :obs
t.string :pregao
t.references :company, foreign_key: true
t.datetime :emissao
t.string :processo
t... |
class AddWordMeanings < ActiveRecord::Migration
def change
add_column :words, :meanings, :string
add_column :words, :description, :text
end
end
|
class Tag < ApplicationRecord
has_many :computers
end
|
class Product < ActiveRecord::Base
attr_accessor :image_file
validates_presence_of :name
validates_presence_of :product_type_id
validates_presence_of :price
validates_presence_of :quantity_in_stock
validate :image_file_format, :if => :image_uploaded?
belongs_to :product_type
has_many :order_products
... |
require 'pry'
class Dog
attr_accessor :id, :name, :breed
def initialize(hash)
#binding.pry
@id = hash[:id]
@name = hash[:name]
@breed = hash[:breed]
end
def self.create_table
DB[:conn].execute("CREATE TABLE dogs (id INTEGER PRIMARY KEY, name TEXT, breed TEXT)")
end
def self.drop_tabl... |
require 'bogo'
require 'forwardable'
require 'optparse'
require 'ostruct'
module Bogo
module Cli
# Parser for CLI arguments
class Parser
# @return [Symbol] represent unset value
UNSET = :__unset__
class OptionValues
extend Forwardable
NONFORWARDABLE = [:is_a?, :respond_to?... |
class FirmsController < ApplicationController
before_filter :find_firm, :only => [:show, :edit, :update, :destroy]
def index
@firms = Firm.where("is_active = 1").order(:name).paginate :page => params[:page], :per_page => 20
end
def show
end
def edit
end
def update
if not @firm.update_attribu... |
class UsersController < ApplicationController
before_action :validate_url_hack, only: []
before_action :logged_in_user, only: []
before_action :correct_user, only: []
def show
@user = User.find(params[:id])
if @user.hours.any?
@hours = @user.hours.all
end
end
def new
@user =... |
require 'bundler/setup'
require 'json'
require 'httparty'
require 'date'
require 'aws-sdk-s3'
require 'elasticsearch'
def lambda_handler(event:, context:)
event['Records'].each do |record|
city = take_city_from_record(record)
data = get_weather_forcast_data(city)
dt = save_time
# バックアップ用でS3にファイル保存
... |
# -*- coding: utf-8; tab-width: 4 -*-
require 'rss'
require 'date'
require 'time'
#require 'nokogiri'
websites = ['http://d.hatena.ne.jp/Kango/rss',
'http://www.st.ryukoku.ac.jp/~kjm/security/memo/memo.rdf',
'http://feeds.trendmicro.com/TM-Securityblog/',
'http://www.ipa.go.jp/security/rss/alert.rdf',
'http://ww... |
# -*- encoding : utf-8 -*-
class DefensesController < ApplicationController
# GET /defenses
before_filter :check_auth
# GET /defenses.json
def index
@defenses = Defense.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @defenses }
end
end
... |
require 'capybara/rspec'
class ViewIdeasPage < SitePrism::Page
element :viewideassearch_field, :xpath, ".//input[@id='search_ideas']"
element :viewideassearch_button, :xpath, ".//*[@id='viewIdeasInput']//a[@title='Search']"
element :stagefilter_dropdown, :xpath, ".//li[contains(@class,'idea_stage')]/a[select[@n... |
class ActionScope
attr_accessor :token
def initialize(token)
@token = token
end
def action_allowed?(policy_class, action_name)
return false unless token[:scopes].key?(:actions)
scope_name = policy_class.name.downcase[/^(.*)policy$/, 1].pluralize.to_sym
allowed_actions = token[:scopes][:action... |
require 'resque/server'
include ApplicationHelper
class SecureResqueServer < Resque::Server
before do
unless current_user and current_user.admin
redirect "/", :alert => "Access denied."
end
end
end
|
# frozen_string_literal: true
RSpec.describe LocateUserJob do
describe '.perform' do
let(:user) { create(:user) }
let(:ip_addr) { FFaker::Internet.ip_v4_address }
subject(:perform) do
described_class.perform_now(user_id: user.id, ip_addr: ip_addr)
end
it 'calls service' do
expect_an... |
class LeaveType
include Mongoid::Document
belongs_to :organization
field :name, type: String
#LEAVE_TYPE_NAME = ['Vacation Leave', 'Sick Leave', 'Administrative Leave', 'Convention Leave', 'Leave For Athletic Competition', 'Leave For Government Office', 'Leave for Emergency Civilian Duty', 'Leave To Appear As a... |
class ChangeOrderIdOnOrderItems < ActiveRecord::Migration[5.0]
def change
rename_column :order_items, :order_id, :shopping_cart_id
end
end
|
require 'spec_helper'
include SessionsHelper
RSpec.describe 'events/index.html.erb' do
before do
Rails.application.load_seed
end
context 'when the user is logged in' do
before { log_in(User.first) }
it 'displays the host name' do
assign(:past_events, Event.past)
assign(:upcoming_event... |
require 'starcraft'
module Starcraft
class GGTracker
attr_accessor :id, :name, :gateway, :matches_count, :hours_players, :race, :league_highest, :league_1v1, :league_2v2, :league_3v3, :league_4v4, :points, :season_games, :career_games, :apm
@leagues = {
0 => "bronze",
1 => "silver",
2 => "... |
module ApplicationHelper
def bulma_class_for flash_type
case flash_type
when "success"
"is-success"
when "error"
"is-danger"
when "alert"
"is-warning"
when "notice"
"is-info"
else
"is-primary"
end
end
end
|
class Owner < ActiveRecord::Base
# Include default devise modules. Others available are:
# :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :tickets
has_many :replies
def active_for_authentication?
s... |
class Api::GalleryPhotosController < ApplicationController
respond_to :json
layout nil
def destroy
photo = Photo.find(params[:id])
authorize photo
if photo.destroy
render json: { message: 'ok' }, status: :ok
else
render json: "error"
end
end
end
|
class AuthorRepositoryActiveRecord
include Datamappify::Repository
for_entity Author
default_provider :ActiveRecord
end
|
class UserMailer < ApplicationMailer
def reply_email(user_id)
@user = User.find(user_id)
mail( :to => @user.email,
:subject => "You've gotten a response!"
) do |format|
format.text
format.html
end
end
end
|
class Availability < ApplicationRecord
has_one :appointment, dependent: :destroy
validates :fp_id, presence: true
validates :from, presence: true
scope :free, -> { left_outer_joins(:appointment).where(appointments: { availability_id: nil }) }
end
|
module Ivona::Speech
class << self
# Helper. Gathers params for the create_speech_file method defined below.
def get_speech_file_params(text, voice, codec_id='mp3/22050',speed = "Prosody-Rate=100", sentencebreak = "Sentence-Break=400", paragraphbreak = "Paragraph-Break=650" )
token = Ivona::Auth.... |
class Product < ActiveRecord::Base
belongs_to :categorie
belongs_to :zone
has_many :line_items, dependent: :nullify
monetize :price_cents
mount_uploader :photo, PhotoUploader #cela definie, je ne sait pas comment qu'il y a un photo uploader pour ce model
validates :title, presence: {
message: "Le ti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.