text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require 'ostruct'
module Tzispa
module Config
class Base < Struct
def self.parametrize(params)
new(*params&.keys&.map(&:to_sym)).new(*(params&.values&.map do |v|
v.is_a?(Hash) ? parametrize(v) : v
end))
end
def method_missing(m, *args, ... |
# -*- encoding : utf-8 -*-
FactoryGirl.define do
factory :user_email do
sequence(:address) {|n| "max.mustermann#{n}@example.com" }
is_verified false
is_primary true
user
end
end
|
class SessionsController < ApplicationController
def new
end
def create
user = User.auth(params[:email], params[:password])
if user
session[:user_id] = user.id
redirect_to root_url, :notice => "Tervetuloa, " + user.full_name + "!"
else
flash[:notice] = "Sähköposti tai salasana on ... |
class Websites::FormDataSerializer < ApplicationSerializer
object_as :website
attributes(
:url,
:name,
:notes,
:contact_id,
:created_at,
:updated_at,
)
end
|
shared_examples 'is_a_case_curation_concern_controller' do |curation_concern_class, options = {}|
actions = options.fetch(:actions, :all)
CurationConcern::FactoryHelpers.load_factories_for(self, curation_concern_class)
def self.optionally_include_specs(actions, action_name)
normalized_actions = Array(action... |
class ProjectsController < ApplicationController
def index
@user = User.find_by(id: session[:user_id])
@projects = Project.where(user_id: session[:user_id])
end
def show
@project = Project.find(params[:id])
@tasks = @project.tasks
@tasks_1 = @tasks.select { |task| task.phase == 1 }
@tasks... |
# 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 ChangeFacebookShareLeadTypeToText < ActiveRecord::Migration
def up
change_table :campaigns do |t|
t.change :facebook_share_lead, :text
end
end
def down
change_table :campaigns do |t|
t.change :facebook_share_lead, :string
end
end
end
|
class PurchasesImporter
HEADER = ['purchaser_name', 'item_description', 'item_price', 'purchase_count', 'merchant_address', 'merchant_name']
attr_reader :file_content
def initialize(file)
@file_content = file.read
end
def run
@file_content.lines.drop(1).each do |line|
values = HEADER.zip(line.... |
require 'memoizer'
require 'singleton'
require File.expand_path('database_config', File.dirname(__FILE__))
require File.expand_path('database_server', File.dirname(__FILE__))
require File.expand_path('test_config', File.dirname(__FILE__))
module TestSupport
class TargetDatabaseServers
include Memoizer
inclu... |
require "formula"
class Cosmic < Formula
desc "Calculate cosmological distances and timescales"
## homepage "https://www.kempner.net/code.php#cosmic"
homepage "https://github.com/joshkempner/Cosmic"
url "https://github.com/joshkempner/Cosmic/archive/refs/heads/main.zip"
sha256 "60d22ea099d35c0cd4cc7afac7636c... |
gem 'gemoji'
# Rakefile
load 'tasks/emoji.rake'
rake emoji
# 这个命令把 emoji 表情图片从 gem 的源码中复制到 Rails 的 public 目录下smile_cat,把图片保存在一个固定的地方,这种方式是被官方推荐的sunglasses,当然你也可以手动把所有图片添加到 assets 加载的目录angry
# config/application.rb
config.assets.paths << Emoji.images_path
#然后在部署的时候把它们编译一下 worried
# config/application.rb
config.ass... |
class ChangeTweetStatDateToForDate < ActiveRecord::Migration
def change
rename_column :tweet_stats, :date, :for_date
end
end
|
require "set"
MATCHER = /\#(?<id>\d+) @ (?<x>\d+),(?<y>\d+): (?<width>\d+)x(?<height>\d+)/
Range.class_eval do
def overlaps?(other)
cover?(other.first) || other.cover?(first)
end
def intersection(other)
return nil if max < other.begin || other.max < self.begin
[self.begin, other.begin].max..[max, ... |
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module NapakalakiGame
class Player
require_relative "Napakalaki.rb"
require_relative "Dice.rb"
require_relative "CombatResult.rb"
att... |
FactoryGirl.define do
factory :location do
sequence(:name) {|n| "location#{n}" }
address1 '12 Seahawks Way'
city 'Renton'
state { State.find_by_abbreviation('WA')}
postal_code '98056'
country {Country.find_by_abbreviation('US')}
end
end |
# frozen_string_literal: true
require 'oai'
require 'tmpdir'
module Orangetheses
class Harvester
def self.default_server
return 'https://dataspace-staging.princeton.edu/oai/request' if test?
'https://dataspace.princeton.edu/oai/request'
end
def self.default_metadata_prefix
'oai_dc'
... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
context 'associations' do
should have_many(:comments)
should have_many(:todo_lists)
should have_many(:todos)
end
end
class NoviceTest < ActiveSupport::TestCase
def setup
@novice = users(:novice)
end
context 'associations' do
... |
#!/usr/bin/env ruby
require 'rubygems'
require 'sqlite3'
require 'yaml'
## Lightweight, persistent cache, to store keys and their values in an SQLite database.
class SqliteCache
## Enable/disable cache hit counting [boolean]
attr_accessor :count_hits
## Number of times to retry, if database is locked [integ... |
class CreateProcessLocations < ActiveRecord::Migration
def change
create_table :process_locations do |t|
t.string :name
t.timestamps null: false
end
ProcessLocation.create([
{ name: 'Setor licitação' },
{ name: 'Arquivado' },
{ name: 'Setor Financeiro' },
{ name: 'Setor Jurídico' },
{ name:... |
class Api::V1::UsersController < ApplicationController
before_action :load_user, only: [:show, :update, :destroy]
def index
prms = request.parameters
if prms[:first]
count = User.count
render json: { first: count.zero? }, status: :ok
else
users = User.all.order(:id)
render json:... |
namespace :metrics do
desc "A Ruby coding standards report using Roodi"
task :roodi do
MetricFu.generate_roodi_report
end
end |
class BoxesController < ApplicationController
before_action :set_box, only: [:show, :edit, :update, :destroy]
def index
@boxes = []
Box.all.each do |box|
if box.parts.length.positive?
@boxes << box
end
end
@boxes
# @boxes = Box.all.sample(100)
# @boxes = Box.all
end
... |
require File.expand_path(File.dirname(__FILE__) + '/helper')
class MethodsApplying < Test::Unit::TestCase
# fixtures :dummies
context "A Dummy instance/record " do
setup do
@dummy = Factory.build(:with_method)
end
should "respond to @instace.applied_methods" do
assert @dummy.... |
require 'spec_helper'
describe ItemsController, :type => :routing do
describe 'routing' do
describe 'routes to #create,' do
subject{ { post:'/projects/1/categories/2/sub_categories' } }
it{ is_expected.to be_routable }
it{ is_expected.to route_to(controller: 'items', action: 'create',
... |
module SessionsHelper
def sign_in_user(user)
# Create a permanent cookie (experies in 20 years from the creation)
cookies.permanent[:remember_token] = user.remember_token
# Makes current_user accesible in both controllers and views
self.current_user = user
end
# Sets current_user
def current_... |
class Rule < ActiveRecord::Base
include IceCubeMethods
belongs_to :activity
after_create :add_slots, unless: :skip_callbacks
belongs_to :address
def add_slots
begin_date = Date.today
if self.repeat_ends_on.blank?
last_date = begin_date + 90.days
else
last_date = self.repeat_ends_on
... |
class ActionTypeDef
A_NIL = nil
A_USE = 1
A_KILL = 2
A_REPAIR = 3
A_MOVE = 4
A_INITVOTE= 5
A_VOTE = 6
A_STATUS = 7
end |
class GlobalWeather
def initialize
@client = Savon.client(wsdl: "http://www.webservicex.com/globalweather.asmx?WSDL")
end
def get_weather(city, country)
xml = @client.call(:get_weather, message: { "CityName" => city, "CountryName" => country }).body.try(:[], :get_weather_response).try(:[], :get_weather_r... |
class Feed
include Mongoid::Document
# integer timestamp used for acquiring a fresh logset from the ES server
#field :timerange, :type => Hash, :default => {'lower' => nil,'upper' => nil} #, :type => Float, :default => 0.0
# TODO: utilize fclass field to differentiate between existing feeds
field :fclass, :type =... |
maintainer "CityIndex Ltd."
maintainer_email "me@ryangeyer.com"
license "Apache 2.0"
description "Installs/Configures shapado"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.3"
supports "ubuntu"
%w{rvm nginx unicorn rightscale}.each do |d|
depends ... |
require 'rails_helper'
RSpec.describe Plate, type: :model do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:main_ingredient) }
it { should validate_presence_of(:type_plate) }
it { should validate_presence_of(:price) }
it { should validate_numericality_of(:price).
is_greater_t... |
module CDI
module V1
class SimpleBlogArticleSerializer < ActiveModel::Serializer
root false
attributes :id,
:title,
:link,
:description,
:content,
:pub_date
end
end
end
|
class GoalsController < ApplicationController
def new
@goal = Goal.new
end
def show
@goal = Goal.includes(:user, :comments).find(params[:id])
@user = @goal.user
@comments = @goal.comments
end
def create
@goal = current_user.goals.new(goal_params)
if @goal.save
flash[:notices] ... |
module BackgroundProcessStubs
def stub_background_administrative_area_lookup(count: 1)
expect(UpdateLocationAdministrativeAreaJob)
.to receive(:perform_later)
exactly(count).times
end
end
|
# encoding: UTF-8
require "spec_helper"
require "v1/patient_case_decorator"
describe V1::PatientCaseDecorator do
describe "#title" do
context "in English" do
before(:each) do
I18n.locale = :en
end
it "prefixes for revision case" do
decorator = V1::PatientCaseDecorator.new(
... |
class CadastroScreen < SitePrism::Page
include CadastroModule
element :formulario, '.collapsible-header', text: 'Formulário'
element :preencher_nome, '#user_name'
element :preencher_sobrenome, '#user_lastname'
element :preencher_email, '#user_email'
element :preencher_endereco,'#user_addr... |
require 'byebug/command'
module Byebug
#
# Ask for help from byebug's prompt.
#
class HelpCommand < Command
self.allow_in_control = true
def regexp
/^\s* h(?:elp)? (?:\s+(\S+))? (?:\s+(\S+))? \s*$/x
end
def execute
return puts(help) unless @match[1]
cmd = Byebug.commands.fi... |
class AddSolrPhotos < ActiveRecord::Migration
def change
create_table :solr_photos do |t|
t.integer :user_id
t.string :name, :default => '', :null => false
t.column :size, 'int unsigned', :default => 0, :null => false
t.column :height, 'int unsigned', :default => 0, :null => fal... |
require 'digest/md5'
=begin
The idea of the API is to collect all tasks that should have been done by robot(s).
Stipulations:
- Each robot has its own API KEY and password used for signing in.
- Each request should contain API KEY, params (if needed) and MD5 digest of params and password
- For every re... |
##
# This class represents Player and contains all the database transaction code related to it.
# encoding: utf-8
class Player < Sequel::Model
def self.all
DB.fetch('SELECT * FROM player ORDER BY ranking_score DESC').all
end
def self.top10
DB.fetch('SELECT * FROM player ORDER BY ranking_score DESC LIMIT... |
Gem::Specification.new do |s|
s.name = %q{jake69mac-stopwords}
s.author = %q{Jake McAllister}
s.email = 'jake69mac@gmail.com'
spec.post_install_message = "Thanks for installing, Please donate to show your appreciation and to allow me to eat:) http://pledgie.com/campaigns/17816 "
s.version = "1.2.1"
s.dat... |
require 'rails_helper'
feature 'User can edit his answer', %q{In order to correct mistakes} do
given(:user) { create(:user) }
given!(:question) { create(:question) }
given!(:other_question) { create(:question) }
given!(:answer) { create(:answer, question: question, user: user) }
scenario 'Unauthenticated c... |
require 'spec_helper'
require 'bullhorn/rest/entities/resume'
require 'bullhorn/rest'
describe Bullhorn::Rest::Entities::Candidate, :vcr do
let(:client) { Bullhorn::Rest::Client.new(client_id: test_bh_client_id, client_secret: test_bh_client_secret, username: test_bh_username, password: test_bh_password) }
desc... |
# frozen_string_literal: true
module Jiji::Model::Graphing
class GraphRepository
def find(backtest_id = nil, start_time = nil, end_time = nil)
query = { backtest_id: backtest_id }
query[:end_time.gte] = start_time if start_time
query[:start_time.lt] = end_time if end_time
Graph.where(... |
#==============================================================================
# Show Animated Picture
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Ported by by: Kread-Ex
# Date: February 20, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
# ... |
json.array!(@hoteljunks) do |hoteljunk|
json.extract! hoteljunk, :id, :name
json.url hoteljunk_url(hoteljunk, format: :json)
end
|
require 'rails_helper'
describe 'FizzBuzzs', type: :request do
describe '#index' do
it 'returns the list of fizzbuzzs' do
get '/'
expect(response).to be_success
expect(response.body).to include 'data'
expect(response.body).to include '100'
expect(response.body).to_not include '101'... |
require 'spec_helper'
describe "Account Creation" do
describe "self.create_acct_complete(params)",:vcr do
it "Creates an account with an extensive set of data elements" do
response = api.create_acct_complete({"master_plan_no" => 1})
response.should have_key("error_code")
response.should have_k... |
module Fog
module Compute
class DigitalOceanV2
class Region < Fog::Model
identity :slug
attribute :name
attribute :sizes
attribute :available
attribute :features
end
end
end
end |
class FontIosevkaSlab < Formula
version "17.0.4"
sha256 "50d7f10c30b4daba5b26a0929cf134e12a9a3b2bf943bca67a9d4282cd6f441c"
url "https://github.com/be5invis/Iosevka/releases/download/v#{version}/ttc-iosevka-slab-#{version}.zip"
desc "Iosevka Slab"
desc "Sans-serif, slab-serif, monospace and quasi‑proportional ... |
class LocationsController < ApplicationController
def new
@company = Company.find(params[:company_id])
@location = Location.new
end
def create
company = Company.find(params[:company_id])
location = company.locations.new(location_params)
if location.save
flash[:notice] = 'Location pendi... |
require 'data_model/type_validators/base'
require 'data_model/err'
module Moon
module DataModel
module TypeValidators
# A recursive TypeValidator, this will check and ensure that sub
# Arrays and Hashes match their provided Type.
module Verbose
include Moon::DataModel::TypeValidators::S... |
describe ArticlesOfficer do
let!(:articles_officer_kirk) { create(:articles_officer_kirk) }
let(:article_kirk) { articles_officer_kirk.article }
describe "#excerpt" do
it "prefers excerpt without funny chars" do
article_kirk.body = "{name: \"Captain James Kirk\" foo" + " "*90 + "James Kirk is silly"
... |
# Your code goes here!
class Anagram
def initialize(word)
@word = word
end
def match(poss_array)
poss_array.reject! do |poss_anagram|
poss_anagram if poss_anagram.length != @word.length
end
poss_array.select do |anagram|
#all the ones where not every letter in the anagram
#matches every letter in... |
class AddRankToDelays < ActiveRecord::Migration[5.0]
DELAYS_RANKS = {
"shortly" => 2,
"see_description" => 1,
"three_days" => 3,
"one_week" => 4,
"two_weeks" => 5,
"one_month" => 6,
"two_months" => 7,
"more_than_two_months" => 8
}
def change
add_column :delays, :rank, :inte... |
# frozen_string_literal: true
FactoryBot.define do
factory :user do
last_name { SecureRandom.uuid }
email_address { Faker::Internet.email }
User.roles.each do |key, _value|
trait key.to_sym do
role { key }
end
end
role { :regular }
branch
flags { [] }
end
end
|
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: "cars#index"
mount ActionCable.server => '/cable'
resources :cars
resources :reservations, only: [:index, :destroy]
resources :users, only: ... |
class ApplicationController < ActionController::API
# check_authorization
include ActionController::HttpAuthentication::Token::ControllerMethods
include ActionController::MimeResponds
include CanCan::ControllerAdditions
include Response
include ExceptionHandler
# called before every action on controllers... |
# frozen_string_literal: true
module Users
class SessionsController < ::Devise::SessionsController
def after_sign_in_path_for(resource)
return welcome_path if resource.sign_in_count == 1
return referrer_params[:user][:referrer] if valid_referrer?
members_path
end
private
def valid_... |
class Web::Admin::ArticlesController < Web::Admin::ApplicationController
def index
if params[:search].present?
articles = Article.active.search params[:search]
else
articles = Article.send(params[:scope] || :active)
end
@articles = articles.page(params[:page]).decorate
end
def show
... |
class FontNotoSansSamaritan < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansSamaritan-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Sans Samaritan"
homepage "https://www.google.com/get/noto/#sans-samr"
def install
(share/"fonts").install "NotoSansSam... |
# frozen_string_literal: true
require 'base64'
require 'excon'
require 'rubygems'
require 'byebug'
module Xendit
class Client
attr_reader :api_key, :base_url
def initialize(api_key:, base_url: 'https://api.xendit.co/v2/')
@api_key = api_key
@base_url = base_url
end
def post(path, body)... |
# frozen_string_literal: true
# Copyright (c) 2018-2020 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to us... |
#!/usr/bin/env ruby -w
# encoding: utf-8
require 'sequel_observer/filter'
unless defined? Sequel::Observer
##
# class Sequel::Observer
#
class Sequel::Observer
# Class methods
##
# == Usage:
# Sequel::Observer.observers = :model_name_observer
# Sequel::Observer.observers = :model_1_name_observer, :model_... |
class CreateGithubComment
attr_accessor :content
GITHUB_ACTIONS = %w'created submitted'
def self.call(content)
self.new(content).call
end
def initialize(content)
@content = content
end
def call
case content['action']
when 'created'
create_created_comment
when 'submitted'
... |
class Api::V1::GrowPhasesController < Api::V1::BaseApiController
def index
# grow_phases = Common::GrowPhase.all()
# render json: Common::GrowPhaseSerializer.new(grow_phases).serialized_json
grow_phases = Common::QueryGrowPhase.call().result
render json: grow_phases.to_json, status: 200
end
def s... |
require "rails_helper"
RSpec.describe DailyMailer, :type => :mailer do
let(:user) { create(:user) }
describe '#digest' do
let!(:questions) { create_list(:question, 2) }
let(:mail) { DailyMailer.digest(user) }
it 'renders the subject' do
expect(mail.subject).to eql('Latest questions of SolveSimple')
... |
class Hotels::UpdateService < Hotels::Base
PERSONAL_ROUTE = 'hotels'
def initialize(params={})
@params = params
@data = @params[:data]
@id = @params[:id]
end
def perform!
@api_call = update_hotel
if @api_call.include?('errors')
error_result
else
ResultObjects::Success.new(... |
module WiKey
# Web App
class App < Roda
# GET /see_also/:topic_name
route('see_also') do |routing|
routing.on String do |topic_name|
routing.get do
result = ApiGateway.new.see_also(topic_name)
view_info = { result: result }
if result.processing?
view_i... |
# == Schema Information
#
# Table name: shelters
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
# user_id :integer
# address :string(255)
#
class Shelter < ActiveRecord::Base
belongs_to :user
has_many :animals
has_many :p... |
require 'test_helper'
class PracticalWorksControllerTest < ActionDispatch::IntegrationTest
setup do
@practical_work = practical_works(:one)
end
test "should get index" do
get practical_works_url
assert_response :success
end
test "should get new" do
get new_practical_work_url
assert_resp... |
#!/usr/bin/env ruby
#
# This program is used for collecting web server visit information.
#
# Author: A. Genius
#
require 'optparse'
def print_usage
puts "USAGE: visit_server -d DNS_NAME"
exit
end
# add option switch and handler
options = {}
option_parser = OptionParser.new do |opts|
# DNS_NAME argum... |
# == Schema Information
#
# Table name: videos
#
# id :integer(4) not null, primary key
# title :string(255)
# description :text
# permalink :string(255)
# video_type_id :integer(4)
# third_party :boolean(1)
# third... |
# frozen_string_literal: true
module Vedeu
# Provides a mechanism to help configure and use Vedeu.
#
module DSL
end # DSL
end # Vedeu
require 'vedeu/dsl/helpers/attributes'
require 'vedeu/dsl/helpers/align'
require 'vedeu/dsl/helpers/truncate'
require 'vedeu/dsl/helpers/wordwrap'
require 'vedeu/dsl/helpers... |
class ResponsesController < ApplicationController
before_action :set_response, only: [:show, :edit, :update, :destroy, :override_response]
# GET /responses
# GET /responses.json
def index
@commit = Commit.find(params[:commit_id])
@url = Url.find(params[:url_id])
@responses = @commit.responses.where(... |
require 'spec_helper'
describe ZanoxPublisher::Incentive do
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
let(:program) { ZanoxPublisher::Program.page.first }
let(:adspace) { ZanoxPublisher::AdSpace.pa... |
# frozen_string_literal: true
require 'generators/graphql/type_generator'
require 'generators/graphql/field_extractor'
module Graphql
module Generators
# Generate an object type by name,
# with the specified fields.
#
# ```
# rails g graphql:object PostType name:String!
# ```
#
# Add ... |
class ContactMailer < ApplicationMailer
def contact_me(msg, sender)
@msg = msg
@sender = sender
mail to: @msg.email, from: @sender.email, subject: @msg.subject, content: @msg.content
end
end
|
class Storyboard < ActiveRecord::Base
belongs_to :script
has_many :cells, :class_name=>"StoryboardCell"
end
|
class ChangeRevenueIdToCashRevenueId < ActiveRecord::Migration
def change
rename_column :transactions, :revenue_id, :cash_revenue_id
end
end
|
class FinderController < ApplicationController
def index
@customer = Customer.all
@page_title = 'All Customers'
end
def alphabetized
@page_title = 'Alphabetized Customers'
@customer = Customer.order(:fullname)
render:index
end
def missing_email
@page_title = 'Customers Missing Emai... |
=begin
#===============================================================================
Title: Command - Change Equip
Author: Hime
Date: Mar 31, 2013
--------------------------------------------------------------------------------
** Change log
Mar 31, 2013
- Initial release
------------------------------------... |
class BackupUpdateGenerator < Rails::Generator::Base
# This method gets initialized when the generator gets run.
# It will receive an array of arguments inside @args
def initialize(runtime_args, runtime_options = {})
super
end
# Processes the file generation/templating
# This will automatically be r... |
# frozen_string_literal: true
Rails.application.routes.draw do
root 'avatars#index'
devise_for :users, controllers: {
sessions: 'users/sessions',
passwords: 'users/passwords',
registrations: 'users/registrations'
}
resources :users, only: %i[index show] do
member do
get :following, :follo... |
require 'test_helper'
class TreeTest < ActiveSupport::TestCase
setup do
@tree = trees(:one)
end
describe "text_for_html_select_option method" do
it "gets the text part for the option" do
@tree.text_for_html_select_option.must_equal "Bay Laurel"
end
it "should not fail if the common name i... |
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
gem "multipart-post", "~> 1.1.4"
gem "progressbar"
gem "awesome_print"
gem "iostruct", ">= 0.0.4"
gem "zhexdump", ">= 0.0.2"
# Add dependencies to develop your gem here.
# Include everything ne... |
Rails.application.routes.draw do
post "/auth", to: "auth#create"
get "current_user", to: "auth#show"
resources :users
resources :parties
resources :maps
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
# frozen_string_literal: true
module ResponseHelper
##
# each_serializer is an optional paramter if you want to use custom serializer
#
def render_success(status:, data: nil, message: nil, serializer: nil, requested_by: 'vue')
serializer = "#{data.class.name}Serializer" if serializer.nil?
serialized_da... |
require 'line/bot'
class GhostController < ApplicationController
protect_from_forgery with: :null_session
def eat
render plain: "吃土"
end
def request_headers
render plain: request.headers.to_h
.reject{|key, value| key.include? '.'}
.map{|key, value| "#{key}: #{value}"}
.sort.join("\n... |
FactoryGirl.define do
factory :changes, class: Hash do
component {{
old: Faker::Lorem.word,
new: Faker::Lorem.word
}}
title {{
old: Faker::Lorem.word,
new: Faker::Lorem.word
}}
content {{
old: {
raw: Faker::Lorem.paragraph,
html: "<p>#{Faker::Lorem.par... |
ENV['RAILS_ENV'] ||= 'production'
require_relative 'config/environment'
require 'stackprof'
top_n = (ENV['TOP'] || 20).to_i
app = Rails.application
possible_routes = ['/posts', '/posts.json']
possible_routes.concat((1..100).map { |i| "/posts/#{i}"})
visit_count = 2000
rng = Random.new(0x1be52551fc152997)
visiting_ro... |
require 'spec_helper'
describe 'Show public talk', js: true do
let!(:user) { create(:user, :paul) }
let!(:talk) { create(:talk, users: [user], owner: user) }
let!(:another_talk) { create(:another_talk, users: [user], owner: user) }
let!(:spdeck_talk) { create(:speakerdeck_talk, users: [user], owner: user) }
... |
class Faculty < ApplicationRecord
has_many :responsibles
end
|
class ContactsController < ApplicationController
before_action :set_user
before_action :set_user_contact, only: [:show, :update, :destroy]
# GET /users/:user_id/contacts
def index
contact_search_data = contact_search_params
per_page = 10
if contact_search_data[:page].present? && contact_search_data... |
#!/usr/bin/env ruby
require_relative 'lib/run'
require 'open3'
# git merge-base --is-ancestor 6e78ca5b090d83b5ea331c9d58535e12b2d393f8 09e5765adbb945f3fc269f4d95a530fd7f03344f
# git merge-base --is-ancestor <expected older> <expected newer>
class GitCompareAge
def initialize(commit1, commit2)
@maybe_parent = c... |
module Api::V1
class BaseController < ActionController::Base
skip_before_action :verify_authenticity_token
rescue_from ActiveRecord::RecordNotFound, with: :not_found
protected
def not_found(exception)
render json: { errors: [exception.message] }, status: :not_found
end
end
end
|
require 'rails_helper'
feature 'Signatures by country and place' do
let!(:germany) { create :ghana, population: 100_000, has_confirmed_signatures: true }
let!(:ghana) { create :germany, has_confirmed_signatures: true }
let!(:confirmed_signature_de) { create(:c... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# user_id :string(255)
# created_at :datetime
# updated_at :datetime
#
class User < ActiveRecord::Base
has_many :listens, primary_key: :user_id
validates :user_id, uniqueness: true
scope :who_listened_to,... |
class Role < ActiveHash::Base
self.data = [
{:id => 1, :title => "Student"},
{:id => 2, :title => "Volunteer"}
]
VOLUNTEER_ROLE_IDS = [2]
def self.id_for(role)
find_by_title(role).id
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.