text stringlengths 10 2.61M |
|---|
class FontEtBook < Formula
head "https://github.com/edwardtufte/et-book/archive/gh-pages.zip", verified: "github.com/edwardtufte/et-book/"
desc "ET Book"
desc "Edward Tufte Book"
homepage "https://edwardtufte.github.io/et-book/"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp'... |
require 'opal'
require 'browser'
require 'browser/socket'
require 'browser/console'
require 'browser/dom'
require 'browser/dom/document'
require 'browser/http'
require 'browser/delay'
require 'native'
require 'item'
puts 'Loading Luggage...'
class Luggage
attr_reader :weights
attr_reader :weight_max
def weight=... |
class Maker < ApplicationRecord
belongs_to :year
has_many :roadbikes, dependent: :destroy
end
|
module CgScout
class Cloudgate
def initialize(required_version)
@cg_version = get_correct_version(required_version)
end
def get_correct_version(required_version)
installed_cg_versions = Gem::Specification.find_all_by_name('cloudgate').map &:version
correct_version = installed_cg_version... |
# encoding: utf-8
$: << 'RspecTests/Generated/azure_special_properties'
require 'rspec'
require 'securerandom'
require '2015-07-01-preview/generated/azure_special_properties'
include AzureSpecialPropertiesModule
describe 'Azure Special properties behaviour' do
before(:all) do
@base_url = ENV['St... |
module Resolvers
class PostSearch < Resolvers::BaseSearchResolver
type [Types::PostType], null: false
description "Lists posts"
scope { Post.all }
option(:id, type: String) { |scope, value| scope.where id: value }
option(:title, type: String) { |scope, value| scope.where title: value }
... |
class FileHandler
attr_reader :filename, :type
def initialize(filename, type)
@types = [:insertion, :query]
@handlers = {:insertion => :create_insertion, :query => :create_query}
@filename = filename
@type = type
end
def open
@file = File.open(filename, "r")
end
def finished?
@fil... |
class BrailleToEnglishFormatter
def initialize(file)
@file = file.chomp
@braille = []
end
def join
create_braille_letter = @file.split[0..2]
until create_braille_letter == [ '', '', '']
create_braille_letter .each do |string|
@braille << string.slice(0..1)
string.slice!(0..... |
require 'rails_helper'
class HackerNewsRequestMock
def request
end
end
class RedditRequestMock
def top_posts
end
def recent_comments
end
end
describe SocialWatcher do
before do
@hacker_news = HackerNewsRequestMock.new
@reddit = RedditRequestMock.new
allow(Watchers::HackerNews::HackerNewsRe... |
class CreateAgendas < ActiveRecord::Migration
def change
create_table :agendas do |t|
t.integer :conference_id
t.integer :sort_order, :default => 0
t.integer :level
t.string :name
t.text :description
t.timestamps
end
add_index :agendas, :conference_id
add_index :a... |
webserver_id = attribute('ec2_instance_webserver', description: 'Web server ID')
webserver_image_id = attribute('ec2_instance_webserver_ami', description: 'Ubuntu 16.04 AMI ID')
databseserver_image_id = attribute('ec2_instance_database_ami', description: 'Ubuntu 16.04 AMI ID')
vpc_id = attribute('vpc_id', description: ... |
require "spec_helper"
require "factory_girl"
describe SessionsController do
it "should redirect to login page when not logged in" do
get :new
assert_response :success
end
it "should re-render new template on failed save" do
User.should_receive(:authenticate).with("email", "password").and_return(n... |
class Settings::UserSessionPolicy < ApplicationPolicy
def destroy?
user == record.user
end
end |
module MethodsQuiz
def has_teen?(a, b, c)
(a >= 13 && a <= 19) || (b >= 13 && b <= 19) || (c >= 13 && c <= 19)
end
def not_string(str)
if str[0] == "n" && str[1] == "o" && str[2] == "t"
return str
else
return "not " + str
end
end
def icy_hot?(a, b)
(a < 0 && b > 100) || (b < 0 && a > 100)
en... |
class AddCopyrightToAllsetting < ActiveRecord::Migration
def change
add_column :allsettings, :copyright, :text
end
end
|
class CmisClient
module XmlUtils
ATOM_NS = 'http://www.w3.org/2005/Atom'
APP_NS = 'http://www.w3.org/2007/app'
CMISRA_NS = 'http://docs.oasis-open.org/ns/cmis/restatom/200908/'
CMIS_NS = 'http://docs.oasis-open.org/ns/cmis/core/200908/'
# standard rels
DOWN_REL = 'do... |
Rails.application.routes.draw do
resources :chats
resources :transactions
resources :pets
resources :users
#///////////////////////////////////////////////////////// User
get "/me", to: "users#show"
post '/signup', to: 'users#create'
post '/login', to: 'sessions#create'
delete '/logout', to: 's... |
class ProductCost < ActiveRecord::Base
monetize :cost_cents, :allow_nil => true
belongs_to :product
has_many :sale_costs, dependent: :destroy
validates :cost, numericality: { greater_than: 0 }
validates_presence_of :name
after_create :create_sale_costs
private
def create_sale_costs
set_foreca... |
class GroupUsersController < ApplicationController
before_action :find_group, only: :create
before_action :find_group_user, only: :destroy
def create
group_user = social_group.group_users.build user: current_user
if group_user.save
flash[:success] = "Da vao group"
redirect_to social_group_pa... |
require File.dirname(__FILE__) + '/example_helper.rb'
# Simple JiakData class with a couple of attributes
class PersonData
include JiakData
attr_accessor :name, :age
end
client = JiakClient.new(SERVER_URI)
bucket = JiakBucket.new('people',PersonData)
puts bucket.name # => 'people'
pu... |
class Dish
attr_accessor :name, :price
def initialize(name, price)
@name = name
@price = price
end
def print_item
"#{@name} $#{@price}"
end
end
class App
def initialize
@entrees = [
Dish.new('Hamburger', 4),
Dish.new('Grilled Cheese', 3),
Dish.new('Pizza Slice', 2)
]
... |
require 'spec_helper'
module Paraphrase
describe ScopeMapping do
describe "#chain" do
let(:mapping) { ScopeMapping.new(:name_like, :to => :name) }
it "applies scope method to Account.scoped object with values from params hash" do
Account.should_receive(:name_like).with('Jon Snow')
... |
class AddTopicToQuestionsTable < ActiveRecord::Migration
def up
add_column :questions, :topic, :integer
end
def down
remove_column :questions, :topic
end
end
|
# under gregorian calender, leap years occur in every year that is evenly
# divisible by 4
# unless the year is also divisible by 100
# if year is evently divisible by 100 then it's not a leap year
# unless it's divisible by 400
# write a method that takes any year greater than 0
# and returns true if the year is a le... |
class ConnectionsController < ApiController
requires_authentication
def create
outcome = CreateConnections.run(user: current_user, friend_type: friend_type, ids: friend_ids)
if outcome.success?
render :json => {success: true}, status: :ok
else
render :json => {success: false, errors: outco... |
module Jekyll
class Site
alias_method :_prometheus_original_process, :process
def process
load_environment(ENV['JEKYLL_ENV'] ||= 'local')
config.update(
'authors' => YAML.load_file(File.join(source, '_authors.yml')),
'uri' => URI.parse(config['url'])
)
if Objec... |
require 'test_helper'
class ChemicalsControllerTest < ActionController::TestCase
setup do
@chemical = chemicals(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:chemicals)
end
test "should get new" do
get :new
assert_response :success
... |
class BeersController < ApplicationController
before_action :find_beer, except: [:index, :new, :create]
def index
@beers = Beer.all
# Sending the ivar to a view
# Rendering the view
end
#####################
def show
end
def new
@beer = Beer.new
end
def create
@beer = Beer.new(beer_params)
if @be... |
class Micropost < ActiveRecord::Base
belong_to :user
validates :content, :length => { :maximum 140 }
end
|
# Time Scheduler
# You're working on a scheduler app. The user would like to attend as many events as possible but cannot attend events that overlap. Can you find the schedule with the greatest number of non-overlapping events?
# See if you can find an O(n log n) solution.
# I/O Format
# You will be given a list of n... |
class Types::CoordinatesType < Types::BaseObject
field :latitude, Float, null: true
field :longitude, Float, null: true
def latitude
object.first
end
def longitude
object.last
end
def self.authorized?(obj, cnt)
obj.first > 10 && obj.last < 10
end
end |
# frozen_string_literal: true
module Keycard
# This class is responsible for extracting the user attributes (i.e. the
# complete set of things that determine the user's #identity), given a Rack
# request.
class RequestAttributes
def initialize(request, finder: InstitutionFinder.new)
@finder = finder
... |
class StickerLimitReached < StandardError; end
class Telegram::OrderController < Telegram::Bot::UpdatesController
include Telegram::Bot::UpdatesController::Session
before_action :set_customer
before_action :set_product
before_action :set_customer_chat_reference
CONTINUE_ORDER = "Continue order"
START_NEW... |
#! /usr/bin/ruby
#
# pairTest.rb
#
# Copyright (c) 2016 - Ryo Kanno
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#
require_relative "SAMReader.rb"
require "optparse"
class MeasureDistance
def initialize
@use_file = false
@hash = nil
end
def open(... |
require 'spec_helper'
feature "manages a list" do
background do
@user = Factory.create(:user)
@other = Factory.create(:other)
login_as @user
end
scenario "my home page" do
page.should have_content("Sem listas de tarefas")
end
scenario "create a new list" do
create_a_list
page.should h... |
#!/usr/bin/env ruby
# coding: utf-8
require 'json'
require 'optparse'
#オプションの判定を行う
def options
args = {}
OptionParser.new do |parser|
parser.on('-c VALUE', '--code VALUE', '座標系番号'){|v| args[:c] = v}
parser.on('-i VALUE', '--input VALUE', 'JSONファイル(必須)'){|v| args[:i] =v}
parser.on('-x VALUE'... |
require_relative '../test_helper'
require 'hquery-patient-api'
class LibraryFunctionTest < Minitest::Test
def setup
@context = get_js_context(HQMF2JS::Generator::JS.library_functions)
@context.eval("hqmf.SpecificsManager.initialize()")
end
def test_library_function_parses
assert_equal false, @co... |
class Alphametics
def self.solve(input)
new(input).solve
end
def initialize(input)
@input = input
@letters = @input.tr(' ', '').tr('+', '').tr('==', '').chars.uniq
@summands, @sum = split_equation(@input)
end
def solve
result = solve_for(@letters)
result ? result : {}
end
privat... |
class Topic < ActiveRecord::Base
mount_uploader :avatar, AvatarUploader
validates :content, presence: true
belongs_to :user
has_many :comments, dependent: :destroy
end
|
public class DatabaseLogger
{
public void Log(string message) {
string messageToLog = SerializeMessage(message);
ConnectToDatabase();
InsertLogMessageToTable(messageToLog);
CloseDbConnection();
}
private string SerializeMessage(object message) {
WriteLine("Serializing... |
# Copyright 2015-2017 SUSE LLC
require 'timeout'
Given(/^the Salt Minion is configured$/) do
# cleanup the key in case the image was reused
# to run the test twice
step %(I delete this minion key in the Salt master)
step %(I stop salt-minion)
step %(I stop salt-master)
key = '/etc/salt/pki/minion/minion_ma... |
require 'rails_helper'
RSpec.describe Presenter::Feedback do
subject(:presenter) do
described_class.new(form_builder_payload: base_payload, api_version: api_version)
end
describe '#optics_payload' do
context 'v1 legacy form-builder' do
let(:base_payload) do
{
serviceSlug: 'user-f... |
require 'google/apis/drive_v3'
require 'googleauth'
module DriveManager
# Class for interacting with the Google Drive API
class Manager
class << self
attr_accessor :service
end
# Create and authenticate the Google Drive service object.
def initialize
self.class.service = Google::Apis::... |
ENV['RACK_ENV'] = 'test'
require_relative '../models/contribution'
require 'test/unit'
class ContributionTest < Test::Unit::TestCase
class << self
def startup
Mongoid.load!("config/mongoid.yml", :test)
end
def shutdown
Mongoid::Config.purge!
end
end
def setup
Contribution.creat... |
require_relative 'font'
require 'date'
require 'json'
require 'byebug'
class LushGreenGardens
WHITE = 0
LIGHT_GREEN = 1
GREEN = 2
DARK_GREEN = 3
FERTILIZER = true
attr_accessor :word, :current_letter, :latest_run, :current_day
def initialize(word="&REWEL")
@original_word = word
@word = word
... |
# frozen_string_literal: true
class User < ApplicationRecord
has_many :friendships
has_many :friends, through: :friendships
has_many :inverse_friendships, class_name: 'Friendship', foreign_key: 'friend_id'
has_many :inverse_friends, through: :inverse_friendships, source: :user
has_many :confirmed_friendships... |
# frozen_string_literal: true
module Rabbitek
##
# Base client hook class
class ClientHook
def call(payload, params)
yield(payload, params)
end
end
end
|
require 'spec_helper'
describe GQLi::Introspection do
let(:dsl) { GQLi::DSL }
let(:client) do
vcr('client') {
space_id = 'cfexampleapi'
token = 'b4c0n73n7fu1'
GQLi::Contentful.create(space_id, token)
}
end
subject { client.schema }
describe 'introspection schema' do
it 'querie... |
require 'support/helpers/assembly_helper'
require 'support/helpers/label_helper'
ControlFlowDetector = Struct.new(:output) do
include AssemblyHelper
include LabelHelper
def detect_jump(destination_label)
assembly_jump_code, assembly_label_code = jump_and_label_code
_, destination_label_code = jump_and_l... |
# == Schema Information
# Schema version: 20101130052456
#
# Table name: places
#
# id :integer not null, primary key
# name :string(255)
# group :string(255)
# created_at :datetime
# updated_at :datetime
# description :text
# website ... |
class ChangeColumnTypes < ActiveRecord::Migration
def change
change_column :restaurants, :latitude, :float
change_column :restaurants, :longitude, :float
change_column :menu_items, :price, :float
end
end
|
class CirclesUser < ActiveRecord::Base
belongs_to :circle
belongs_to :user
end
|
class AttendancesController < ApplicationController
before_action :set_attendance, only: [:show, :edit, :update, :destroy]
# GET /attendances
# GET /attendances.json
def index
@attendances = Attendance.all
end
# GET /attendances/1
# GET /attendances/1.json
def show
end
# GET /attendances/new
... |
require 'mongoid'
class Bunny
include Mongoid::Document
include Mongoid::Timestamps
field :article_title, type: String
field :bunny_video, type: String
end |
require 'rails_helper'
RSpec.feature 'Searches' do
context 'search by sheep id' do
scenario 'animal exists' do
visit root_path
animal = FactoryGirl.create(:animal)
within('.navbar') do
fill_in 'Search members', with: animal.registration_id
click_button :search
end
ex... |
class ChangeThreadIdToThdId < ActiveRecord::Migration
def change
rename_column :thread_tag_binds,:thread_id,:thd_id
end
end
|
require 'test_helper'
class Pullrequest::BaseTest < ActiveSupport::TestCase
def setup
@params = {
channel: '@slackbot',
actor: FactoryGirl.attributes_for(:user),
pullrequest: FactoryGirl.attributes_for(:pullrequest),
repository: FactoryGirl.attributes_for(:repository)
}
end
test ... |
# Author: Guy Boertje <https://github.com/guyboertje>
# Author: David R. Albrecht <https://github.com/eldavido>
# Author: Hiroshi Ichikawa <http://gimite.net/>
# The license of this source is "New BSD Licence"
# acl.rb, derived from https://github.com/guyboertje/gdata-spreadsheet-ruby/blob/master/lib/document.rb
# mor... |
class FontKolkerBrush < Formula
head "https://github.com/google/fonts/raw/main/ofl/kolkerbrush/KolkerBrush-Regular.ttf", verified: "github.com/google/fonts/"
desc "Kolker Brush"
desc "Never recommended to use all caps when editing copy"
homepage "https://fonts.google.com/specimen/Kolker+Brush"
def install
... |
# Control entire application
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
private
def logged_in?
!!request.headers['HTTP_AUTHORIZATION']
end
helper_metho... |
require 'httparty'
class Request
include HTTParty
include Helper
attr_accessor :url, :response_code
def initialize(url, url_args)
@url = bittrex_url(url, url_args)
end
def get!
response = self.class.get(url)
response_code = response.code
response_hash = response.parsed_response
if re... |
require 'spec_helper'
describe Movie do
describe "Find movies with the same director" do
it "should call the model method that finds movies whose director matches that of the current movie" do
movie = FactoryGirl.create(:movie)
movie.find_all_by_director
end
end
end
|
# == Informacion de la tabla
#
# Nombre de la tabla: *dbm_departamentos_de_bolivia*
#
# idDepartamento :integer(11) not null, primary key
# departamento :string(50) default(""), not null
#
# Departamentos de Bolivia sin su descripcion
#
class DepartamentoBolivia < ActiveRecord::Base
set_table_name('dbm_... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class Notifications::NotifyFollower < Notifications::AbstractNotification
def initialize(interrelationship)
@receiver = User.find(interrelationship.followed_id)
@transmitter = User.find(interrelationship.follower_id)
end
def notify
return if receiver == transmitter
EventsMailer.follower_mail(tran... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# activated :boolean default(FALSE)
# activated_at :datetime
# activation_digest :string
# admin :boolean default(FALSE)
# email :string not ... |
module Guidelines::Main
require 'open-uri'
require 'nokogiri'
require_relative '../../lib/guidelines/tag'
require_relative '../../lib/guidelines/attribute'
require_relative '../../lib/guidelines/sveden_data'
require_relative '../../lib/guidelines/abitur_data'
require_relative '../../lib/guidelines/checking_metho... |
class AuthenticationsController < ApplicationController
def create
omniauth = auth_hash
authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if authentication
sign_in(authentication.user)
redirect_to root_url, notice: "Signed in!"
else
sign_in... |
try_require_if_javascript "sprockets/es6" do
if ExecJS.runtime.is_a?(ExecJS::RubyRhinoRuntime)
Jekyll.logger.warn "ES6 transpiler has trouble with RubyRhino, use Node"
end
end
|
require File.join(File.dirname(__FILE__), "../../spec_helper")
module StreamSend
describe "Resource" do
describe "with missing method" do
before(:each) do
@resource = StreamSend::Resource.new({"name" => "scott"})
end
it "should return value" do
@resource.name.should == "scott"
... |
json.array!(@piles) do |pile|
json.extract! pile, :id, :card_pile_id, :card_id, :card_order
json.url pile_url(pile, format: :json)
end
|
# For example, given:
# A[0] = 3
# A[1] = 4
# A[2] = 4
# A[3] = 6
# A[4] = 1
# A[5] = 4
# A[6] = 4
# the function should return [3, 2, 2, 4, 2], as explained above.
# Write an efficient algorithm for the following assumptions:
# N and M are integers within the range [1..100,000];
# ea... |
require "spec_helper"
describe Square do
let(:test_square){Square.new("g", "7")}
let(:test_piece){Queen.new("white")}
describe "#set_contents" do
before do
test_square.set_contents(test_piece)
end
context "when a piece is set on this square" do
it "contains the piece that ... |
require File.dirname(__FILE__) + '/test_helper'
class TestEachWithContext < Test::Unit::TestCase
context "first?" do
setup do
@collection = [1,2,3,4]
end
should "return true on last element" do
@collection.each_with_context do |num,c|
assert c.first? if num == 1
end
end
... |
class Project < ActiveRecord::Base
def budget_remaining
budget = self.data["total_project_cost"].to_f
staff_cost = self.data["firm_cost"].to_f
budget - staff_cost
end
def percentage_budget_remaining
(self.budget_remaining / self.data["total_project_cost"].to_f * 100).round(2)
end
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :partner do
name { Faker::Company.name }
user
end
end
|
class Genre < ApplicationRecord
has_many :musics, class_name: 'Music', dependent: :destroy
end
|
# encoding: utf-8
require 'inky'
def reformat_html(html)
html
.gsub(/\s+/, ' ') # Compact all whitespace to a single space
.gsub(/> *</, ">\n<") # Use returns between tags
.gsub(%r{<(\w+)([^>]*)>\n</\1>}, '<\1\2/>') # Auto close empty tag... |
# frozen_string_literal: true
require 'rails_helper'
require 'support/error_details'
RSpec.describe 'personal_information', type: :request do
include SchemaMatchers
include ErrorDetails
let(:token) { 'fa0f28d6-224a-4015-a3b0-81e77de269f2' }
let(:auth_header) { { 'Authorization' => "Token token=#{token}" } }
... |
feature 'Posting meme' do
after do
remove_uploaded_file
end
scenario 'user can update a meme to add a memeified image' do
allow(Cloudinary::Uploader).to receive(:upload).and_return({"test_url" => 'test',"public_id" => 'test_id'})
allow(Cloudinary::Utils).to receive(:cloudinary_url).and_return('transform_i... |
class Category < ActiveHash::Base
self.data = [
{ id: 1, name: '認可保育園' },
{ id: 2, name: '認可外保育園(企業主導型)' },
{ id: 3, name: '認可外保育園' },
{ id: 4, name: '認定こども園' }
]
include ActiveHash::Associations
has_many :preschools
has_many :prices
end
|
class AddForceHtmlToProxyRule < ActiveRecord::Migration
def change
add_column :proxy_rules, :https, :boolean, null: false, default: false
end
end
|
class StudyScheduleReport < Report
VALIDATES_PRESENCE_OF = [:title].freeze
VALIDATES_NUMERICALITY_OF = [].freeze
VISIT_GROUP_OFFSET = 2
def generate(document)
@protocol = Protocol.find(@params[:documentable_id])
document.update_attributes(content_type: "application/vnd.openxmlformats-officedocument.... |
class CreateDomains < ActiveRecord::Migration
def change
create_table :domains do |t|
t.string :name
t.string :description
t.integer :parent_id
t.timestamps
end
#add_index :domains, :slug, unique: true
#Domain.create_translation_table! slug: :string
end
end
|
class CreateTables < ActiveRecord::Migration
def change
create_table :users do |u|
u.string :password_hash, :email
u.timestamps
end
create_table :surveys do |s|
s.string :title
s.references :user
s.timestamps
end
create_table :questions do |q|
q.string :text
... |
class AddIndexToMessagesSendAt < ActiveRecord::Migration[5.1]
def change
add_index :messages, :send_at
end
end
|
Rails.application.routes.draw do
resources :meetings
root 'jobs#index'
resources :jobs do
resources :followups
end
resources :admins
resources :applicants
resources :sessions
resources :about
resources :event
get 'logout', to: 'sessions#destroy', as: 'logout'
get 'login', to: 'sessions#new'... |
json.array!(@servicereqs) do |servicereq|
json.extract! servicereq, :id, :desc, :status, :reason
json.url servicereq_url(servicereq, format: :json)
end
|
#!/usr/bin/env ruby
require "rubygems"
require "open3"
require "colorize"
require "digest"
require "active_support/all"
require 'optparse'
options = {
:env => "ruby",
:syntax => "ruby",
:label => 'test/test_feed.rb'
}
OptionParser.new do |opts|
opts.banner = "Usage: #{__FILE__} [options]"
opts.on("-s", "-... |
# frozen_string_literal: true
module GraphQL
module StaticValidation
class FragmentSpreadsArePossibleError < StaticValidation::Error
attr_reader :type_name
attr_reader :fragment_name
attr_reader :parent_name
def initialize(message, path: nil, nodes: [], type:, fragment_name:, parent:)
... |
# == Schema Information
#
# Table name: muwashafats
#
# id :integer not null, primary key
# name :string
# description :text
# level :integer
# created_at :datetime not null
# updated_at :datetime not null
# category :integer
#
class Muwashafat < ApplicationRe... |
# frozen_string_literal: true
module NotificationsHelper
# Wraps a flash in a `Notification` object which handles mapping flash keys to
# the correct CSS class.
Notification = Struct.new(:key, :message) do
FLASH_TO_CSS_MAP = {
alert: 'is-warning',
error: 'is-danger',
notice: 'is-info',
... |
class CampaignsController < ApplicationController
before_action :set_campaign, except: [:index, :new, :create, :active_campaigns]
before_action :authenticate_user!
before_action :is_authorised, only: [:listing, :pricing, :description, :sample_content, :platform, :target_influencer, :guideline, :update]
def ind... |
class Pile
attr_reader :corner
attr_accessor :cards
# Initializes as an empty regular pile by default
def initialize(corner = false, cards = [])
@corner = corner
@cards = cards
end
def empty?
@cards.empty?
end
def top_card
@top_card = @cards.last
end
def bottom_card
@bottom_c... |
require 'spec_helper'
describe "foursquare_data/new" do
before(:each) do
assign(:foursquare_datum, stub_model(FoursquareDatum,
:client_id => 1,
:social_network_id => 1,
:new_followers => 1,
:total_followers => 1,
:total_unlocks => 1,
:total_visits => 1
).as_new_record)
e... |
Rails.application.routes.draw do
root to: "links#index"
resources :links, only: [:index, :edit, :update]
end
|
# frozen_string_literal: true
class ContactController < ApplicationController
def suggest
@form = SuggestACorrectionForm.new(suggest_params)
if @form.valid? && @form.submit
render partial: "catalog/correction_form", locals: { form: @form }
else
render partial: "catalog/correction_form", locals... |
json.replies!(@replies) do |reply|
json.extract! reply, :id, :user_id, :critique_id, :body
json.url reply_url(reply, format: :json)
end
|
class AddEndDateToMarketDishes < ActiveRecord::Migration[6.0]
def change
add_column :market_dishes, :end_date, :datetime, null: false
end
end
|
class User < ActiveRecord::Base
include BCrypt
has_many :purchases, class_name: :Item, foreign_key: :buyer_id
has_many :sales, class_name: :Item, foreign_key: :seller_id
has_many :bids, class_name: :Bid, foreign_key: :bidder_id
#has_many :bid_on_items, through: :bids, source: :item
has_one :account
valid... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.