text stringlengths 10 2.61M |
|---|
#!/usr/bin/env ruby
require 'rubygems'
require 'ruby-debug'
require 'prawn'
pdf = Prawn::Document.new(:page_size => 'A5', :page_layout => :landscape, :margin => [10, 10, 10, 10])
# Fuente
pdf.font_families.update("Georgia" => { :normal => "#{File.dirname(__FILE__)}/../fonts/Georgia.ttf" })
pdf.font "Georgia"
# Dim... |
module Renderers
# A middleware container for offsetting the view from a Camera2
class CameraContext < Moon::RenderContainer
# @return [Camera2]
attr_accessor :camera
def apply_position_modifier(*args)
pos = super(*args)
pos -= Moon::Vector3[@camera.view_offset, 0] if @camera
pos
... |
require 'nmea_plus'
RSpec.describe NMEAPlus::Decoder, "#parse" do
describe "testing the parser" do
before do
@parser = NMEAPlus::Decoder.new
end
context "when reading an NMEA message" do
it "conforms to basic NMEA features" do
input = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,54... |
class CreateDobraCutaneas < ActiveRecord::Migration
def self.up
create_table :dobra_cutaneas do |t|
t.references :antropometrica
t.float "coxa"
t.float "peito"
t.float "subescapular"
t.float "abdome"
t.float "triceps"
t.float "axilar"
t.float "suprailiaca"
t.t... |
class Mumble < ActiveRecord::Base
include Sluggable
belongs_to :user
belongs_to :mention
has_many :mumble_poundsigns
has_many :poundsigns, through: :mumble_poundsigns
validates :body, presence: true, length: {minimum: 2, maximum: 75}
sluggable_column :body
after_save :extract_mentions, :extract_poun... |
class Garden PLANT_KEY = {
'G' => :grass,
'C' => :clover,
'R' => :radishes,
'V' => :violets
}.freeze
STUDENTS = %w(Alice Bob Charlie David Eve Fred Ginny
Harriet Ileana Joseph Kincaid Larry).freeze
def initialize(input, students=STUDENTS)
@outer_row, @inner_row = input.s... |
class Mystic < ActiveRecord::Base
has_many :accesses
has_many :meditations, :through => :accesses
has_many :purchases
attr_accessor :skip_welcome_email
after_create :gain_access_to_free_meditations, :send_email_to_aweber, :deliver_gift_email
devise :database_authenticatable, :registerable, :recoverable, :... |
require 'icecast.rb'
class GetInfoWorker < BackgrounDRb::MetaWorker
set_worker_name :get_info_worker
def create(args = nil)
logger.debug "worker is created"
# If the streaming server is playing a continuous mix, mixCounter keeps track of where
# we are in the mix so the correct ar... |
# -*- encoding: utf-8 -*-
module SendGrid4r::REST
module Sm
#
# SendGrid Web API v3 Suppression Management - Groups
#
module Groups
include Request
Group = Struct.new(
:id, :name, :description, :last_email_sent_at, :is_default,
:unsubscribes
)
def self.url(gr... |
class AddVoicemailAccountIdToSipAccounts < ActiveRecord::Migration
def change
add_column :sip_accounts, :voicemail_account_id, :integer
end
end
|
require "rails_helper"
RSpec.describe VisitsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/tests").to route_to("tests#index")
end
it "routes to #new" do
expect(:get => "/tests/new").to route_to("tests#new")
end
it "routes to #show" do
... |
class MongrelClusterMonitor < Scout::Plugin
def run
unless app_name = @options["app_name"]
raise "app_name must be specified"
end
unless rails_root = @options["rails_root"]
raise "rails_root must be specified"
end
mongrel_rails_command = @options["mongrel_rails_command"] || "mongrel_ra... |
class CommentsController < ApplicationController
def create
@job = Job.find(params[:job_id])
@comment = @job.comments.build(comment_params)
if success = @comment.save
CompanyMailer.new_comment(@job, @comment).deliver
end
if success
flash[:notice] = "Comment was create succes... |
# frozen_string_literal: true
# Slide types were used to drive the original donor kiosk
class SlideType < ApplicationRecord
has_many :slides
validates :name, presence: true
end
|
class MenuItem < ActiveRecord::Base
belongs_to :menu
belongs_to :food_item
belongs_to :vote
validates :food_item_id, presence: true
validates :menu_id, presence: true
def num_votes
return self.vote
end
end
|
class ChangeDeliveryAndTakeoutInBusinesses < ActiveRecord::Migration[5.2]
def change
change_column :businesses, :delivery, :string, default: "No"
change_column :businesses, :takeout, :string, default: "No"
end
end
|
require 'yaml'
require './lib/AppLogger.rb'
class BoardManager
attr_accessor :path, :loaded, :structure
def initialize(path = '.')
AppLogger.info("Initializing using path: #{path}",'BoardManager','initialize')
@path = path if (path)
@loaded = false
@structure = {}
if File.exist?(@path... |
require 'logger'
module Reveal
module Cli
extend self
def process(args)
command_name = args.first.gsub('-', '_')
command_args = args[1..-1]
cmd = Reveal::Command.new(logger)
supported_cmds = cmd.methods - cmd.class.methods
unless supported_cmds.include?(command_name.to_sym)
... |
module APIV1
class Accounts < Grape::API
resource :account do
desc 'Returns all account objects, admin only!'
get do
accounts = Account.all
present accounts, with: APIV1::Entities::Account
end
desc 'Creates an account'
params do
requires :email, type: Strin... |
# 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{hash_syntax}
s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_ru... |
module Api
class PartiesController < ApplicationController
respond_to :json
def index
@parties = CommonCode.party_list
respond_with(@parties)
end
end
end
|
class AddAttachmentSecondaryBytImageToVariants < ActiveRecord::Migration
def self.up
change_table :spree_variants do |t|
t.attachment :secondary_byt_image
end
end
def self.down
remove_attachment :spree_products, :secondary_byt_image
end
end
|
class AddColumns < ActiveRecord::Migration[5.1]
def change
add_column :users, :image_url, :string
add_column :users, :contact_info, :text
end
end
|
class UserMailer < ApplicationMailer
default from: "reena_hrajani@yahoo.co.in"
def invite_guest(guest, event, current_user, url)
@guest = guest
@event = event
@current_user = current_user
@url = url
mail(to: @guest.email_id, subject: "You are Invited ")
end
end
|
class CartsController < ApplicationController
def show
@order_details = current_order.order_details
end
def clear
current_order.order_details.each(&:destroy)
redirect_to carts_show_path
end
end
|
class CreateEmails < ActiveRecord::Migration
def change
create_table :emails do |t|
t.string :filename
t.float :character_count, :default => 0.0
t.float :alpha_numeric_count, :default => 0.0
t.float :alpha_numeric_ratio, :default => 0.0
t.float :digit_count, :default => 0.0
t... |
class CreateBinaryExercises < ActiveRecord::Migration
def change
create_table :binary_exercises do |t|
t.references :user, index: true
t.references :cpu_binary, index: true
t.references :ram_binary, index: true
t.references :binary_cycle, index: true
t.timestamps
end
end
end
|
class Reservation < ActiveRecord::Base
belongs_to :space
belongs_to :order
validates_with DateValidator
validates :start_date, presence: true
validates :end_date, presence: true
def total_nights
(end_date - start_date) / 60 / 60 / 24
end
def total_price
total_nights * space.price
end
de... |
class AddVerifyCodeToDelivery < ActiveRecord::Migration
def change
add_column :deliveries, :verify_code, :string
add_column :deliveries, :send_result, :boolean
end
end
|
module AuthenticationHelper
def signed_in?
!session[:logged_in].nil?
end
def ensure_signed_in
unless signed_in?
session[:redirect_to] = request.request_uri
redirect_to(new_session_path)
end
end
end
|
class ChangeDetailsOfIndexHistories < ActiveRecord::Migration[5.1]
def change
change_table :index_histories do |t|
t.remove :products_type
t.remove :products_id
t.references :p, index: true
end
end
end
|
require 'eventmachine'
require 'vcap/common'
require 'vcap/component'
require 'nats/client'
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'abstract'
module VCAP
module Services
module Base
class Base
end
end
end
end
class VCAP::Services::Base::Base
def initialize(options)
@logger =... |
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user, :current_uuid
def connect
self.current_user = find_verified_user
self.current_uuid = cookies[:uuid]
end
protected
def find_verified_user
if (current_user = env["warden"].user)... |
json.array!(@offerlists) do |offerlist|
json.extract! offerlist, :buyer, :price, :date, :product_id
json.url offerlist_url(offerlist, format: :json)
end
|
# encoding: utf-8
module OgpContext
def get_facebook_token
authentications.where(provider: PROVIDER_FACEBOOK).first.oauth_token
end
end
|
class Semester < ApplicationRecord
has_many :courses
end
|
require 'rails_helper'
describe "find many customers with params" do
context "search using valid params" do
before :each do
@customer1, @customer2, @customer3 = create_list(:customer, 3)
end
it "can find an customer with id params" do
get '/api/v1/customers/find_all', params: {id: @customer1.... |
require 'echo'
RSpec.describe Echo do
let(:echo) {described_class.new}
context '#prompt' do
it 'asks you to say something' do
expect{echo.prompt}.to output('Say something: ').to_stdout
end
end
context '#answer' do
it 'user can respond' do
allow(STDIN).to receive(:gets).and_return('he... |
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Platron
class Helper < ActiveMerchant::Billing::Integrations::Helper
def initialize(order, account, options = {})
@secret_key = options.delete(:secret)
@path = options.delete(... |
# == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# project_name :string not null
# project_path :string not null
# resource_name :string not null
# resource_path :string not null
# description :st... |
class StoreOrder < ActiveRecord::Base
enum status: [:unprocessed, :processed, :failure, :success]
belongs_to :store
belongs_to :order
has_many :cart_items
has_many :stripe_webhook_events
validates :total, :total_shipping, :store_id, :subtotal, :tax_total, presence: true, unless: :unprocessed?
def pr... |
FactoryGirl.define do
factory :banner do
association :upload
image_url 'http://path/to/s3/banner.png'
factory :valid_banner, traits: [:pc] do
image File.open("#{Rails.root}/spec/images/banners/valid/200x200.png")
end
factory :invalid_banner, traits: [:pc] do
image File.open("#{Rails.... |
module ApplicationHelper
def format_price(event)
if event.free?
#"<strong>FREE</strong>".html_safe
content_tag(:strong, "Free")
else
number_to_currency(event.price, unit: "€ ")
end
end
def image_for(event)
if event.image_file.blank?
image_tag 'dummy.jpg', size: "100x100"
else
image_tag eve... |
require 'spec_helper'
describe TrainsController do
describe "GET index" do
it "assigns @trains" do
get :index # makes a request to bart.gov
expect(assigns(:trains)).to_not be_blank
expect(response).to render_template("index")
end
end
end
|
class ForgotPassword < ActionMailer::Base
def index_notification(recipient)
from "i@soulup.net"
recipients recipient.email_address_with_name
subject "Восстановление пароля"
part :content_type => "text/html", :body => render_message('index', :user => recipient)
end
end
|
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
before_action :configure_permitted_parameters, if: :devise_controller?
# below checking is moved to devise initiali... |
require './src/token'
require './src/tokenizer/built_ins'
require './src/interpreter/processor'
require './src/interpreter/errors'
require './spec/contexts/processor'
RSpec.describe Interpreter::Processor, 'error handling' do
include_context 'processor'
describe '#execute' do
it 'raises an error when calling... |
# encoding: UTF-8
# Parse a given file for its vocabulary
#
# ruby parse.rb [input book text to parse for new words] [known vocab list] [new words CSV]
require 'rmmseg'
require 'zidian'
require 'ruby-pinyin'
RMMSeg::Dictionary.load_dictionaries
def clean_text(text)
# get rid of chinese punctuation
text = text.gs... |
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# uniqname :string
# created_at :datetime not null
# updated_at :datetime not null
# email :string default(""), not null
... |
require 'rails_helper'
RSpec.describe Player, :type => :model do
describe '#height_in_feet' do
it 'returns height in feet and inches' do
@player = FactoryGirl.create(:player)
expect(@player.height_in_feet).to eq("6 feet 2 inches")
end
end
end
|
require 'open-uri'
require 'nokogiri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
doc = Nokogiri::HTML(open(index_url))
students = [ ]
doc.css("div.roster-cards-container").each do |card|
card.css(".student-card a").each do |profile|
profile_link = "#... |
class RenamePhoto < ActiveRecord::Migration
def change
rename_column :pins, :photo_url, :photo
end
end
|
require 'spec_helper'
RSpec.describe ROM::SQL::Attribute, :postgres do
include_context 'users and tasks'
let(:ds) { users.dataset }
describe '#is' do
it 'returns a boolean expression' do
expect(users[:id].is(1).sql_literal(ds)).to eql('("id" = 1)')
end
it 'returns a boolean expression for qu... |
class Expense < ActiveRecord::Base
belongs_to :project
belongs_to :period
validates :project_id, presence: true
validates :period_id , presence: true
validates :commission, numericality: true
validates :outsourcing, numericality: true
validates :tickets, numericality: true
... |
require 'rails_helper'
RSpec.describe "papers/index", type: :view do
before(:each) do
assign(:papers, [
Paper.create!(
:paper_height => 2.5,
:paper_width => 3.5,
:chain_lines => "Chain Lines",
:format => "Format",
:name => "Name",
:result => "MyText"
),... |
require "service/tftp/config-file"
#
# A configuration file generator for local booting with TFTP.
#
class Service::Tftp::ConfigLocalBoot < Service::Tftp::ConfigFile
def self.content
return <<-EOF
default local
label local
localboot 0
EOF
end
def initialize node, debug_options
@node = node
@debug... |
namespace :event do
desc 'Delete events by subj_id'
task :detete_by_sub_id, [:subj_id] => :environment do |task, args|
logger = Logger.new(STDOUT)
events= Event.where(subj_id: args[:subj_id])
total = events.size
events.find_each do |event|
event.destroy
end
logger.info "[Event Data] De... |
class Person
attr_accessor :name, :age
def initialize(name, age)
@name = name
@age = age.to_i
end
def nickname
# YOUR IMPLEMENTATION HERE
@name[0...4]
end
def birth_year
# YOUR IMPLEMENTATION HERE
return 2016 - @age
end
def introduction
# YOUR IMPLEMENTATION HERE
@nam... |
require "librato/metrics"
module Cubic
module Providers
class Librato
attr_reader :client, :namespace, :source, :queue_size, :_transaction_queue
class MissingConfigurationError < StandardError
def initialize(name)
super(":librato provider requires a #{name} config")
end
... |
require 'spec_helper'
module GotFixed
describe IssueFactory do
before(:each) do
@issue_factory = IssueFactory.new
end
describe "#from_github" do
it "should create an issue from an opened Github issue" do
open_issues = JSON.load(File.open "spec/factories/github/open.json")
is... |
class User < ActiveRecord::Base
has_many :microposts
has_secure_password
# pssword, password_confirmationカラムが仮想で生成
# authenticateメソッドも用意してくれる
validates :name,
presence: true,
length: {maximum: 50}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validate... |
class BicyclesController < ApplicationController
def new
@bicycle = Bicycle.new
authorize @bicycle
end
def create
@bicycle = Bicycle.new(bicycle_params)
authorize @bicycle
if @bicycle.save
flash[:notice] = "You added a new bicycle to your stock #{@bicyc... |
class SearchableService
include HTTParty
base_uri ENV['api_uri'] || 'api.spotify.com'
DEFAULT_ENDPOINT = ENV['artist_endpoint']
DEFAULT_LIMIT = ENV['api_limit']
# Public: Create constructor
#
# Parameters
#
# searches - A hash contains query and limit
#
# Example
#
# SearchableServi... |
require 'rails_helper'
describe User do
def setup
@user = User.new(name: "Example User", email: "user@example.com")
end
it { should validate_presence_of(:name) }
it { should validate_presence_of(:email) }
it { should validate_presence_of(:password) }
it { should ensure_length_of(:name).is_at_most(50) }
it {... |
class Painel::SalesController < Painel::BaseController
def index
@sales = Sale.all
end
def new
@sale = Sale.new
@sale.order_product.build
end
def create
@sale = Sale.new(sale_params)
@sale.employee_id = current_user.id
respond_to do |f|
if @sale.save
f.json { render js... |
require 'pry'
# P(n) = P(P(n - 1)) + P(n - P(n - 1))
# Eg 1
# Input : 13
# Output : 1 1 2 2 3 4 4 4 5 6 7 7 8
# Input : 20
# Output : 1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12
# Time complexity: ?
# Space Complexity: ?
def newman_conway(num)
if num <= 0
raise ArgumentError.new
end
sequence = []
num... |
FactoryBot.define do
factory :conversation do
author_id { create(:user).id }
recipient_id { create(:user).id }
after(:build) do |conversation, proxy|
if proxy.author_id.present?
conversation.author_id = proxy.author_id
end
if proxy.recipient_id.present?
conversation.rec... |
# Question 1
# ----------
# class MyCar
# attr_accessor :speed
# def initialize(y, c, m)
# @year = y
# @color = c
# @model = m
# @speed = 0
# end
# def speed_up(number)
# self.speed += number
# puts "You are now driving at #{speed} mph."
# end
# def slow_down(number)
# self... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :idea do
idea "MyString"
question_id 1
user_id 1
end
end
|
class RemoveStatusFromKeyitem < ActiveRecord::Migration
def change
remove_column :adventurers_items, :status, :integer
add_column :adventurers_items, :selected, :boolean, defalt: false
end
end
|
require 'spec_helper'
describe 'DocImage' do
before(:each) do
sign_in
@p = create(:person)
@p.identifications.create(foid_type: "Passport", foid: "DOC UPLOAD TEST 1")
@p.identifications.create(foid_type: "Passport", foid: "DOC UPLOAD TEST 2")
visit profile_path(@p)
click_on 'Documents'
end... |
class RemoveStates < ActiveRecord::Migration[5.1]
def change
remove_column :listings, :state, :string
end
end
|
require 'rails_helper'
RSpec.describe Bill, :type => :model do
let (:bill) { Bill.find_by(bill_id: 'hr2642-113') }
it "has an official title" do
expect(bill.official_title).not_to be_nil
end
it "has a short title" do
expect(bill.short_title).not_to be_nil
end
it "has a popular title" do
expe... |
require 'compiler_helper'
module Alf
class Compiler
describe Default, "ungroup" do
subject{
compiler.call(expr)
}
let(:expr){
ungroup(an_operand(leaf), :a)
}
it_should_behave_like "a traceable compiled"
it 'has a Ungroup cog' do
expect(subject).to be... |
require 'spec_helper'
describe "series_sets/index.html.erb" do
before(:each) do
assign(:series_sets, [Factory(:series_set), Factory(:series_set)])
end
it "renders a list of series_sets" do
render
rendered.should have_selector("tr>td")
end
end
|
class CreateInterestTrees < ActiveRecord::Migration
def self.up
create_table :interest_trees do |t|
t.column :root_node_id, :integer, :default => nil
t.column :name, :string, :limit => 255
t.column :cobrand_id, :integer
t.column :status, :enum, :limit => [:active, :suspended, :delete... |
class AddTypeToSchedule < ActiveRecord::Migration
def self.up
add_column :target_schedules, :type, :string, :default => 'Advanced'
end
def self.down
remove_column :target_schedules, :type
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe "Iiif Search", type: :request do
let(:user) { FactoryBot.create(:user) }
let(:yale_work) do
{
"id": "1234567",
"title_tesim": ["Fake Work"],
"child_oids_ssim": ["2222222"],
"visibility_ssi": "Yale Community Only"
}... |
module Spree
OrdersController.class_eval do
include ProductCustomizations
include AdHocUtils
before_action :set_option_params_values, only: [:populate]
private
def set_option_params_values
params[:options] ||= {}
params[:options][:ad_hoc_option_values] = ad_hoc_option_value_ids
... |
class Builders::SiteStats < SiteBuilder
def build
@total_words, @total_posts = 0
@average_words = []
generator do
# Doing some stat collection on post content
log.info "Site Stats:", "Generating word counts for posts"
site.collections.posts.resources.each do |post|
log.debug... |
class CustomUserMailer < Devise::Mailer
# Overides devise method to add custom subjects
# and bcc mail
#
def headers_for(action)
headers = {
:subject => find_custom_subject(action),
:from => mailer_sender(devise_mapping),
:to => resource.email,
:bcc =... |
class Tweet < ApplicationRecord
has_many :stars
validates :tweet, presence: true, length: {minimum: 1, maximum: 140}, allow_blank: false
validates :link, presence: true
validates :user_name, presence: true
def star_count
stars.count
end
end
|
class CreateImportTasks < ActiveRecord::Migration[5.1]
def change
create_table :import_tasks do |t|
t.string :importer_type, null: false
t.string :file
t.string :log
t.integer :status, default: ImportTask.statuses[:processing]
t.timestamps
end
end
end
|
class AddFeatureModel < ActiveRecord::Migration
def up
create_table :features do |f|
f.column :title, :string
f.column :content_date, :datetime
f.column :overview, :text
f.column :body, :text
f.column :type, :string
f.timestamps
end
end
def down
drop_table :feature... |
class TitlesController < ApplicationController
respond_to :html, :json
def index(page: 1, media: nil, initial: 'current')
page = page.to_i
@options = { page: page, media: media, initial: initial }.compact
unless request.format.html?
@titles = Title.page(page)
filter_by_initial(initial)
... |
namespace :unicorn do
task :kill_old, :roles => :app do
run 'pkill -TERM -f "master \(old\)"'
end
task :winch, :roles => :app do
run 'pkill -WINCH -f "unicorn_rails master"'
end
task :kill, :roles => :app do
run 'pkill -KILL -f "unicorn_rails"'
end
task :config, :roles => :app do
config... |
require "multi_json"
require "thread"
require "ecology/version"
module Ecology
class << self
attr_reader :application
attr_reader :data
attr_reader :environment
attr_accessor :mutex
end
ECOLOGY_EXTENSION = ".ecology"
Ecology.mutex = Mutex.new
class << self
# Normally this is only for t... |
class Csv2hash
class Definition
MAPPING = 'mapping'
COLLECTION = 'collection'
TYPES = [MAPPING, COLLECTION]
attr_accessor :rules, :type, :header_size
def initialize rules, type, header_size=0
self.rules, self.type, self.header_size = rules, type, header_size
end
def validate!
... |
class Admin::ProgramsController < ApplicationController
before_filter :require_organizer
layout 'admin'
def new
@program = Program.new
end
def create
p params
params[:program][:period_id] = params[:period_id]
@program = Program.new(program_params)
if @program.save
redirect_to admin_e... |
class Author < ActiveRecord::Base
has_many :blogs, dependent: :destroy
def self.create_authors
response = Net::HTTP.get_response("localhost:3000", "http://localhost:3000/all_users")
data = JSON.parse(response.body)
return data
end
end |
require "rails_helper"
RSpec.describe "Requests - Books" do
let(:headers) do
{
"ACCEPT" => "application/json"
}
end
describe "GET /books" do
let!(:books) { create_list(:book, 5, :random) }
it "returns a list of the books" do
get "/books", headers: headers
res_json = JSON.pars... |
# coding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
# More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage
config.cache.scope = :box
e... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
before_action :redirect_if_unverified
around_action :set_current_user
private
def redirect_if_unverified
return unless user_signed_in? && !current_user.verified_at?
redirec... |
class Order < ActiveRecord::Base
has_many :line_items, dependent: :destroy
validates :username, :address, :email, :address,:address2,
:telephone1,:telephone2,:shipcountry, presence: true
validates :accept, acceptance: { accept: true }
attr_accessible :username, :address,:email,
:address2,:telephone1,:telephone... |
class Ability
include CanCan::Ability
def initialize(user)
alias_action :destroy, to: :delete
@user = user
if @user
case @user.user_role_type.id
when ::UserRoleType.default.id then default
when ::UserRoleType.redactor.id then redactor
when ::UserRoleType.moderator.id the... |
require 'test_helper'
class EtapasPrestamoTest < ActionDispatch::IntegrationTest
def setup
@libro = libros(:three) # No tiene prestamos
@user = users(:michael)
end
test "Va recorriendo todas las etapas de un prestamo y chequea las views" do
log_in_as @user
get libro_path(@libro)
assert_temp... |
class UsersController < ApplicationController
before_action :authenticate_user!
def user_params
params.require(:user).permit(:name, :tag_list) ## Rails 4 strong params usage
end
end
|
# 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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
# Defines our Vagrant environment
#
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
N = 3
(1..N).each do |i|
config.vm.define "mongo#{i}" do |node|
node.vm.box = "centos/7"
node.vm.hostname = "mongo#{i}"
node.vm.network :private_network, ip: "11.0.0.1#{i}"
... |
module Walkable
def walk
"I'm walking."
end
end
module Swimmable
def swim
"I'm swimming!"
end
end
module Climbable
def climb
"I'm climbing."
end
end
class Animal
include Walkable
def speak
"I'm an animal, and I speak!"
end
def a_public_method
"Will this work? " + sel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.