text stringlengths 10 2.61M |
|---|
class RenameColInCards < ActiveRecord::Migration[5.2]
def change
rename_column :cards, :player, :player_id
end
end
|
class Admin::UsersController < ApplicationController
before_action :is_admin
def index
@users = User.all().paginate(:page => params[:page], :per_page => 15 )
end
def destroy
User.find(params[:id]).destroy()
redirect_to action: 'index'
end
end
|
class Park
attr_reader :name,
:trails
def initialize(name)
@name = name
@trails = []
end
def add_trail(trail)
@trails << trail
end
def trails_shorter_than(milage)
@trails.find_all do |trail|
trail.length < 2.5
end
end
def hikeable_miles
@trails.sum do |tra... |
#encoding: utf-8
class Charge < ActiveRecord::Base
has_and_belongs_to_many :students
attr_accessible :amount, :ctype, :datedue, :name, :student_ids
validates :amount, :numericality => { :greater_than_or_equal_to => 0 }
validates_inclusion_of :ctype, in: %w( Inscripcion Colegiatura Exposicion Material Otro ),... |
require 'test_helper'
class BadgeImageTest < ActiveSupport::TestCase
self.use_instantiated_fixtures = true
fixtures :badge_images
def setup
@c = Client.find(:first)
end
def test_public_image
bi = BadgeImage.new(
:image_file_name => 'silver_star.png',
:image_content_type => 'image/png'... |
module Percolation
class UnionFind
attr_accessor :data
def initialize(size)
@data = Array.new(size) { |i| i }
end
def connected?(i, j)
root(i) == root(j)
end
def union(i, j)
data[root(i)] = root(j)
end
private
def root(i)
until data[i] == i do
i... |
# puts "What is your name?"
# name = gets.chomp
# puts "Hello, #{name}, nice to meet you!"
puts "What is the input string?"
word = gets.chomp
n = word.length
puts "#{word} has #{n} characters." |
class Models::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model (e.g. app/models/model.rb)
found_model = Model.find_for_facebook_oauth(request.env["omniauth.auth"])
Rails.logger.info "------------"
Rails.logger.info fo... |
class Phone < ActiveRecord::Base
belongs_to :phone_type
belongs_to :phoneable, polymorphic: true
before_validation :set_phone
validates :phoneable, associated: true
attr_accessor :_destroy # TODO: Remove when Reform releases _destroy
def number_with_ext
if ext.present?
"#{number} Ext: #{ext}"
... |
require 'docking_station_class'
describe DockingStation do
it { is_expected.to respond_to :release_bike }
it { is_expected.to respond_to(:dock_bike).with(1).argument }
it { is_expected.to respond_to :bike }
#testing dock_bike method
it "docks something" do
bike = Bike.new
expect... |
class Santa
attr_reader :age, :ethnicity
attr_accessor :gender, :age
def speak
puts "Ho, ho ho! Haaaappy Holidays!"
end
def eat_milk_and_cookies(cookie)
puts "That was a good #{cookie}!"
end
def initialize(name, gender, ethnicity, weight)
puts "initializing Santa instance ..."
@name = na... |
module Clarity
class MetricReport
attr :name
attr_reader :rows
attr_reader :keynames
def initialize(name, params={})
@name = name
timeframe = params[:timeframe]
raise "timeframe required" if timeframe.blank?
keynames = params[:metrics]
raise "metrics required" if keynames.blank?
... |
# frozen_string_literal: true
require 'test_helper'
class EmailPresenterTest < ActiveSupport::TestCase
test 'types returns an array' do
email = StubEmail.new
types = EmailPresenter.new(email, nil).types
assert_equal Array, types.class
end
test "addressee returns 'Unknown' if email does not have a p... |
require 'game'
describe Game do
subject(:game) { described_class.new }
describe '#score' do
context 'Gutter game' do
it 'returns a score of 0' do
20.times { game.roll(0) }
expect(game.score).to eq(0)
end
end
context 'perfect game' do
it 'returns a score of 300' do... |
require "spec_helper"
require "massive_sitemap/writer/base"
describe MassiveSitemap::Writer::Base do
let(:writer) { MassiveSitemap::Writer::Base.new }
describe "set" do
it "returns itself" do
writer.set(:filename => "test").should == writer
end
end
end
|
class FillPanTask < Task
def initialize
super('Fill the pan with cake batter.')
end
def time_required
2.5 # 3 minutes
end
end
|
module ApplicationHelper
def body_classes(classes=nil)
ary = [Rails.application.class.to_s.split("::").first.downcase]
ary << controller.controller_name
ary << controller.action_name
ary << 'mobile' if mobile_agent?
unless classes.nil?
method = classes.is_a?(Array) ? :concat : :<<
ar... |
Then(/^I see "(.*?)" was add$/) do |arg1|
page.should have_content arg1
end
Then(/^I click "(.*?)" button$/) do |arg1|
click_button arg1
end
Given(/^I visit "(.*?)"$/) do |arg1|
visit arg1
end
|
class AddPositionToCurrencies < ActiveRecord::Migration
def change
add_column :currencies, :position, :integer, index: true
end
end
|
class ReviewsController < ApplicationController
before_action :set_review, only: [:show, :edit, :update, :destroy]
before_action :set_program
before_action :authenticate_visitor!
def new
@review = Review.new
end
def edit
end
def create
@review = Review.new(review_params)
@review.program_id = @program.i... |
Rails.application.routes.draw do
get 'home' => "main_page#show"
get 'login' => "students#new"
post 'login' => "students#new_session"
post 'logout' => "students#destroy"
post 'validate' => "lessons#validate"
post 'edit_step_page' => "lessons#update_steps"
post 'request_step_action' => "lessons#show_step_... |
# frozen_string_literal: true
FactoryGirl.define do
factory :event do
name 'Rails event'
place 'tokyo'
start_time Time.zone.now + 1.hour
end_time Time.zone.now + 3.hours
content 'Railsの勉強会です'
factory :update_event do
place 'kyoto'
end
factory :start_time_is_not_before_end_time... |
require "rails_helper"
RSpec.describe BroadcastCountsJob, type: :job do
describe "#perform" do
it "triggers a graphql subscription" do
schema = stub_const("MessagingSchema", spy)
user = create(:user)
described_class.new.perform(user.id)
expect(schema).to have_received(:trigger)
end
... |
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-pl... |
FactoryBot.define do
factory :treatment_group_membership, class: Experimentation::TreatmentGroupMembership do
association :patient, factory: :patient
association :treatment_group, factory: :treatment_group
experiment { treatment_group.experiment }
experiment_name { experiment.name }
treatment_gro... |
require "application_system_test_case"
class PostsTest < ApplicationSystemTestCase
setup do
@post = posts(:one)
end
test "visiting the index" do
visit posts_url
assert_selector "h1", text: "Posts"
end
test "creating a Post" do
visit posts_url
click_on "New Post"
fill_in "Content", ... |
node['certie']['domains'].each do |domain, domains|
selfsigned_path = "#{node['certie']['path']}/#{domain}/selfsigned/"
directory selfsigned_path do
recursive true
action :create
not_if { ::File.directory?(selfsigned_path) }
end
template 'openssl-config' do
source 'openssl.cnf.erb'
path "#... |
require 'erb'
require 'haml'
require 'tilt'
module IdobataGateway
class Template < Struct.new(:options)
class MissingTemplate < StandardError
def initialize(path)
super "Missing template - #{path}"
end
end
def initialize(options = {})
options = {
format: :html5,
... |
require 'spec_helper'
describe 'brew package for redis' do
describe command('/usr/local/bin/brew info redis --json=v1') do
# the JSON output is awkward to parse here, but it's
# cross-platform-version, since the formula may be installed as a
# source or from bottle depending on the version of OS X.
i... |
# frozen_string_literal: true
module Types
UserType = GraphQL::ObjectType.define do
name 'User'
description 'An account linked to a Discord user'
interfaces [Interfaces::ModelInterface]
## Attributes stored in the DB
field :email, types.String
field :discordName, !types.String, property: :d... |
class Statistic < ActiveRecord::Base
belongs_to :question
validates :correct, :presence => true
end
|
source "https://rubygems.org"
def override_with_local(opts)
local_dir = opts.delete(:path)
unless local_dir.start_with? '/'
local_dir = File.absolute_path(File.join(File.dirname(__FILE__), local_dir))
end
#puts "Checking for '#{local_dir}' - #{Dir.exist?(local_dir)}"
Dir.exist?(local_dir) ? {path: local_... |
module Harvest
module EventHandlers
module ReadModels
class FishingGroundBusinesses
include Celluloid
def initialize(database)
@database = database
end
def handle_new_fishing_business_opened(event)
@database.save(
uuid: event... |
# frozen_string_literal: true
module App
# AppController -> Controller out the back-office
class AppController < ::ApplicationController
layout 'app/layouts/application'
skip_before_action :verify_authenticity_token
before_action :set_metas
before_action :set_analytics
def set_metas
@the... |
class Api::V1::ShippingCategoriesController < Api::V1::BaseController
skip_before_action :authenticate_user!, only: [:show]
def show
country = params["country"]
weight = params["weight"]
@shipping_category = ShippingCategory.where(alpha2: country).where("weight >= ?", weight).min
end
end
|
# frozen_string_literal: true
# rubocop:todo all
## Copyright (C) 2019-2020 MongoDB 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
#
# ... |
require 'rails_helper'
feature 'user receives error messages when he or she
does not fill in the form properly',
%Q(
As a Car dealer
I want to know when I failed to properly create a
new manufacturer and what I did wrong
so that I can correct my mistakes
) do
scenario 'user improperly fills out the manuf... |
module Reports
class FacilityProgressService
include Memery
MONTHS = -5
CONTROL_MONTHS = -12
DAYS_AGO = 29
attr_reader :control_range
attr_reader :facility
attr_reader :range
attr_reader :region
attr_reader :diabetes_enabled
def initialize(facility, period, current_user: nil)... |
# frozen_string_literal: true
# [result, time_of_execution_ms]
def clock_monotonic_measure(&block)
s = Process.clock_gettime(Process::CLOCK_MONOTONIC)
result = block.()
f = Process.clock_gettime(Process::CLOCK_MONOTONIC)
execution_ms = (f - s) * 1000
[result, execution_ms]
end
|
class CreateJoinTableAdvertisementCategory < ActiveRecord::Migration[5.0]
def change
create_join_table :advertisements, :categories do |t|
t.index [:advertisement_id, :category_id], name: 'ad_cat'
t.index [:category_id, :advertisement_id], name: 'cat_ad'
end
end
end
|
class Event < ApplicationRecord
CATEGORY = ["Theater", "Exhibition", "Movie", "Concert"]
MOOD = ["Dramatic", "Romantic", "Glamorous", "Wild", "Nerdy"]
TAG = ["Dramatic", "Romantic", "Modern", "Funny"]
validates :name, presence: true
# validates :description, presence: true
validates :category, presence: true... |
def real_palindrome?(string)
new_string = string.downcase.delete(' ','\'',",")
new_string.reverse == new_string
end
puts real_palindrome?('madam') == true
puts real_palindrome?('Madam') == true # (case does not matter)
puts real_palindrome?("Madam, I'm Adam") == true # (only alphanumerics matter)
puts re... |
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
include TruncateHtmlHelper
class Truncator
include TruncateHtmlHelper
end
describe TruncateHtmlHelper do
def truncator
@truncator ||= Truncator.new
end
it 'is included in ActionView::Base' do
ActionView::Base.included_modules.should inc... |
#encoding: utf-8
module DianboHelper
#
# 创建一个新的奇遇点拨。
#
def create_new_dianbo
re, user = validate_session_key(get_params(params, :session_key))
return unless re
type = params[:type]
server_time = Time.now
#点拨类型类表。
type_list = Dianbo.get_types_list
unless type_list.include?(type.to_i)... |
class TopicInfoType < ActiveRecord::Base
belongs_to :topic
belongs_to :info_type
#在topic_info_type被删除之后,同时需要删除topic和info之间的关系:topic_info
after_destroy :delete_topic_info
#validates_presence_of :display_name_in_topic
#以下是类方法
def self.create_topic_info_types(topic_id,info_type_id)
end
#以下是实例方法
def... |
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'fileutils'
=begin rdoc
Utilities for building and deploying applications.
@!attribute [rw] target
@return [String] build target directory name.
@see TARGET_DIR
=end... |
require "json"
require "selenium-webdriver"
require "test/unit"
class LogIn < Test::Unit::TestCase
def setup
@driver = Selenium::WebDriver.for :chrome
@base_url = "https://staging.shore.com/merchant/sign_in"
@accept_next_alert = true
@driver.manage.timeouts.implicit_wait = 30
@verification_error... |
# frozen_string_literal: true
require 'spec_helper'
require 'vagrant-bolt/util/config'
require 'vagrant-bolt/config'
describe VagrantBolt::Util::Config do
let(:global) { VagrantBolt::Config::Bolt.new }
let(:local) { VagrantBolt::Config::Bolt.new }
let(:local_data_path) { '/local/data/path' }
let(:inventory_pa... |
require File.dirname(__FILE__) + '/../../../../spec_helper'
require File.dirname(__FILE__) + '/../../shared/constants'
require 'openssl'
describe "OpenSSL::PKey::RSA.new" do
it 'new without params' do
rsa = OpenSSL::PKey::RSA.new
rsa.to_s.should == PrivateKeyConstants::RSABlank
end
it 'new with key s... |
class WebConfiguration < ClientConfiguration
include Redis::Objects
hash_key :attrs, global: true
def self.config
ClientConfiguration.config.merge(attrs.all).reject{ |k,v| v == '_nil' }
end
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# アソシエーション
has_many :items, dependent: :destroy
ha... |
class User < ActiveRecord::Base
before_create :setup_role
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me, :firstname, :lastname, :nickname, :role_ids
has_and_belongs_to_many :roles... |
require 'cosy/renderer/abstract_midi_renderer'
require 'gamelan'
module Cosy
class MidiRenderer < AbstractMidiRenderer
TICKS_PER_BEAT = 480.0
DEFAULT_SCHEDULER_RATE = 500 # Hz
STOP_BUFFER = 2
attr_accessor :scheduler_rate
def initialize(options={})
super
@scheduler_rate = DEFAUL... |
class Course < ApplicationRecord
has_many :tutorships
has_many :users, through: :tutorships
end
|
class OrdersController < ApplicationController
before_action :authenticate_user!
before_action :cart_total, only: [:create]
def index
@orders = current_user.orders
end
def payment
@order = Order.find(params[:id])
end
def show
if current_user.orders.pluck(:id).include?(params[:id].to_i)
... |
class Conf < ActiveRecord::Base
validates :name, :value, presence: true
before_save :parameterize_name
class << self
def get(name)
begin
Conf.find_by_name(name).value
rescue
nil
end
end
end
private
def parameterize_name
self.name = self.name.parameterize
end
e... |
require "erb"
require "fileutils"
require "logger"
require "pp"
#require "set"
require "datamapper"
require "nats/client"
require "uuidtools"
require "mysql"
require 'vcap/common'
require 'vcap/component'
$:.unshift(File.dirname(__FILE__))
require "mysql_service/util"
require "mysql_service/storage_quota"
module V... |
class UserSetup
attr_reader :user, :attributes
def initialize(user, attributes={})
@user = user
@attributes = attributes.try(:symbolize_keys) || {}
end
def save
@user.subject_ids = attributes[:subject_ids]
@user.receive_notifications = attributes[:receive_notifications]
@user.save
end
... |
class RenameSongsArtists < ActiveRecord::Migration
def change
rename_column :songs, :artist, :artist_name
rename_column :songs, :album, :album_name
end
end
|
class AddUserReferencesToPillar < ActiveRecord::Migration[5.0]
def change
add_reference :pillars, :user, foreign_key: true
end
end
|
class Update < ActiveRecord::Base
belongs_to :keyresult
validates :prev_value, presence:true
end
|
class ArtistsController < ApplicationController
before_action :ensure_login
before_action :set_artist, only: [:show, :edit, :update, :destroy]
# GET /artists
def index
@artists = Artist.all.order('created_at DESC')
@new_artist = Artist.new
end
# POST /artists
def create
@artists = Artist.all... |
json.array! @client_organizations do |co|
json.id co.id
json.client_id co.client_id
json.organization_id co.organization_id
end
|
class BlogsController < ApplicationController
before_action :authenticate_user!
def index
@blogs=Blog.all
end
def new
@blog=Blog.new
end
def create
@blog=Blog.new(blog_params)
@blog.user_id = current_user.id
@blog.save
redirect_to @blog
end
def show
@blog=Blog.find(params[:id])
end
de... |
class Product < ActiveRecord::Base
#links
has_many :photos
has_many :cartitems, :dependent => :destroy
has_many :orders, :through => :cartitems
belongs_to :category
belongs_to :badge
#validations
validates_numericality_of :price
validates_numericality_of :discount, :only_integer => true
validates... |
require 'feature_helper'
feature 'reset password', js: true, perform_enqueued: true do
given!(:user) { create :user, username: 'luiswong' }
Steps 'for requesting reset instructions' do
When 'I visit the homepage' do
visit '/'
end
And 'I click on Login' do
within '.nav' do
click_lin... |
class BigDecimal
def to_url_param
self.to_s.gsub(".", '')
end
# create big decimal from url param string
def self.from_url_param(s)
# break up number, add '.' after first 2 digits
match = s.match(/(-{0,1}[0-9]{2,2})([0-9]+)/)
BigDecimal.new("#{match[1]}.#{match[2]}")
end
end |
#!/usr/bin/env ruby
# Defines Subprocess, which provides a consistent API for calling, waiting on
# and interacting with other programs.
#
# This is unlikely to work under non-Unix platforms, and the tests at the
# end of the script definitely won't.
# Support for Windows would be a welcome addition -- please contribu... |
FactoryGirl.define do
factory :patient do
sequence(:fullname) { |n| "Patient #{n}" }
pesel {rand(11111111111..99999999999)}
birth_date "2014-12-16"
address
sex "male"
trait :male do
sex "male"
end
trait :female do
sex "female"
end
end
end
|
require "rails_helper"
RSpec.describe RecipesController, type: :routing do
it 'routes to #new' do
expect(get('/recipes/new')).to route_to('recipes#new')
end
it 'routes to #create' do
expect(post('/recipes')).to route_to('recipes#create')
end
it 'routes to #show' do
expect(get('/recipes/1')).to route_to('r... |
class SightingsController < ApplicationController
def show
sighting = Sighting.find_by(id: params[:id])
render json: sighting
end |
desc "Clean up as though this were a fresh distribution"
task :dist_clean => [ :clean ] do
end
desc "Clean everything"
task :clean do
sh 'rm pkg'
end
require 'rake/gempackagetask'
gem_spec = Gem::Specification.new do |s|
s.name = 'memetic'
s.version = '1.0.0'
s.summary = 'Memetic'
s.platf... |
class Book < ActiveRecord::Base
include ActionView::Helpers
has_one :material, :as => :item
has_many :materials, :as => :item
has_attached_file :file
def list_representation
image_tag file.url
end
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: data_sets
#
# id :bigint not null, primary key
# hashtags :hstore
# index_name :string
# num_retweets :integer
# num_tweets :integer
# num_users :integer
# top_mentions :hstore
# top_retwee... |
# frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :first_name, null: false
t.string :last_name, null: false
t.string :email, null: false, unique: true
t.string :ic... |
class AddColumnSsServers < ActiveRecord::Migration
def change
add_column :ss_servers, :operating_system, :string, :default => 'Windows'
add_column :ss_servers, :charging_model, :string, :default => 'Reserved 1-Year'
end
end
|
module InContact
module Resources
AGENTS = "Agents"
AGENT_SESSIONS = "AgentSessions"
CONTACTS = "Contacts"
CALL_LISTS = "CallLists"
DISPOSITIONS = "Dispositions"
end
end
|
collection @feed_items
node :type do |item|
item.class.to_s.underscore
end
node :data do |item|
case item.class.to_s.underscore
when 'post'
partial("api/v1/posts/post", :object => item)
when 'board_pic'
partial("api/v1/board_pics/board_pic", :object => item)
when 'book'
partial("api/v1/books/book"... |
# 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... |
Rainbows! do
use :ThreadPool # concurrency model to use
worker_connections 400
keepalive_timeout 0 # zero disables keepalives entirely
client_max_body_size 200*1024*1024 # 200 megabytes
client_header_buffer_size 2 * 1024 # 2 kilobytes
end
|
require 'fluent/config'
class Fluentd
module Setting
class Config
attr_reader :fl_config, :file
delegate :elements, to: :fl_config
def initialize(config_file)
@fl_config = Fluent::Config.parse(IO.read(config_file), config_file, nil, true)
@file = config_file
end
de... |
class DealService
class << self
include ApiClientRequests
def request_uri(options=nil)
if options.is_a?(Fixnum) || options.is_a?(String)
URI("#{ServiceHelper.uri_for('deal', protocol = 'https', host: :external)}/deals/#{options}.json")
elsif options.present?
uri = URI("#{ServiceH... |
# frozen_string_literal: true
require 'spec_helper'
require File.join(File.dirname(__FILE__), '../../lib/registration_notifier')
RSpec.describe RegistrationNotifier do
let(:notifier) { described_class.instance }
describe '#cancel' do
context 'when having one active event for today' do
let!(:event) { Fa... |
class AddRedeemedColumn < ActiveRecord::Migration[6.1]
def change
add_column :rewards, :redeemed, :boolean
end
end
|
require './lib/response_processor'
require './lib/curses/curses_window'
module Messenger
module Commands
module Messages
class Main
class ChatController
include ::ResponseProcessor
attr_reader :scroll_position
def initialize(chat, current_user)
@chat = Me... |
require 'spec_helper'
describe YtUpdatePlaylistJob do
before(:each) do
@client = YtDataApi::YtDataApiClient.new(ENV['YT_USER'], ENV['YT_USER_PSWD'], ENV['YT_DEV_AUTH_KEY'])
response, @youtube_id = @client.create_playlist("delayed_job")
end
after(:each) do
@client.delete_playlist(@youtube_id)
end... |
name 'hpcloud-dns'
maintainer 'Mikko Kokkonen'
maintainer_email 'mikko@owlforestry.com'
license 'Apache 2.0'
description 'Manages DNS records and zones in HP Cloud DNS'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.0.0'
|
class CreateProcessPolicyCombinePartialTransferNoLeases < ActiveRecord::Migration
def change
create_table :process_policy_combine_partial_transfer_no_leases do |t|
t.integer :representative_number
t.string :valid_policy_number
t.string :policy_combinations
t.string :predecessor_policy_type... |
class CreateArticles < ActiveRecord::Migration[5.0]
def change #creara la tabla cuando migremos
create_table :articles do |t|
t.string :title
t.text :body
t.integer :visits_count
t.timestamps
end
end
end
#Las migraciones son como las pilas vienen desde el ultimo antes de migrar cuan... |
require 'rake'
require 'raven/cli'
namespace :raven do
desc "Send a test event to the remote Sentry server"
task :test, [:dsn] do |_t, args|
Rake::Task["environment"].invoke if Rake::Task.tasks.map(&:to_s).include?("environment")
Raven::CLI.test(args.dsn)
end
end
|
module StateMachineAbilities
extend ActiveSupport::Concern
module ClassMethods
def authorize_resource_state_events(opts = {})
key = opts.delete(:key) { :state_event }
filter_params = { only: [:update] }.merge(opts)
before_filter(filter_params) do
unless params[permitted_params_key][k... |
module Refinery
module Members
class MembersController < ::ApplicationController
layout 'popup'
before_filter :find_page
def index
# you can use meta fields from your model instead (e.g. browser_title)
# by swapping @page for @member in the line below:
find_all_members_... |
require_relative '../../scraper/itemdb'
require_relative '../spec_helper'
require 'httparty'
require 'nokogiri'
RSpec.describe 'itemdb' do
before(:each) do
@scraper = ItemDb.new
end
it '/valid item' do
res = @scraper.scrape("9780321552686")
expect(res[:code]).to eq "9780321552686"
expect(res[:va... |
#!/usr/bin/ruby
class Operations
def initialize(database_settings_path="config/database.yaml")
begin
@settings_file = YAML.load_file(database_settings_path)
@mysql = nil
@mongo = nil
@postgre = nil
rescue Errno::ENOENT => e
raise "Error reading #{database_settings_path}."
end
end
def process_o... |
#
# project_controller.rb
# macistrano
#
# Created by Pom on 24.04.08.
# Copyright (c) 2008 Paperplanes, Mathias Meyer. All rights reserved.
#
require 'osx/cocoa'
require 'rubygems'
require 'growl_notifier'
class ProjectController < OSX::NSWindowController
include OSX
include NotificationHub
GROWL_MESSAG... |
RailsAdmin.config do |config|
## == Devise ==
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_user)
## == Cancan ==
config.authorize_with :cancan
config.included_models = ["User",
"Subject",
... |
class Post < ApplicationRecord
belongs_to :blogger
belongs_to :destination
end
|
begin
require 'vagrant'
rescue LoadError
raise 'The Vagrant Netinfo plugin must be run within vagrant.'
end
if Vagrant::VERSION < '1.6.0'
puts 'WARNING: The Vagrant Netinfo plugin has only been tested with vagrant 1.6.x'
puts 'If it works with your version of vagrant, send me a pull request updating this versi... |
# frozen_string_literal: true
# rubocop:disable Metrics/MethodLength
# rubocop:disable Style/StringConcatenation
# rubocop:disable Layout/ArrayAlignment
require_relative 'test_helper'
class TemplateLocalsFileTest < Minitest::Test
def test_file_template_with_locals_file_json
path_file_source = File.join([TestHe... |
class RenameBlockTypeColumn < ActiveRecord::Migration
def change
rename_column :blocks, :type, :kind
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.