text stringlengths 10 2.61M |
|---|
class Bot::Alegre < BotUser
check_settings
::ProjectMedia.class_eval do
attr_accessor :alegre_similarity_thresholds
end
def self.run(body)
if CONFIG['alegre_host'].blank?
Rails.logger.warn("[Alegre Bot] Skipping events because `alegre_host` config is blank")
return false
end
hand... |
module Decorator
def decorate_method(fn, &block)
fxn = instance_method(fn)
define_method fn do |*args|
instance_exec(fxn.bind(self), *args, &block)
end
rescue NameError, NoMethodError
fxn = singleton_class.instance_method(fn).bind(self)
define_singleton_method fn do |*args|
instance_... |
class AddCatalogToProduct < ActiveRecord::Migration
def self.up
add_column :products, :catalog, :string
end
def self.down
remove_column :products, :catalog
end
end
|
class Tree
attr_accessor :children, :node_name
def initialize(name, children=[])
@children = children
@node_name = name
end
def visit_all(&block)
visit &block
# visit(&block)
children.each { |c| c.visit_all &block }
# @children.each { |c| c.visit_all(&block) }
end
def visit(&block)
block.call s... |
module DeviseHelper
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
def devise_error_messages!
return "" unless devise_error_messages?
resource.errors.full_messages.each do |message|
flash_m... |
class Owner < ApplicationRecord
validates :name, presence: true, length: { minimum: 5, message: "Precisa ter no mínimo 5 letras" }
validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
end
|
class TagsController < ApplicationController
before_action :signed_in_user
before_action :set_tag, only: [:show, :edit, :update, :destroy]
# GET /tags
# GET /tags.json
def index
@tags = current_user.tags.all
@tags_groups ={}
StuffsTag::tags_groups(current_user).each do |st|
@tags_groups[s... |
module Memflash
class << self
attr_accessor :threshold
end
self.threshold = 300 # Messages longer than this will be stored in Rails.cache
module CachingLayer
def []=(key, value)
value_for_hash = value
if value.kind_of?(String) && value.length >= Memflash.threshold
value_for_hash = ... |
# encoding: UTF-8
class SessionsController < ApplicationController
before_action :public_access, only: [:new, :create_with_omniauth]
def new
render layout: "pages"
end
def new_slack
render layout: "pages"
end
def create
user = User.find_by(email: params[:email].downcase)
if user && user.... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
module HttpsResponseHelper
def self.data_not_found
return :status => :not_found,
:json => {
:status => false,
:displayMessage => [{ "message": "Data Not Fund" }],
}
end
def self.errors(errors)
return :status => :unprocessable_entity,... |
class FilesController < ApplicationController
before_filter :set_dir
def index
@info = get_file_info(@full_path)
if @info[:directory?]
@files = get_files(@full_path)
else
send_file(@full_path)
return
end
respond_to do |format|
format.html
format.json { r... |
FactoryGirl.define do
factory :person do |f|
f.name "John Smith"
sequence(:email) { |i| "email_#{i}@email.com" }
f.org "Sample Organization"
end
factory :invalid_person, parent: :person do |f|
f.email nil
end
end
|
source 'https://rubygems.org'
gem 'puma'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use PostgreSQL as the database for Active Record.
gem 'pg', '0.18.4'
# Use SCSS for stylesheets.
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets.
gem 'uglifier'... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class Fase2sController < ApplicationController
before_action :set_fase2, only: [:show, :edit, :update, :destroy]
# GET /fase2s
# GET /fase2s.json
def index
@fase2s = Fase2.all
end
# GET /fase2s/1
# GET /fase2s/1.json
def show
end
# GET /fase2s/new
def new
@fase2 = Fase2.new
end
# G... |
class EventManagement::EventsController < EventManagement::ApplicationController
def index
@event_management_events = EventManagement::Event.filter_user_by(@current_user.id)
end
def show
@event_management_event = EventManagement::Event.find(params[:id])
end
def edit
@event_management_event = Ev... |
require "geofips/version"
require "csv"
module Geofips
class Location
attr_reader :lat, :lng, :ne_lat, :ne_lng, :sw_lat, :sw_lng
def initialize(code)
@lat = 0.0
@lng = 0.0
@ne_lat = 0.0
@ne_lng = 0.0
@sw_lat = 0.0
@sw_lng = 0.0
location_rows = CSV.read(File.expand_... |
class Field < ActiveRecord::Base
belongs_to :local
has_many :line_items
before_destroy :ensure_not_referenced_by_any_line_item
private
# ensure that there are no line items referencing this product
def ensure_not_referenced_by_any_line_item
if line_items.empty?
return true
else
err... |
$:.push File.expand_path("../lib", __FILE__)
require "warden/rails/version"
Gem::Specification.new do |s|
s.name = "warden-rails"
s.version = Warden::Rails::VERSION
s.authors = ["Adrià Planas"]
s.email = ["adriaplanas@liquidcodeworks.com"]
s.summary = "Thin wrapper around Warden for ... |
class ProjectUsersController < ApplicationController
# GET /project_users
# GET /project_users.json
def index
@title = "プロジェクトユーザ一覧"
@catch_phrase = " プロジェクトとユーザの紐付けを行います。"
#@project_users = ProjectUser.all
@project_users = ProjectUser.joins('INNER JOIN projects ON project_users.project_id = pr... |
# == Schema Information
#
# Table name: release_order_envs
#
# id :integer not null, primary key
# release_order_id :integer
# env_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_release_order_envs_on_en... |
require 'sqlite3'
require_relative 'questions_db'
require_relative 'questions'
class QuestionsFollows
def self.all
questions_follows = QuestionsDBConnection.instance.execute("SELECT * FROM questions_follows")
questions_follows.map { |datum| QuestionsFollows.new(datum) }
end
def se... |
class AddAmountToDonations < ActiveRecord::Migration[5.0]
def change
add_column :donations, :amount, :integer, :default => 5
add_column :donations, :user_id, :integer
add_column :donations, :restaurant_id, :integer
end
end
|
# frozen_string_literal: true
module Reports
class Material < Base
def receipts
@receipts ||= Receipt.completed
.where(delivered_at: start_date..end_date)
.where(destination_type: "User")
.where(origin_type: "CollectionPoint")... |
require 'spec_helper'
require_relative '../lib/grid_partition/node.rb'
describe GridPartition::Node do
context "::initialize" do
it 'should give a instance w/ 3 argument' do
node = GridPartition::Node.new(1,2,1.0)
node.should_not be_nil
end
it 'should not accept minus value argument' do
... |
require 'csv'
class Exporter
attr_reader :scope
def self.run
self.new.run
end
def initialize(scope = nil)
@scope = scope
end
def run
data = message_data
CSV.open("public/#{path}", 'w') do |csv|
csv << MessageCSVPresenter::HEADERS
data.each do |row|
csv << row
en... |
require_relative 'patient'
class Room
attr_reader :patients, :door_number
attr_accessor :id
def initialize(attributes = {})
@id = attributes[:id]
@door_number = attributes[:door_number]
@number_of_beds = attributes[:number_of_beds] || 0
@patients = attributes[:patients] ||... |
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
config.vm.define "cust1-core" do |server|
server.vm.box = "generic/ubuntu2004"
server.vm.hostname = "... |
class Score < ActiveRecord::Base
validates_presence_of :option
validates_presence_of :comment
end
|
# frozen_string_literal: true
AUTHORIZED_BIB_TAGS = %w[100 110 111 600 610 611 630 650 651 700 710].freeze
require_relative '../../../../app/models/wikidata_connection'
module FindIt
module Macros
# Checks Wikidata for additional keywords to index
module WikidataEnrichment
def keywords_from_wikidata
... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :identification_type
t.string :identification_number
t.boolean :extra_plates
t.string :plate
t.timestamps
end
end
end |
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'sqlite3'
require 'inifile'
module Bnicovideo
class UserSession
# Windows 95 and NT 4.x
module Win95
def self.init_from_firefox
# Single user only
base_path = File.join... |
#!/usr/bin/ruby
#
# Red Hat rotates wtmp monthly by default, which causes the loss of
# login history unnecessarily, as most servers are logged into very
# infrequently and wtmp grows very slowly. So we change the rotation to
# be based on the size of wtmp, which results in retention of 1-2 years
# of login history i... |
RSpec.describe Api::V1::MoviesController, type: :controller do
describe 'GET index' do
before(:each) do
5.times { create(:movie) }
get :index, format: :json
end
include_examples "check response", "application/json"
it "assigns movies as @movies" do
expect(assigns(:movies)).to matc... |
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
# Define layout depending on the called controller
layout :resolve_layout
after_filter :set_csrf_cookie_for_ng
... |
class CryptServices
secret_key_credit_cards = Rails.application.credentials[:secret_key_credit_cards]
key = ActiveSupport::KeyGenerator.new('password').generate_key(secret_key_credit_cards, 32)
@crypt = ActiveSupport::MessageEncryptor.new(key)
class << self
def encrypt(data)
@crypt.encrypt_and_sign... |
# encoding: UTF-8
class Film
class Personnages
# Path du fichier contenant les données marshalisées
def marshal_file
@marshal_file ||= File.join(film.collecte.data_folder, 'personnages.msh')
end
end #/Personnages
end #/Film
|
require 'spec_helper'
describe User do
it { should have_many(:posts) }
describe '#display_name' do
it 'returns the name of the user if it is available' do
user = build(:user, name: 'Some Name', email: 'user@example.com')
expect(user.display_name).to eq(user.name)
end
it 'returns the emai... |
# Creates sets of different sizes
class SetCreator
# Returns a hash of doubleton ItemSets from singleton ItemSets
def self.create_doubletons(singletons)
item_ids = singletons.map(&:id)
create_doubletons_from_item_ids(item_ids)
end
# Creates permutations of possible frequent item sets
# given item_se... |
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
# Copyright:: 2011, En Masse Entertainment, Inc
# License:: Apache License, Version 2.0
#
# 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
# ... |
RSpec::Support.require_rspec_mocks 'verifying_proxy'
module RSpec
module Mocks
# @private
module VerifyingDouble
def respond_to?(message, include_private=false)
return super unless null_object?
method_ref = __mock_proxy.method_reference[message]
case method_ref.visibility
... |
require 'fileutils'
module OHOLFamilyTrees
class FilesystemLocal
attr_reader :output_dir
def initialize(output_dir)
@output_dir = output_dir
end
def with_metadata(metadata)
self
end
def write(path, metadata = {}, &block)
filepath = "#{output_dir}/#{path}"
FileUtils.... |
require 'semantic_logger'
module GhBbAudit
module Bitbucket
class BitbucketRepo
include SemanticLogger::Loggable
def initialize(user_name,repo_name)
@user_name = user_name
@repo_name = repo_name
end
def get_all_file_paths
return [] if ( !@user_name || !@repo_name... |
class Board
attr_accessor :state
def initialize(state=nil)
@state = (state || Array.new(9))
end
def valid_step?(step)
self[step].nil?
end
def get_available_steps
@state.each.with_index(1).select { |mark, index| mark.nil? }.map { |mark, index| index }
end
def new_board(step, mark)
boa... |
class AddDefault0ToSearches < ActiveRecord::Migration
def change
change_column :talent_domains, :times_searched, :integer, :default =>0
change_column :talent_domains, :times_used, :integer, :default =>0
change_column :keywords, :times_searched, :integer, :default =>0
change_column :keywords, :times_us... |
FactoryBot.define do
factory :document do
country { ISO3166::Country.all_translated('EN').sample }
document_type { Document.document_types.keys.sample }
issued_at { 5.years.ago }
expired_at { 5.years.from_now }
number { 123 }
end
end
|
class CustomersController < ApplicationController
before_action :authenticate_customer!
before_action :set_customer,only: [:edit,:show,:withdraw]
def show
set_customer
if @customer != current_customer
redirect_to items_path
end
end
def edit
set_customer
if @customer != current_customer
redirect... |
class DashboardBaseGenerator < Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
def create_dashboard_base_controller
copy_file "dashboard_base_controller.rb", "app/controllers/dashboard_base_controller.rb"
end
def create_dashboard_base_file
copy_file "dashboard_base.rb", "app... |
#!/usr/bin/env ruby
num = (1..999)
def multiple(num)
num.select do |x|
x %3 == 0 || x %5 == 0
end
end
puts multiple(num).reduce(:+)
|
class GenresController < ApplicationController
def new
@genre = Genre.new
end
def update
# @post = Post.find(params[:id])
# @schoolclass = SchoolClass.find(params[:id])
# @student = Student.find(params[:id])
# @artist = Artist.find(params[:id])
@genre = Genre.find(params[:id])
... |
require 'rails_helper'
describe 'sweater weather api' do
before(:each) do
@user = User.create(email: 'foofoo@gmail.com', password: 'password', password_confirmation: 'password')
end
it 'can login a registered user with valid credentials' do
post "/api/v1/sessions", :params => '{ "email": "foofoo@gmail.co... |
require 'fdk'
def myfunction(context:, input:)
input_value = input.respond_to?(:fetch) ? input.fetch('name') : input
name = input_value.to_s.strip.empty? ? 'World' : input_value
{ message: "Hello #{name}!" }
end
FDK.handle(target: :myfunction)
|
require_relative '../test_helper'
class PayloadTest < TrafficTest
include PayloadPrep
def setup
setup_model_testing_environment
@user = TrafficSpy::User.find(1)
@user_url_blog = @user.payloads.where(url: "http://jumpstartlab.com/blog")
end
def test_url_popularity
expected_result = {"http://ju... |
module MatchEvent
class Base < ActiveRecord::Base
self.table_name = "match_events"
belongs_to :match
belongs_to :team
belongs_to :player1, class_name: "Player", foreign_key: "player1_id"
belongs_to :player2, class_name: "Player", foreign_key: "player2_id"
scope :for_scoring, -> (player_id) ... |
#============================================================================
# Unit Circle
#----------------------------------------------------------------------------
# Display under the battler position
#============================================================================
class Unit_Circle < Sprite_Base
#... |
Types::PdvType = GraphQL::ObjectType.define do
name 'Pdv'
field :id, !types.ID
field :tradingName, !types.String
field :ownerName, !types.String
field :document, !types.String
field :coverageArea, !types.String
field :address, !types.String
end
|
class CommissionCalculator
INSURANCE_PRICE = 100 # in cents
def self.for(rental)
new(rental)
end
def initialize(rental)
@rental = rental
end
# forcing integers to match up with docs, not sure if these things are
# calcuated in cents which is probably why they are all integers
def insurance_fe... |
require 'digest'
module Digest
class RubySHA3 < Digest::Class
PILN = [10, 7, 11, 17, 18, 3, 5, 16,
8, 21, 24, 4, 15, 23, 19, 13,
12, 2, 20, 14, 22, 9, 6, 1]
ROTC = [ 1, 3, 6, 10, 15, 21, 28, 36,
45, 55, 2, 14, 27, 41, 56, 8,
25, 43, 62, 18, 39, 61... |
module Prov
class HandlesProvBlock
attr_reader :body,:commands,:triples
def initialize
@urinum=0
@commands=[]
end
def uri
RDF::URI url
end
def graph_uri
"http://www.amee.com/graph"
end
def author
nil
end
def newuri
@urinum+=1
... |
@token = nil
@error = nil
When(/^the user pairs with BitPay(?: with a valid pairing code|)$/) do
claim_code = get_claim_code_from_server
pem = BitPay::KeyUtils.generate_pem
@client = BitPay::Client.new(api_uri: ROOT_ADDRESS, pem: pem, insecure: true)
@token = @client.pair_pos_client(claim_code)
end
When(/^the... |
$: << File.dirname(__FILE__)
$test_env = true
require "../lib/proforma"
describe "A Low level TextField" do
before do
class DerpForm < Form
@@derp_field = TextField.new("Herp some derps", :max_length=>2)
end
@derp_field = DerpForm.new.fields[0]
end
it "should assign its name based on the cl... |
class CreateIncidentworkflows < ActiveRecord::Migration[6.0]
def change
create_table :incidentworkflows do |t|
t.references :incident, null: false, foreign_key: true
t.references :workflowtemplate, null: false, foreign_key: true
t.timestamps
end
end
end
|
class DeploymentBroadcastJob < ApplicationJob
queue_as :default
def perform(status, user:)
DeploymentChannel.broadcast_to user, status: status
end
end
|
# Represents a grid column!
module Autogrid
class Column
# An unique String ID of this column
attr_accessor :id
# The name of this column, which should be human readable
attr_accessor :name
# todo: comment these
attr_accessor :html, :header_html, :visible, :hidden, :filter, :use... |
class KeyValueWidget
attr_accessor :value
def initialize(x, y, label, value)
raise 'Cannot initialize key value widget when x is nil' unless x
raise 'Cannot initialize key value widget when y is nil' unless y
raise 'Cannot initialize key value widget when label is nil' unless label
raise 'Cannot ... |
class Substring
def initialize
@dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit"]
end
def user_input(string)
substrings(string,@dictionary)
end
def substrings(string, dict_array)
my_hash = {}
arr_word = string.split(" ")
arr_... |
module Hpricot
# :stopdoc:
class Doc
attr_accessor :children
def initialize(children)
@children = children ? children.each { |c| c.parent = self } : []
end
def output(out)
@children.each do |n|
n.output(out)
end
out
end
end
class BaseEle
attr_accessor :... |
class Backbone::ThemesController < ApplicationController
def index
render :json => Theme.where(:status => :active).all
end
end |
class AddPaperTrailTables < ActiveRecord::Migration[5.0]
def change
create_table :paper_trail_versions do |t|
t.string :item_type
t.integer :item_id, null: false
t.string :event, null: false
t.string :whodunnit
t.text :object
t.datetime :created_at
end
a... |
module Exercise2
class Solution
attr_reader :numbers, :iterations, :calculation_results
def initialize(number, with_print = false)
@n = number
@calculation_results = []
@iterations = 0
@with_print = with_print
end
def run
while @n != 495 && @n != 0
# main loop ... |
class Project < ActiveRecord::Base
STATUSES = [:ongoing, :finished, :stopped]
has_many :story
#validations
validates :title, presence: true
validates :status, presence: true, numericality: {
greater_than_or_equal_to:0, less_than: STATUSES.length
}
end
|
class HomeController < ApplicationController
before_filter :require_user
before_filter :require_admin, only: [:make_chore_auction_form]
before_filter :clear_admin, only: [:make_chore_auction]
def my_chores
#grabs user data to display chores in the template
@user = current_user
respond_to do |for... |
require "net/ssh"
class ExecWithStatus
def initialize(ssh, command)
@command = command
@channel = ssh.open_channel(&method(:channel_opened))
@channel[:out] = ""
end
def result
@channel[:out]
end
def status
@status
end
private
def channel_opened(channel)
channel.exec(@command... |
class UsersController < ApplicationController
before_action :authorize_user
skip_before_action :verify_authenticity_token
def new
@user = User.new
end
def create
@list = List.find_by_id(params[:list_id])
@user = User.find_or_create_by_filtered_params(user_params)
@user.assign_invitation_toke... |
require 'chefspec'
require 'chefspec/berkshelf'
require_relative 'support/example_groups/provider_example_group'
require_relative 'support/example_groups/resource_example_group'
RSpec.configure do |config|
config.color = true # Use color in STDOUT
config.formatter = :documentation # Use the specified... |
require_dependency "usercommunications/application_controller"
module Usercommunications
class UsermaildataController < ApplicationController
before_action :set_usermaildatum, only: [:show, :edit, :update, :destroy]
# GET /usermaildata
def index
@usermaildata = Usermaildatum.all
end
# GET... |
require 'rails_helper'
RSpec.describe LikesController, type: :controller do
before do
@user = create(:user)
@secret = create(:secret, user: @user)
@like = create(:like, secret: @secret, user: @user)
end
context "when not logged in " do
before do
session[:user_id] = nil
end
it "... |
module PayoneerApiClient
class Balance
class << self
def status
PayoneerApiClient.make_api_request(METHOD_NAME[:balance], :get)
end
end
end
end
|
class Cliente < ActiveRecord::Base
def self.search(search, page)
where(['upper(nombre) like ?',
"%#{search}%".upcase]).paginate(page: page, per_page: 3).order("nombre")
end
end |
module AuthForum
class OrderMailer < ApplicationMailer
def order_confirm(order)
@order = order
mail(to: order.email, subject: 'Your order has been Confirmed')
end
end
end
|
## Staxfile DSL commands
module Stax
module Dsl
def stack(name, opt = {})
opt = {groups: @groups}.merge(opt) # merge with defaults
Stax.add_stack(name, opt)
end
def command(*args)
Stax.add_command(*args)
end
## temporarily change default list of groups
def group(*groups, &b... |
require 'spec_helper'
describe 'restaurants index page' do
context 'no restaurants have been added' do
it 'should display a message' do
visit '/restaurants'
expect(page).to have_content 'No restaurants yet'
end
end
end
describe 'creating a restaurant' do
context 'logged out' do
it 'takes us to the si... |
class Repository < ActiveRecord::Base
has_many :votes
def self.display_order_by_score
self.order("score DESC").all
end
def self.display_order_by_pushed_at
self.order("repos_pushed_at DESC, score DESC").all
end
def vote(user)
return nil unless user
self.vote_count = self.votes.count + 1
... |
require 'spec_helper'
describe Redemption do
let(:negative_points_redemption) do
FactoryGirl.build(:redemption, {
:points => - 50
})
end
let(:redemption) do
Redemption.new
end
let(:normal_redemption) do
FactoryGirl.create(:redemption)
end
let(:hacker) do
FactoryGirl.create(:... |
# == Schema Information
#
# Table name: questions
#
# id :integer not null, primary key
# question_text :string
# created_at :datetime not null
# updated_at :datetime not null
# correct_answer_id :integer
#
class Question < ApplicationRecord
validates :q... |
class AddSanitanizedUrlToShortUrls < ActiveRecord::Migration[5.2]
def change
add_column :short_urls, :sanitanized_url, :string
end
end
|
require 'jipcode'
require 'uri'
require 'net/http'
require 'zip'
require 'nkf'
module Jipcode
module JapanPost
ZIPCODE_URLS = {
general: 'https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip'.freeze,
company: 'https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip'.freeze
}... |
# encoding: utf-8
class Departamento < ActiveRecord::Base
# Valida la precensia de los campos
validates_presence_of :departamento
# relacion de 1 a varios con documentos
has_many :clientes
# metodo que por defecto presenta el string
def to_s
departamento
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box =... |
# frozen_string_literal: true
class Event < ApplicationRecord
include DateRange
validates_with EventSeasonValidator
belongs_to :user, optional: true
def self.ical(events = includes(:user))
Icalendar::Calendar.new.tap do |cal|
cal.prodid = '-//wereb.us//moretti.camp//EN'
events.each { |event| ... |
class PagesController < ApplicationController
layout 'admin'
before_filter :confirm_admin
before_filter :load_nav
def index
list
render('list')
end
def list
@pages = Page.sort
end
def show
@page = Page.find(params[:id])
@items = @page.items.sort
end
def new
@page = Page.new(... |
# frozen_string_literal: true
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 :authenticate_user!
before_action :configure_permitted_parameters, if:... |
require 'test_helper'
describe "SuperFormatter::Tcat" do
before do
@spreadsheet = SuperSpreadsheet::Loader.new("test/support/tcat/export.csv").tap { |s| s.call }
@service = SuperFormatter::Tcat::Import.new(@spreadsheet).tap { |s| s.call }
end
should "#result.length = 34" do
assert_equal 34, @service... |
Rails.application.routes.draw do
namespace :api do
resources :departments do
resources :products
end
end
end
|
class UsersController < ApplicationController
before_action :find_user, only: [:show, :edit]
before_action :current_user
def index
@users = User.all
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
flash[:status] = "success"
flash[:resu... |
module NavigationHelpers
module Refinery
module Supports
def path_to(page_name)
case page_name
when /the list of supports/
admin_supports_path
when /the new support form/
new_admin_support_path
else
nil
end
end
end
end
end
|
# frozen_string_literal: true
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
can :read, :all
if user.is? :admin
can :manage, :all
elsif user.is? :user
can :read, User, user_id: user.id
cannot :read, Requirement
can... |
class CreateAuths < ActiveRecord::Migration
def change
create_table :auths do |t|
t.string :oauth_token
t.string :oauth_secret
t.integer :user_id
t.string :provider
t.string :dc
t.string :list_id
t.string :name
t.string :provider_id
t.timestamps
en... |
module Zergio
class ObjectBase
# Attributes shared by all objects.
attr_writer :id, :created_at, :updated_at
def id
if valid_id?
@id
else
@id = (@id.to_s.scan(/^(\d+)$/).first.first rescue nil)
end
end
def as_time(input)
input.kind_of?(Time) ? input : Dat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.