text stringlengths 10 2.61M |
|---|
class FontMigmix1m < Formula
version "20150712"
sha256 "ac91394f3687315fb2727f8ee2b8ef70c6801d0b674dfc991912400eb3e7a344"
url "https://osdn.dl.osdn.jp/mix-mplus-ipa/63544/migmix-1m-#{version}.zip"
desc "MigMix 1M"
homepage "https://mix-mplus-ipa.osdn.jp/migmix/#migmix1m"
def install
parent = File.dirnam... |
class MakeEventsUnique < ActiveRecord::Migration[5.1]
def change
add_index(:events, [:user_id, :category, :date], unique: true)
end
end
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
# This module is only used to check the environment is currently a testing env
module SpecHelper
end
# load variables from .env file
open('.env', 'r').readlines.each do |l|
kv = l.split('=')
ENV[kv[0]] = kv[1].chomp
end
require 'fastlane' # to import the... |
class Site < ApplicationRecord
serialize :content, Array
validates :url, presence: true, url: true
end
|
require 'json'
require 'aws-sdk-sqs'
require 'aws-sdk-s3'
require 'logger'
def s3processor(event:, context:)
logger.info("event #{event.to_json}")
response = s3_client.get_object({
bucket: event["Records"].first["s3"]["bucket"]["name"],
key: event["Records"].first["s3"]["object"]["key"],
})
logger.in... |
class AddPublishedToGuiders < ActiveRecord::Migration
def up
change_table :guiders do |t|
t.boolean :published, :default => false
end
Guider.update_all ["published = ?", false]
end
def down
remove_column :guiders, :published
end
end
|
# -*- encoding : utf-8 -*-
class ChangeTableNameOfProductsToProducts < ActiveRecord::Migration[5.1]
def change
rename_table :products_tables, :products
end
end
|
# frozen_string_literal: true
module Main
module Actions
module Home
class Subscribe < Action::Base
AuthorizationError = Class.new(StandardError)
config.handle_exception AuthorizationError => :handle_authorize
before :authorize
params do
required(:name).filled
... |
require 'rails_helper'
feature 'User system' do
describe "instructor" do
before(:each) do
@instructor = create(:instructor)
login_as(@instructor)
end
after(:each) do
Warden.test_reset!
end
scenario "can visit students page from root path" do
visit root_path... |
def xor? val1, val2
if (val1 && !val2) || (!val1 && val2)
return true
end
return false
end
puts xor?(5.even?, 4.even?) == true
puts xor?(5.odd?, 4.odd?) == true
puts xor?(5.odd?, 4.even?) == false
puts xor?(5.even?, 4.odd?) == false
# Second time, same same
# def xor?(num1, num2)
# return true if num1 && ... |
class AddNicesCountToSports < ActiveRecord::Migration[5.1]
def change
add_column :sports, :nices_count, :integer
end
end
|
# @param {String} s
# @param {String} t
# @return {Boolean}
def is_anagram(s, t)
@pos_sum = s.split("").inject(Hash.new(0)) {|hash, e| hash[e] += 1; hash}.to_a.sort
@pos_sum2 = t.split("").inject(Hash.new(0)) {|hash, e| hash[e] += 1; hash}.to_a.sort
@pos_sum == @pos_sum2
end
|
module Nokogiri
module XML
class DocumentFragment < Node
def name
'#document-fragment'
end
end
end
end
|
class WikiHistory < ActiveRecord::Base
paginates_per 10
belongs_to :user
belongs_to :sort
end |
class AddEnableSectionsToUsers < ActiveRecord::Migration
def change
add_column :users, :enable_about_section, :boolean, :default => true
add_column :users, :enable_education_section, :boolean, :default => true
add_column :users, :enable_experience_section, :boolean, :default => true
add_column :users,... |
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
ENV['RAILS_ENV'] ||= 'test'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
def is_logged_in?
!session[:user_id].nil?
end
# Log in as a p... |
class ApartmentPopulator
def initialize(apt_search_data = AptSearch.new.scrape_apartment_data)
@apartment_data = apt_search_data
end
def perform
PageResponseIterator.iterate(@apartment_data)
ApartmentUpdater.update_distances
end
end
# ApartmentPopulator.new(AptSearch.new.get_apartment_data_from_raw_html(h... |
module CloudappExport
class Item
attr_reader :attributes
def initialize(attributes)
@attributes = attributes
end
def [](key)
@attributes[key]
end
def name
@attributes['name']
end
def filename
ext = @attributes['name'].split('.').last
"#{@attributes['sl... |
class Network < ApplicationRecord
include Ownable
include Documentable
multisearchable(
against: [:name, :address, :gateway, :vlan_id],
additional_attributes: ->(record) { { label: record.name } },
)
pg_search_scope(
:search,
against: [:name, :address, :gateway, :vlan_id],
using: {
... |
# Start a new application
corneal new blog_app
bundle install
# Run through the routes for post in README
# | HTTP Verb | Route | Action |
# | GET | /posts | index |
# | GET | /posts/:id | show |
# | GET | /posts/new | new |
# | POST | /posts ... |
class Admin::BaseController < ApplicationController
before_filter :authorize_admin
protected
def authorize_admin
unless current_user.admin?
flash[:alert] = "You must be an authorized admin."
redirect_to "/"
end
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 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... |
Rails.application.routes.draw do
get 'attendance/new'
get 'attendance/index'
get 'users/show'
root 'events#index'
get 'static_pages/index'
devise_for :users
resources :users, only: [:show]
resources :events
resources :charges
resources :attendances
get 'events/subscribe/:id', to: 'events#subscribe... |
module Resource
class HandlesController < ApplicationController
skip_before_action :verify_authenticity_token, only: [:create]
def show
handle_file
end
def create
handle_file
end
private
#ueditor的配置
def handle_file
uditor_action = request.fullpath.to_s.split('act... |
require 'spec_helper'
require_relative '../support/test_data_hash'
require_relative '../support/two_decimals'
feature 'Bill Features' do
let(:test_data_hash){ TestDataHash.data }
include TwoDecimals
context 'when on bill page' do
before :each do
allow(GetBillData).to receive(:call).and_return(test_dat... |
require_relative 'piece'
class Pawn < Piece
#Pawn is inheriting
#@color = symbol
#reference to @board
#@pos ----------
#Pawn.new(color, board, pos)
#to_s
#empty?
#valid_moves
#pos=(val)
#symbol
# private -> move_into_check?(end_pos)
def symbol #what we're referring to ... |
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = "https://www.theofilosvenardos.com"
SitemapGenerator::Sitemap.compress = false
SitemapGenerator::Sitemap.create do
# Put links creation logic here.
#
# The root path '/' and sitemap index file are added automatically for you.
# Link... |
# A serializer for {WrappedError} objects.
class SimpleJsonapi::Errors::WrappedErrorSerializer < SimpleJsonapi::ErrorSerializer
id(if: ->(err) { err.id.to_s.present? }) do |err|
err.id.to_s.presence
end
status(if: ->(err) { err.status.to_s.present? }) do |err|
err.status.to_s.presence
end
code(if: -... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
#require '../lib/omniauth-etrade/version'
require File.expand_path('../lib/omniauth-etrade/version', __FILE__)
Gem::Specification.new do |spec|
spec.name = "omniauth-etrade"
spec.version ... |
class AddPanToPeople < ActiveRecord::Migration[5.0]
def change
add_column :profiles, :pan_no, :string
add_column :profiles, :regi_no, :string
add_column :profiles, :estd, :date
end
end
|
require_dependency "event_calendar/application_controller"
module EventCalendar
module Susanoo
class GenresController < EventCalendar::ApplicationController
before_action :enable_engine_required
before_action :set_divisions_and_sections, only: %i(new)
# GET /event_calendar/susanoo/genres/new
... |
class GuestSessionsController < ApplicationController
def create
user = User.find_by(email: 'test@example.com')
log_in(user)
flash[:success] = 'ゲストユーザーでログインしました'
redirect_to posts_path(user)
end
end
|
class Resource < ActiveRecord::Base
validates :name, :resource_type, :unit, :space, :presence => true
validates :value, :min, :max, :numericality => true
belongs_to :resource_type
belongs_to :space
belongs_to :unit
after_create :fill_system_name
private
def fill_system_name
self.system_name = (s... |
authorization do
role :admin do
has_permission_on [:fee_imports],
:to => [
:import_fees,
:select_student,
:list_students_by_batch,
:list_fees_for_student
]
end
role :manage_fee do
has_permission_on [:fee_imports],
:to => [
:import_fees,
:select_student... |
json.array!(@agencies) do |agency|
json.extract! agency, :id, :restrictions, :hours_of_operation, :address_id, :contact_name, :contact_phone, :contact_email, :services, :geographic_restrictions, :family_stipulations, :faith_based, :is_active, :general_information
json.url agency_url(agency, format: :json)
end
|
class Api::V1::UomsController < Api::V1::BaseApiController
def index
uoms = Common::UnitOfMeasure.all
uom_serializer = Common::UomSerializer.new(uoms).serialized_json
render json: uom_serializer
end
end
|
class CreateGothrams < ActiveRecord::Migration
def change
create_table :gothrams do |t|
t.string :gothram_name
t.timestamps null: false
end
end
end
|
require "spec_helper"
describe EstimateMailer do
before(:each) do
# @user = create(:user)
client = create(:client, users_attributes: [attributes_for(:user)])
@user = client.users.first
@estimate = create(:estimate, client_id: @user.client_id, send_to_contact: @user.id)
@new_pw= @user.generate_valid_... |
class Build < ActiveRecord::Base
attr_reader :shell
attr_accessor :source_control
validates_presence_of :plan_id
serialize :parameters, Hash
delegate :name, :repository_url, :requirements, :needed_resources, :project, :to => :plan
belongs_to :plan
belongs_to :slave
belongs_to :starter, :class_na... |
#
# Cookbook Name:: openresty
# Recipe:: default
#
# Copyright 2016, tashinfrus
#
# All rights reserved - Do Not Redistribute
#
openresty_install_dir=node[:openresty][:install_dir]
execute 'openresty_package_download' do
command 'wget http://openresty.org/download/ngx_openresty-1.5.8.1.tar.gz'
cwd '/opt/'
not_if... |
require 'date'
module GHI
module Commands
class List < Command
attr_accessor :web
attr_accessor :reverse
attr_accessor :quiet
attr_accessor :exclude_pull_requests
attr_accessor :pull_requests_only
def options
OptionParser.new do |opts|
opts.banner = 'usage: ... |
class ArticelsController < ApplicationController
before_action :set_articel, only: [:show, :edit, :update, :destroy]
def index
@articels = Articel.all
end
def show
end
def new
@articel = Articel.new
end
def create
@articel = Articel.new(articel_params)
@articel.save
redirect_to @a... |
class MemosController < ApplicationController
def self.view_num
10
end
def view
memo_list
render_list
end
def create
memo = Memo.new
memo.content = params[:content]
memo.person_id = params[:id]
memo.color = "#ffffff"
if params[:template].to_i != 0
memo.template = Templ... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :housephone
t.string :mobilephone
t.string :address
t.string :photo
t.references :profile
t.timestamps
end
add_index :users, :profile_i... |
class ApiConnectionService
attr_reader :user_params
BASE_URL = APPCONFIG["api"]["base_url"]
def initialize(user_params)
@user_params = user_params
end
def connect
begin
Faraday.new(url: BASE_URL, headers: headers) do |faraday|
faraday.basic_auth(*user_params.values)
faraday.re... |
class Message < ApplicationRecord
belongs_to :user
belongs_to :group
validates :body, presence: true
mount_uploader :image, ImageUploader
def json_data
name = self.user.name
time = self.created_at.strftime ('%Y年%m月%d日 %H:%M:%S')
message_data = [self, name, time]
end
end
|
require "rails_helper"
describe "Viewing a list of vegetables" do
it "shows the vegetables for a specific plantation" do
plantation1 = Plantation.create!(name: "Plantation 1")
vegetable1 = plantation1.vegetables.create!(vegetable_attributes(name: "Cabbage"))
vegetable2 = plantation1.vegetables.create!(ve... |
require 'test_helper'
class HairsControllerTest < ActionController::TestCase
setup do
@hair = hairs(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:hairs)
end
test "should get new" do
get :new
assert_response :success
end
test "s... |
class V1::ProjectsController < ApplicationController
before_action :require_login
before_action :set_company_project , except: [:index , :create ]
def index
projects = Project.order('created_at DESC');
if projects != []
render json: {status: 'SUCCESS', message:'Loaded projects', data:pr... |
=begin
What is the most asked question on CodeWars?
Can someone explain /*...*/?
You need to write a function detect that will check if a string starts with Can someone explain, case sensitive. Return true if so, false otherwise.
Let's hope you don't write a solution that makes people ask that question at you!
=end
... |
class Doha < Formula
# Update these values as needed as new versions are released
current_version="1.0.16"
# current_release="20190115004751"
# current_sha256="3207e4369795f13b80088210ddfdb679be45351e1c70e5e872d0830c12fd6a76"
# Installing "openssl" ensures there's a certificate chain at
# `/usr/local/etc/o... |
require_relative "fetchable"
require_relative "safe_insertable"
module Crawler
module Models
class Like < ActiveRecord::Base
#Fetch method returns an array of Like models with user_profile_id
# set to vk_id of UserProfile
extend Fetchable
fetcher :likes_getList, [:item_id, :owner_id], Map... |
require './test_helper.rb'
class TestBlackJack < MiniTest::Unit::TestCase
def setup
@register = BlackJack.new
end
def test_
assert_equal true, @register.twenty_one?(3, 4, 5, 6, 3)
assert_equal false, @register.twenty_one?(3, 11, 10)
assert_equal true, @register.twenty_one?(10, 11)
end
end
|
class App < ApplicationRecord
mount_uploader :image
validates :title, presence: true
end
|
class CreatePrefectureregions < ActiveRecord::Migration
def change
create_table :prefectureregions do |t|
t.string :name , limit: 6 , null: false
end
end
end
|
# frozen_string_literal: true
require 'sidekiq'
module VBADocuments
class RunUnsuccessfulSubmissions
include Sidekiq::Worker
def perform
guids = VBADocuments::UploadSubmission.where(status: 'uploaded').pluck(:guid)
guids.each { |guid| VBADocuments::UploadProcessor.perform_async(guid) }
end
... |
Pod::Spec.new do |s|
s.name = 'NPModalPanView'
s.version = '0.0.1'
s.summary = '拖拽view'
s.description = <<-DESC
上下拖拽的view
DESC
s.homepage = 'https://github.com/iyongjie/NPModalPanView'
s.license = { :type => 'MIT'... |
require 'rails_helper'
RSpec.describe "Sessions", type: :request do
describe "GET /new" do
before do
get login_path
end
it "returns http success" do
expect(response).to have_http_status(:success)
end
it "login name test" do
expect(response.body).to include "ログイン"
end
... |
# # Mailer to send to partners of an organization a reminder about the deadline date.
class ReminderDeadlineMailer < ApplicationMailer
def notify_deadline(partner, organization)
@partner = partner
@organization = organization
mail(from: @organization.from_email, to: @partner.email, subject: "#{@organizati... |
class AddCamposToTiposmascostas < ActiveRecord::Migration
def change
add_column :tiposmascotas, :nombre, :string
end
end
|
class WheelCounter
def initialize(vehicles)
@vehicles = vehicles
end
def count_wheels
total_wheels = 0
@vehicles.each do | vh |
total_wheels += vh.wheels
end
puts total_wheels
end
end
|
class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :email
t.string :uid
t.timestamps
t.index :email, unique: true, where: "email IS NOT NULL"
t.index :uid, unique: true, where: "uid IS NOT NULL"
end
# Affected tables
tables = ... |
require "spec_helper"
require "solr/server"
describe "Supernova::Solr::Server" do
let(:url) { "http://path.to.solr:112" }
let(:core_name) { "core_name" }
let(:server) { Supernova::Solr::Server.new(url) }
let(:body) { "{\"responseHeader\":{\"status\":0,\"QTime\":3}}" }
describe "#initialize" do
it "ca... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :section_base, class: Section do
sequence(:code){|n|"code#{n}"}
sequence(:name){|n|"test#{n}"}
sequence(:place_code){|n|"code#{n}"}
sequence(:number){|n|n}
sequence(:ftp){|n|"/contents/test#{n}"}
... |
# frozen_string_literal: true
class AddBombingCauseOfDeath < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def change
execute <<-SQL
ALTER TYPE cause_of_death ADD VALUE 'bombing';
SQL
end
end
|
require "rails_helper"
describe "Deleting a fruit" do
it "destroys the fruit and shows the fruit listing without the delete plantation" do
plantation = Plantation.create!(plantation_attributes)
fruit = plantation.fruits.create!(fruit_attributes)
visit plantation_fruit_path(plantation, fruit)
... |
require 'sinatra'
require 'haml'
require 'sinatra/session'
require './helpers/view_helpers'
#require './models/player'
require './lib/game'
require './models/action'
require "pry"
Dir['./lib/*.rb'].each { |file| require file }
set :session_secret, 'So0perSeKr3t!'
set :database, "postgres://kitaka@localhost/spike"
ge... |
class WorkoutsController < ApplicationController
before_filter :require_user, :only => [ :show, :new, :index ]
before_filter :setdates
def show
@daily_workouts = @current_user.workouts.find :all, :conditions => [ "workout_date = ? and plan_type = ?",
@show_date, 'a' ]
@dates = get_highlight_dates
... |
module Clockface
class EventValidationInteractor
include Interactor
after { context.fail! if context.errors.any? }
def call
context.errors = []
handle_invalid_model unless model_valid?
handle_duplicate_event if duplicate_event?
end
private
def model_valid?
context.... |
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module TeatroSantanderRooftop
class Application < Rails::Application
# Use the responders controller from the responders g... |
class Profile < ApplicationRecord
belongs_to :user
validates :bio, :goals, :interests, :born_on, presence: true
validates :bio, :goals, :interests, length: {maximum: 700}
validates_datetime :born_on, date: true
validates :born_on, date: { before: DateTime.now }
def age
today = Date.today
d = Date... |
class Question < ApplicationRecord
# Associations
belongs_to :category
has_many :answers
# --------------------
# Validations
validates :qn_text, presence: { message: "Please enter question."}
validates :category_id, presence: { message: "Please choose category."}
# --------------------
def self.s... |
module MangoPayV1
# A payment card.
class Card < MangoPayV1::Ressource
# Create a payment card
#
# * *Args* :
# - +data+ -> A JSON with the following attributes (Square brackets for optionals):
# * [Tag]
# * OwnerID
# * ReturnURL
# ... |
class UserCompany < ActiveRecord::Base
belongs_to :user
belongs_to :company
validates_uniqueness_of :user, scope: :company_id
end
|
class Deck
def self.all_cards
[].tap do |deck|
Card.ranks.each do |rank|
Card.suits.each do |suit|
deck << Card.new(rank, suit)
end
end
end
end
attr_reader :cards
def dup
Deck.new(cards.map(&:dup), false)
end
def choose(n)
@cards.combination(n)
... |
module SheetSync
class ReviewRowFinder
attr_reader :worksheet
def initialize(worksheet)
@worksheet = worksheet
end
def find(tweet_review)
worksheet.each_row do |row|
return row if includes_tweet_review?(tweet_review, row)
end
nil
end
private
def includes... |
class SysJobLog < ActiveRecord::Base
validates_presence_of :sys_job_name
end
|
require "test_helper"
class AnimalsControllerTest < ActionDispatch::IntegrationTest
setup do
@animal = animals(:one)
end
test "should get index" do
get animals_url, as: :json
assert_response :success
end
test "should create animal" do
assert_difference("Animal.count") do
post animals_... |
class Queue
attr_accessor :front, :back
class Node
attr_accessor :data, :next_node
def initialize(data)
self.data = data
@next_node = nil
end
end
def initialize()
@front = nil
@back = nil
end
def empty?
@back.nil?
end
def enqueue(data)
node = Node.new(data)... |
require "byebug"
class PolyTreeNode
attr_accessor :children, :parent, :value
def inspect
"value:#{@value} parent:#{@parent} children:#{@children}"
end
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent=(node)
if self.parent
self.parent.children.... |
# frozen_string_literal: true
namespace :v2 do
desc "Task to call from the scheduler every hour"
task every_hour: %i[download_all ingest_all cache_all]
end
|
class AddLogoUrlToProfileDescription < ActiveRecord::Migration
def change
add_column :profile_descriptions, :logo_url, :string
end
end
|
require 'spec_helper'
describe "quotes/new.html.erb" do
before(:each) do
assign(:quote, stub_model(Quote,
:service_id => 1,
:page => "MyString",
:line_1 => "MyString",
:line_2 => "MyString",
:line_3 => "MyString",
:author => "MyString",
:line_count => 1
).as_new_reco... |
# Shows you how to minimally implement the ActiveModel::Validator
# API into a custom model
class HasNameValidator < ActiveModel::Validator
def validate(record)
record.errors[:name] = "Must have name" if record.name.blank?
end
end
|
class BulkDiscountsController < ApplicationController
before_action :fetch_current_bulk_discount, only: [:edit, :show]
before_action :fetch_current_merchant
def index
@upcoming_holidays = HolidayFacade.upcoming_holidays
end
def new
@new_bulk_discount = BulkDiscount.new
end
def create
bulk_d... |
require 'rails_helper'
RSpec.feature 'Sign Up', type: :feature do
background do
Capybara.current_driver = :selenium_chrome_headless
end
scenario 'normal sign up' do
sign_up('tester', 'test@gmail.com', 'testtest', 'testtest')
expect(current_path).to eq root_path
end
scenario 'informat email' do
... |
require 'test_helper'
class CoversationsControllerTest < ActionController::TestCase
setup do
@coversation = coversations(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:coversations)
end
test "should get new" do
get :new
assert_respon... |
require 'spec_helper'
require 'shared_examples'
describe "GET /request_data" do
let(:url) {'http://www.example.com/feed.rss'}
context "The request is not stored" do
before(:each) do
REDIS.stub(:hgetall).with(url).and_return({})
end
it_should_behave_like "a successful request", '/request_data?u... |
# == Schema Information
#
# Table name: carts
#
# id :integer not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# purchased_at :datetime
#
class Cart < ActiveRecord::Base
has_many :line_items, dependent: :destroy
# has_one :line_item, d... |
require 'spec_helper'
module Naf
describe ApplicationRunGroupRestriction do
# Mass-assignment
[:application_run_group_restriction_name].each do |a|
it { should allow_mass_assignment_of(a) }
end
[:id,
:created_at].each do |a|
it { should_not allow_mass_assignment_of(a) }
end
... |
class Student < ApplicationRecord
has_and_belongs_to_many :courses
has_and_belongs_to_many :groups
def self.import(file)
all_students = []
Student.all.each do |student|
all_students.push(student.username)
end
all_courses= {}
Course.all.each do |course|
all_courses[course.name] =... |
class CarsController < ApplicationController
before_action :current_user_must_be_car_user,
only: %i[edit update destroy]
before_action :set_car, only: %i[show edit update destroy]
def index
@q = Car.ransack(params[:q])
@cars = @q.result(distinct: true).includes(:user,
... |
class Admin::TreeTypesController < Admin::AdminController
before_filter :set_menu
def index
if params[:tree_type_id] && params[:tree_type_id].to_i > 0
@tree_types = TreeType.where(:id => params[:tree_type_id]).paginate(:page => params[:page], :per_page => 50)
else
@tree_types = TreeType.order(... |
require_relative 'recipe'
class Pantry
attr_reader :stock, :shopping_list, :cookbook
def initialize
@stock = {}
@shopping_list = {}
@cookbook = {}
end
def stock_check(item)
if stock[item].nil?
0
else
stock[item]
end
end
def restock(item, quantity)
if stock[item].n... |
# Player.rb
#
# Copyright 2015 Kmar <kmar@kmar-Kubuntu>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
... |
RSpec.describe Web::Views::Goals::New, type: :view do
let(:message) { 'Title must be filled' }
let(:params) { OpenStruct.new(valid?: false, error_messages: [message]) }
let(:exposures) { Hash[params: params] }
let(:template) { Hanami::View::Template.new('apps/web/templates/goals/new.html.erb') }
let(:vi... |
class ApplicationController < ActionController::Base
skip_before_action :verify_authenticity_token, if: Proc.new { |c| c.request.format == 'application/json' }
def render_json_error(status:, message:)
render json: { error: message }, status: status
end
end
|
class Role
include Mongoid::Document
include Mongoid::Timestamps
store_in database: 'sribulancer_development', collection: 'roles'
field :name
embeds_many :role_rules
end
|
class Api::V1::RoadTripController < ApplicationController
before_action :authenticate
def create
road_trip = RoadTripFacade.new(road_trip_info)
road_trip_response = RoadTripSerializer.new(road_trip)
render json: road_trip_response
end
private
def authenticate
user = User.find_by(api_key: pa... |
namespace :summary do
desc "Send a summary email"
task :email, [:user_id] => [:environment] do |t, args|
User.all.each do |user|
p "Making results for user #{user.profiles.first.fullname}"
monitors = user.search_monitors
ids = []
monitors.each do |e|
ids += e.results.map {|e| e.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.