text stringlengths 10 2.61M |
|---|
class Admin::UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /admin/users
def index
@users = User.all
end
# GET /admin/users/index
def show
end
# GET /admin/users/new
def new
@user= User.new
end
# GET /admin/users/index/edi... |
# frozen_string_literal: true
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'bolt'
require 'bolt/logger'
require 'logging'
require 'rspec/logging_helper'
# Make sure puppet is required for the 'reset puppet settings' context
require 'puppet_pal'
# HACK: must be loaded prior to spec libs t... |
class ShortenedUrl < ActiveRecord::Base
validates :long_url, :presence => true, :length => { maximum: 1024 }
validates :submitter, presence: true
validate user_over_submission
# validates :short_url, presence: true, uniqueness: true
belongs_to(
:submitter,
:class_name => 'User',
:foreign_key => ... |
require 'rails_helper'
RSpec.describe MessageBroadcastJob, active_job: true, type: :job do
describe '#perform' do
let!(:user) { create :user }
let!(:client) { create :client, user: user }
let(:rr) { ReportingRelationship.find_by(user: user, client: client) }
let!(:message) { create :text_message, rep... |
puts 'Cleaning database...'
Restaurant.destroy_all
puts 'Creating restaurants...'
restaurants_attributes = [
{
name: 'Dishoom',
address: '7 Boundary St, London E2 7JE',
phone_number: 0123,
category: 'belgian'
},
{
name: 'Pizza East',
address: '56A Shoreditch ... |
class NlpsController < ApplicationController
def analyse
@brand = Brand.find(params[:brand_id])
@text = @brand.reviews.map { |review| "#{review.title} #{review.content}" }.join(" ")
@analyse = WatsonService.new(@text).analyse
@review_tab = true
if @brand.nlps.length != 0
@brand.nlps.each d... |
require 'rails_helper'
RSpec.describe Libris, :type => :model do
before :each do
WebMock.disable_net_connect!
end
after :each do
WebMock.allow_net_connect!
end
describe "find_by_id" do
context "with an existing id" do
before :each do
stub_request(:get, "http://libris.kb.se/xsearch... |
class DistributorsController < ApplicationController
# GET /distributors
# GET /distributors.json
def index
@distributors = Distributor.all
end
# POST /distributors
# POST /distributors.json
def create
# distributor_params = {:name => "distributor2",:parent_id => 1}
@distributor = Distributo... |
require 'net/smtp'
module NotificationSystem
class Notification < ActiveRecord::Base
belongs_to :recipient, :class_name => 'User'
belongs_to :event, :class_name => 'NotificationSystem::Event'
validates_presence_of :recipient, :date
named_scope :pending, lambda { { :conditions => ['sent_... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/response'
require './lib/guess_checker'
class GuessCheckerTest < Minitest::Test
def test_it_exists
gc = GuessChecker.new("rgrg","bgbg")
assert true
end
def test_it_has_a_maximum_amount_of_guesses
gc = GuessChecker.new("r... |
class AddQuestionIdFromResponses < ActiveRecord::Migration[6.1]
def change
add_column :responses, :question_id, :integer, null: false
end
end
|
class ShoesController < ApplicationController
def index
@shoes = Shoe.all
render json: @shoes
end
def create
@shoe = Shoe.create(shoe_params)
end
def show
@shoe = Shoe.find(params[:id])
render json: @shoe
end
private
def shoe_params
params.require(:shoe).permit(:name, :descript... |
require 'spec_helper'
describe "has_many association:" do
before do
dynamic_models.task {
has_many :renamed_subtasks, :class_name => "Subtask", :foreign_key => "task_id"
has_moderated_association :renamed_subtasks
}.subtask {
belongs_to :task, :foreign_key => "task_id"
}
end
it "cr... |
class IctNetworkPoint < ActiveRecord::Base
validates :requisition_type_id,:justification,:location,:quantity, :presence => true
mount_uploader :ict_network_attachment, IctNetworkAttachmentUploader
end
|
# frozen_string_literal: true
require 'test_helper'
class HashExtensionsTest < ActiveSupport::TestCase
test 'flatten_by_keys example case' do
h = { foo: { bar: { baz: 1 }, bay: [2, 3, 4] } }
e = { 'foo.bar.baz': 1, 'foo.bay': [2, 3, 4] }
assert_equal e, h.flatten_by_keys
end
test 'flatten_by_keys w... |
class CreatePlans < ActiveRecord::Migration
def change
create_table :plans do |t|
t.string :level
t.decimal :price, :precision => 8, :scale => 2, :null => false
t.integer :number_of_releases_per_month, :null => false
t.string :storage_space, :null => false
t.integer :number_of_user_a... |
module Notifiers
class VideoCallbackNotifier
delegate :url_helpers, to: 'Rails.application.routes'
attr_reader :video
def initialize(video)
@video = video
end
def self.notify(video)
new(video).send_callback_notification
end
def send_callback_notification
return if vid... |
class AddAccountIdToStudents < ActiveRecord::Migration
def change
add_column :students, :account_id, :integer
end
end
|
module Merchant
module MerchantStatus
STATUS = [ENTERING=0, AUDITING=1, AUDITING_PASSED=2, ONLINE=3, OFFLINE=4, ONLINE_WAITING = 5]
end
end
|
# BrigadeProjectsController directs CRUD actions for all
# BrigadeProjects
class BrigadeProjectsController < ApplicationController
helper_method :edit_brigade_json
# GET /brigade_projects
# GET /brigade_projects.json
def index
@brigade_projects = BrigadeProject.all
general_static_response(@brigade_proje... |
Gem::Specification.new do |s|
s.name = 'cheap_random'
s.version = '0.9.4'
s.date = '2012-07-12'
s.summary = 'pseudo random number generation from arbitrary data'
s.description = <<-EOT
**CheapRandom** is a set of tools for pseudo random number generation from arbitrary data. The properties of the **CheapR... |
class Emailer < ActionMailer::Base
default from: "shipping@zingbars.com"
def prep_email()
@recipients = Invoice.where(:c_date => 1.week.ago..Date.today+1).where(:emailable => true, :to_email => true)
@recipients.each do |recipient|
@name = recipient.c_name
Emailer.sample_email(recipient).d... |
class LessonsController < ApplicationController
before_action :set_lesson, only: [:edit, :update]
def index
end
def new
@lesson = Lesson.new
@lesson.users << current_user
end
def create
@lesson = Lesson.new(lesson_params)
if @lesson.save
redirect_to root_path, notice: "レッスンを作成しました... |
#==============================================================================
# ** Game_General
#------------------------------------------------------------------------------
# Autor: Valentine
#==============================================================================
module Game_General
def full_clients?
... |
FactoryBot.define do
factory :user_purchase do
token {"1111"}
post_code {"123-4567"}
ship_to_region_id {1}
city {"aaa"}
block {"sss"}
building {"xxx"}
phone_number {"09012345678"}
end
end |
# U2.W5: Die Class 1: Numeric
# I worked on this challenge by myself.
# 2. Pseudocode
# Input: numbers of sides for the die
# Output: returns the number of sides for the die and a random number within the range of sides
# Steps:
# 2.1 Create Class Die that initializes with the sides parameter given
# 2.2 Define si... |
require 'rubygems/package_task'
require 'rake/testtask'
load File.dirname(__FILE__) + '/test/integration/tasks.rake'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
end
task :default => :test
spec = Gem::Specification.load(Dir['*.gemspec'].first)
gem = Gem::PackageTask.new(sp... |
class OrganizationsController < ApplicationController
before_action :authenticate_user!
#load @organization/s and authorize user for all actions
load_and_authorize_resource
before_action :can_create_organization?, only: :new
def index
# load
#@organizations=Organization.where.not(owner_id: 0)
end... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{vigetlabs-routing-filter}
s.version = "0.2.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to?... |
class Admin::OrdersController < AdminController
actions :index, :show
private
def collection
@orders ||= end_of_association_chain.paginate :page => params[:page], :per_page => params[:per_page] || Order.per_page
end
end
|
require 'securerandom'
module Sdp
# Takes the filename, destination address, and may be interface
# then fragments the input filename into pieces with size MTU.
# For each fragment a separate advertisement message has been sent with
# sequence number.
module Publisher
def self.pub_file(filename,destinat... |
class Admin::PostsController < Admin::BaseController
def destroy
resource.is_deleted = !resource.is_deleted
resource.save!
head :ok
end
private
def resource
@post ||= Post.find(params&.symbolize_keys[:id])
end
def collection
@collection ||= Post.page(params[:page]).per(5)
end
end
|
class HomeController < ApplicationController
def index
@count = {}
Event.distinct(:type).each do |type|
subtype = type.clone
subtype["Event"] = ""
@count[subtype] = Event.where(type: type).count()
end
@total = Event.count()
end
def refresh
UpdateArchivesJob.perform... |
namespace :deploy do
desc "sbt package on dev"
task :sbt_package_dev do
on roles(:dev), in: :sequence, wait: 5 do
within release_path do
execute '/usr/bin/sbt', 'package'
end
end
end
after :published, :sbt_package_dev
desc "Copy api war to Jetty webapps, on dev"
task :copy_war_dev ... |
require 'active_support/core_ext'
module CloudConductorCli
module Helpers
describe Record do
let(:record) { Object.new.extend(Record) }
let(:model) { :project }
let(:mock_project) { { id: 1, name: 'project_name', description: 'project_description' } }
before do
allow(Connection).... |
Rails.application.routes.draw do
post :sign_in, to: 'authentication#sign_in'
post :sign_up, to: 'authentication#sign_up'
post '/:provider', to: 'authentication#authenticate', constraints: { provider: /facebook|google/ }
get 'reset/:email', to: 'password#reset', constraints: { :email => /.*/ }
post :reset, to... |
require 'rails_helper'
RSpec.describe Api::V1::GroupEventsController, type: :routing do
describe 'routing' do
it 'routes to #index' do
expect(get: '/v1/group_events').to route_to('api/v1/group_events#index')
end
it 'routes to #show' do
expect(get: '/v1/group_events/1').to route_to('api/v1/gr... |
class AddDeskIdToCards < ActiveRecord::Migration[5.0]
def change
add_column :cards, :desk_id, :integer, :null => false
end
end
|
module MedicalEntities
class DonationsController < ApplicationController
before_action :set_donation, only: %i[show edit update destroy]
# GET /medical_entities/donations
# GET /medical_entities/donations.json
def index
@donations = Donation.all
end
# GET /medical_entities/donations/1
... |
require "minitest_helper"
require "chandler/configuration"
require "chandler/github"
class Chandler::GitHubTest < Minitest::Test
def setup
@config = Chandler::Configuration.new
@client = Chandler::GitHub::Client.new
@client.stubs(:login).returns("username")
Chandler::GitHub::Client
.stubs(:new... |
require 'csv'
module RideShare
class Driver
attr_reader :id_d, :name_d, :vin
def initialize(id_d, name_d, vin)
raise ArgumentError.new("no valid ID") if id_d.class != Integer
raise ArgumentError.new("no valid ID") if id_d < 0
raise ArgumentError.new("name must be a string") if name_d.clas... |
#!/usr/bin/ruby
# Dropzone Destination Info
# Name: Create DMG file
# Description: Creates a DMG file from the dropped files, holding down the option key creates an encrypted DMG.
# Handles: NSFilenamesPboardType
# Events: Clicked, Dragged
# KeyModifiers: Option
# Creator: Megan Cooke
# URL: http://www.insanekitty.co.... |
class CreateDogs < ActiveRecord::Migration[6.0]
def change
create_table :dogs do |t|
t.string :title, null: false
t.integer :dog_gender, null: false
t.integer :dog_age_id, null: false
t.integer :vaccine, null: false
t.integer :surgery, null: false
t.integer :prefecture_id, null... |
namespace :projects do
desc 'Close expired projects'
task expire: :environment do
Project.expire_old
end
end
|
require 'rails_helper'
RSpec.describe "stories/new", type: :view do
before(:each) do
assign(:story, Story.new(
:user => nil,
:working_article => nil,
:reporter => "MyString",
:group => "MyString",
:title => "MyString",
:subtitle => "MyString",
:body => "MyString",
... |
class CreateArtists < ActiveRecord::Migration
def change
create_table :artists do |t|
t.string :name
t.string :name2
t.string :name3
t.string :name4
t.string :name5
t.integer :role_id
t.integer :instrument_id
t.string :image_url
t.timestamps null: false
e... |
class CreateAddresses < ActiveRecord::Migration
def change
create_table :addresses do |t|
t.integer :addresstable_id, :null => false
t.string :addresstable_type, :null => false, :limit => 30
t.string :zipcode
t.string :address
t.string :district
t.string :number
t.strin... |
require 'rails_helper'
describe Planet do
it { should have_many :vacations }
it { should have_many :landmarks }
it { should have_valid(:name).when("Tatooine", "Jakku") }
it { should_not have_valid(:name).when(nil, "") }
it { should have_valid(:language).when("Basic", "Kaminoan") }
it { should_not have_va... |
class ContactFormMailer < ActionMailer::Base
default from: "info@tlth.se"
def contact_email(user, sender_email, questions, answers, title)
@user = user
@sender_email = sender_email
@questions = questions
@answers = answers
@title = title
mail(to: user.email, subject: "[TLTH] ... |
class MajorsController < ApplicationController
def index
@majors = Major.pluck :name
respond_to do |format|
format.json { render json: @majors }
end
end
end
|
require 'test/unit'
module TestHelper
def assert_accept fa, *values
values.each do |value|
assert fa.accept?(value), "'#{value}' not accepted!"
assert(!fa.reject?(value), "'#{value}' rejected!")
end
end
def assert_reject fa, *values
values.each do |value|
assert fa.reject?(value),... |
class Article < CouchRest::Model::Base
use_database COUCH_DB
property :title, String
property :content, String
property :published_at, Time
property :authors, [String]
property :category # tech, business, politics, sports, etc.
property :ratings, Integer # 1-5, 5 is the highest
proper... |
# OpenNebula::XMLElement class
class OpenNebula::XMLElement
# Calls info! method and returns a hash representing the object
def to_hash!
self.info! || self.to_hash
end
def to_json opts = {}
to_hash!.to_json opts
end
end
|
require "./lib/Lesson 4 Counting Elements/MaxCounters/max_counter"
describe 'MaxCounters' do
describe 'Example Tests' do
it 'Example test: (5, [3,4,4,6,1,4,4]) to [3,2,2,4,2]' do
expect(max_counter(5, [3,4,4,6,1,4,4])).to eq [3,2,2,4,2]
end
end
describe 'Correctness Tests' do
context "extreme_... |
# 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... |
# frozen_string_literal: true
# Advent of Code 2020
#
# Robert Haines
#
# Public Domain
require 'test_helper'
require 'aoc2020/handheld_halting'
class AOC2020::HandheldHaltingTest < MiniTest::Test
PROGRAM = <<~EOPROG
nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +... |
class CreatePunches < ActiveRecord::Migration
def change
create_table :punches do |t|
t.string :alias
t.string :mac, null: false
t.string :local_ip, null: false
t.string :public_ip, null: false
t.float :latitude
t.float :longitude
t.timestamps
end
end
end
|
require 'rails_helper'
describe CommitStatus do
describe '#set_pending' do
it 'sets the pending status on GitlabApi' do
github_api = stubbed_github_api(:create_pending_status)
repo_name = 'thoughtbot/hound'
sha = 'abc123'
token = 'token'
commit_status = CommitStatus.new(
rep... |
# frozen_string_literal: true
class Knight
@@movement = [2, 1, -1, -2]
def self.moves
@@movement.permutation(2).filter { |pair| pair[0].abs != pair[1].abs }
end
end
|
# frozen_string_literal: true
require 'rails_helper'
feature 'Editor edits a case' do
let(:this_case) { FactoryBot.create(:case) }
let(:user) { FactoryBot.create(:user) }
scenario 'Editor arrives at the case edit page and sees the subjects name' do
login_as(user, scope: :user)
visit "/cases/#{this_case.... |
require_relative 'Bike'
class DockingStation
attr_reader :name, :capacity, :bikes
def initialize(name, capacity)
@name = name
@bikes = []
@capacity = capacity
end
def self.create(name, capacity)
@dock = DockingStation.new(name, capacity)
end
def self.instance
@dock
end
def dock... |
require 'rails_helper'
RSpec.shared_examples 'a removable model' do |models_to_be_removed|
let!(:other_user) { create(:heavy_user) }
models_to_be_removed.each do |model|
it "destroys #{model.name}" do
count = subject.try(model.name.underscore.pluralize).count
expect {
subject.destroy
... |
# -*- encoding : utf-8 -*-
FactoryGirl.define do
factory :person do |f|
church
f.first_name 'John'
f.last_name 'Doe'
end
end
|
=begin
** EST - DYNAMIC SHOP v1.3
author : estriole
requested by Adon from rpgmakerweb.com
extra credits:
Nate McCloud for pointing bugs in v 1.2
licences:
Free to use in all project (except the one containing pornography)
as long as i credited (ESTRIOLE).
version history
v 1.0 - 2013.01.04 => fini... |
class CreateJsonCache < ActiveRecord::Migration
def change
create_table :json_caches , :id => false do |t|
t.uuid :id, :primary_key => true, default: "uuid_generate_v4()"
t.json :content
t.datetime :expire
#author
end
end
end
|
class RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
# remove provious social login errors
# before doing save validation
session.delete(:errors)
session.delete(:errors_full_messages)
hash = session[:omniauth]
if hash
@user = User.ne... |
FactoryBot.define do
# We can set the aliases (nicknames) to a factory like this:
factory :customer, aliases: [:user, :father] do
# Transient attributes, or transitory or temporary, attribute invisible to attributes_for.
transient do
upcased false
qtd_orders 3
end
name { Faker::Name.name }
email... |
require "rails_helper"
RSpec.describe MockTestsController, :type => :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/mock_tests").to route_to("mock_tests#index")
end
it "routes to #new" do
expect(:get => "/mock_tests/new").to route_to("mock_tests#new")
end
... |
# Generated by juwelier
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: subdomain_router 1.0.1 ruby lib
Gem::Specification.new do |s|
s.name = "subdomain_router".freeze
s.version = "1.0.1"
s.required_rubygems_version = Gem::R... |
# encoding:utf-8
require 'active_support/core_ext/object/deep_dup'
class ElasticsearchRasi
module Request
CONTENT_TYPE = { content_type: 'application/json' }
def request(method, params)
send_request(method, params)
end
def clear_request(method, params)
response = send_request(method, pa... |
# encoding: utf-8
class AtendimentosController < ApplicationController
# GET /atendimentos
# GET /atendimentos.json
def index
@atendimentos = @atendimentos = Atendimento.where(["status != ?", "Finalizado"])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @at... |
require 'rails_helper'
RSpec.describe BatchesController, :type => :controller do
before :each do
@file = fixture_file_upload('spec/support/fixtures/one_sale.txt', 'text/tab-separated-values')
@empty_file = fixture_file_upload('spec/support/fixtures/empty.txt', 'text/tab-separated-values')
end
describe "P... |
class RenamePriceToMemberPrice < ActiveRecord::Migration
def up
rename_table :prices, :member_prices
end
def down
rename_table :member_prices, :prices
end
end
|
class CreateXrays < ActiveRecord::Migration
def self.up
create_table :xrays do |t|
t.integer :diagnosis_id
t.integer :operation_id
t.datetime :date_time
t.string :taken_at
t.string :photo_file_name # Original filename
t.string :photo_content_type # Mime type
t.integer :ph... |
require_relative '../../spec_helper'
describe MangoPayV1::Contribution, :type => :feature do
let(:new_user) {
MangoPayV1::User.create({
'Tag' => 'test',
'Email' => 'my@email.com',
'FirstName' => 'John',
'LastName' => 'Doe',
'CanRegisterMeanOfPaym... |
class ApplicationController < ActionController::Base
include Pundit
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
rescue_from Timeout::Error, with: :time_out
private
def record_not_found(error)
render json: { error... |
class Shop < ActiveRecord::Base
has_many :shop_types
has_many :locations
has_many :types, through: :shop_types
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
VALID_PHONE_REGEX = /\A(\(?(\d{3})\)?[-. ]\d{3}[-.]\d{4})\z/
validates :name, presence: true, length: {minimum: 1, maximum: 65 }
vali... |
class IngredientsController < ApplicationController
load_and_authorize_resource
def index
@featured_ingredient = find_featured_ingredient(params[:path])
@ingredients = Ingredient.visible.order("name ASC")
end
def show
@ingredient.increment_view_count!
render layout: false
end
def search
... |
require 'net/http'
require 'json'
namespace :food_cart do
desc "Loads food carts from the source"
task :load => :environment do
url = ENV["SOURCE_URL"]
uri = URI(url)
response = Net::HTTP.get(uri)
JSON.parse(response).each do |cart_json|
FoodCart.load_from_json(cart_json)
end
end
e... |
class Organization
attr_reader :url, :avatar_url
def initialize(attrs = {})
@url = attrs[:url]
@avatar_url = attrs[:avatar_url]
end
def self.organizations(current_user)
GithubService.new(current_user).get_organizations.map do |repo|
Organization.new(repo)
end
end
end
|
require 'docking_station'
describe DockingStation do
it_behaves_like "a bike container"
let(:station) { DockingStation.new(:capacity => 100) }
let(:bike) { double :bike, is_a?: :Bike}
let(:broken_bike) { double :bike, broken?: :true }
let(:van) { double :van }
it "should allow setting the defau... |
# -*- encoding : utf-8 -*-
Stoffi::Application.routes.draw do
scope '(:l)', l: /us|uk|se|cn|de/ do
namespace :admin do
resources :translatees
resources :translatee_params
resources :configs
end
as :user do
get 'login', to: 'users/sessions#new', as: :new_user_session
post... |
# encoding: UTF-8
module API
module V1
class Comments < API::V1::Base
before do
authenticate_user
end
namespace :comments do
Comment.resource_types.each do |key, resource_type|
namespace key do
route_param :id do
paginated_endpoint do
... |
class MetrcCreateAdditives
include Sidekiq::Worker
sidekiq_options queue: 'low'
def perform(task_id)
#build params here
task = Cultivation::Task.find(task_id)
batch = task.batch
metrc_batches = Metrc::PlantBatch.where(batch_id: batch.id).to_a
nutrient_profile = batch.nutrient_profiles.where(t... |
require "virtus"
module TwitterBro
class BearerToken
include Virtus.value_object
values do
attribute :value, String
end
def to_s
value
end
end
end
|
$:.push File.expand_path("../lib", __FILE__)
require "conduit/sureaddress/version"
Gem::Specification.new do |s|
s.name = "conduit-sureaddress"
s.version = Conduit::SureAddress::VERSION
s.authors = ["Andy Vanasse"]
s.email = ["andy.vanasse@hellolabs.com"]
s.homepage = "https://github.com/conduit/co... |
class User < ApplicationRecord
has_many :chimps, class_name: "Chirp"
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Likes', type: :system do
let!(:me) { create(:user) }
let!(:others) { create(:user) }
let!(:avatar) { create(:avatar, user: others, public: true) }
describe 'sign in user' do
describe 'create like', js: true do
before do
sig... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def authenticate_drinker!
session[:drinker_return_to] = env['PATH_INFO']
redirect_to drinker_facebook_omniauth_authorize_path unless drinker_signed_in?
end
end
|
class DataHash
attr_accessor :data_hash
def initialize
@data_hash = Hash.new(false)
end
def get(*keys)
output = []
keys.each do |key|
if @data_hash.key?(key)
output << @data_hash.fetch(key)
else output << nil
end
end
return output
end
def set(key, data_en... |
class Patron < ApplicationRecord
belongs_to :brewery, dependent: :destroy
end
|
resource_name :vault_certificate
provides :vault_certificate
require 'vault'
require 'openssl'
default_action :create
# ======================================================================================================================
# == General properties ======================================================... |
module NetAppSdk
class Volume < Filer
def self.create(aggr, volname, size)
vol_create = @@filer.invoke("volume-create",
"containing-aggr-name", aggr,
"volume", volname,
"size", size)
raise vol_create... |
class AddRefToBookings < ActiveRecord::Migration
def change
change_table :bookings do |t|
t.references :flight, :passenger
end
end
end
|
# frozen_string_literal: true
require './models/application_record'
class LineItem < ApplicationRecord
belongs_to :recipe, required: true
belongs_to :ingredient, optional: true
validates :raw_text,
presence: true
end
|
class AddBillNoInReceivables < ActiveRecord::Migration[5.0]
def change
add_column :receivables, :bill_no , :int
end
end
|
class Request
def initialize(message, *params)
@message = message
@params = params
end
attr_reader :message, :params
end
class Response
def initialize(result = nil)
@result = result
end
attr_reader :result
end
require 'socket'
require 'webrick'
class LocalServer
def initialize... |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def render_facebox
if @facebox_rendered.nil?
@facebox_rendered = true
render :partial => "shared/facebox"
else
end
end
def ... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "boxcutter/ubuntu1604-desktop"
#config.vm.box = "ubuntu/xenial64"
#config.vm.network :forwarded_port, guest: 5000, host: 5000
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "Ubuntu.16.04.Vagran... |
class Admin::TipoInstitucionsController < ApplicationController
layout 'admin'
require_role "administrador"
# GET /tipo_institucions
# GET /tipo_institucions.xml
def index
@tipo_institucions = TipoInstitucion.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { ren... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.