text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require 'rails_helper'
describe 'Merchant Items API' do
before :each do
@merchant1 = create(:merchant)
@item1 = create(:item, merchant: @merchant1)
@item2 = create(:item, merchant: @merchant1)
@item3 = create(:item, merchant: @merchant1)
@item4 = create(:item, merc... |
class ChangeGradePointType < ActiveRecord::Migration
def self.up
change_column :assessment_scores, :grade_points, :float
end
def self.down
end
end
|
require 'redmine'
require_dependency 'watchers_textinput/hooks'
Redmine::Plugin.register :watchers_textinput do
name 'Watchers Textinput plugin'
author 'Alvin Chow'
description 'Redmine plugin to convert watchers checkboxes to more compact autocomplete text field'
version '0.1.0'
url 'http://example.com/path... |
class Recipe
attr_reader :name, :ingredients
def initialize(name)
@name = name
@ingredients = {}
end
def add_ingredient(name, quantity)
@ingredients[name] = quantity
end
def quantity_needed(name)
@ingredients[name]
end
def total_calories
@ingredients.sum do |ingredient, quantity|... |
#! /usr/bin/env ruby
@input = STDIN.read.chomp.split('')
def move_to(direction, coordinates)
case direction
when '^'
coordinates[0] = coordinates[0] + 1
when 'v'
coordinates[0] = coordinates[0] - 1
when '>'
coordinates[1] = coordinates[1] + 1
when '<'
coordinates[1] = coordinates[1] - 1
en... |
require "word_count"
describe String, "#word_count" do
it "should return 1 when the string is one word long" do
a_string = "apple"
the_word_count = a_string.word_count
the_word_count.should equal(1)
end
it "should return 0 when the string is empty" do
a_string = ""
the_word_count = a_string.... |
class HashtagsController < ApplicationController
before_filter :find_user, only: [:destroy]
before_filter :authorize_user, only: [:destroy]
before_filter :fetch_top_users_and_tags, only: :search
def find_user
@user = User.find_by_auth_token(cookies[:auth_token])
end
def authorize_user
unless @us... |
module ApplicationHelper
def notice_message
flash_messages = []
flash.each do |type, message|
type = :success if type.to_s == "notice"
type = :warning if type.to_s == "alert"
type = :danger if type.to_s == "error"
text = content_tag(:div, link_to("×", "#", class: "close"... |
# frozen_string_literal: true
class Ability
include CanCan::Ability
def initialize(user)
if user.bo_role == 'sales'
end
if user.coach
can :create, Coach, :user_id => user.id
can :manage, Company, :id => user.coach.company_id
end
if user.bo_role == 'root'
can :manage, :all
elsif user.role == 'comp... |
class MorePhysicalTherapyMods < ActiveRecord::Migration
def self.up
add_column :patient_interactions, :range_of_motion, :boolean
add_column :patient_interactions, :ambulation, :boolean
end
def self.down
remove_column :patient_interactions, :ambulation
remove_column :patient_interactions, :range_o... |
# frozen_string_literal: true
require_dependency 'vba_documents/application_controller'
require_dependency 'vba_documents/upload_error'
module VBADocuments
module V0
class UploadsController < ApplicationController
skip_before_action(:authenticate)
def create
submission = VBADocuments::Uploa... |
class Category < ActiveRecord::Base
has_many :products
validates :name, length: { minimum: 1, maximum: 50 }
end
|
class AssessmentPlansController < ApplicationController
before_filter :login_required
filter_access_to :all
require 'lib/override_errors'
helper OverrideErrors
in_place_edit_with_validation_for :assessment_term, :name
in_place_edit_with_validation_for :assessment_plan, :name
before_filter :find_academi... |
class IngredientsController < ApplicationController
def index
ingredients = Ingredient.all
render json: ingredients
end
def create
# sandwich = Sandwich.find_by(:id => params[:sandwich_id])
my_sandwich = Sandwich.find_by(id: params[:sandwich_id])
my_ingredients = my_sandwich.ingredients.create(ingredient... |
require 'fileutils'
class TeamExporter
def initialize(path, uri_root_for_logo)
self.path = path
self.uri_root_for_logo = uri_root_for_logo
end
def export(team)
FileUtils.mkdir_p(path)
name_file { |f| f << team.name }
copy_logo(team.logo_path)
score_file { |f| f << team.score }
lead_j... |
def combine_anagrams(words)
output = {}
words.each do |word|
if output[sort_word word].nil?
output[sort_word word] = [ word ]
else
output[sort_word word] << word
end
end
output.values
end
def sort_word(word)
word.downcase.chars.sort.join
end
|
require 'spec_helper'
describe PageDesc::Page do
before do
class TestPage < Page
url 'the url'
end
end
it 'has a url' do
TestPage.new(:session).url.should == 'the url'
end
it 'is sets the elements session' do
TestPage.new(:session).instance_variable_get(:@main_element).instance_variab... |
module Naf
class LoggerLevel < NafBase
# Protect from mass-assignment issue
attr_accessible :level
#---------------------
# *** Associations ***
#+++++++++++++++++++++
has_many :logger_style_names,
class_name: '::Naf::LoggerStyleName'
#--------------------
# *** Validations **... |
require_relative '../entry_collection'
RSpec.describe Parser::EntryCollection do
it 'creates an entry_collection class' do
testIO = StringIO.new
entry_collection = Parser::EntryCollection.new(testIO)
expect(entry_collection).to be_kind_of(Parser::EntryCollection)
end
it 'returns correct number of ro... |
# frozen_string_literal: true
class GamePolicy < ApplicationPolicy
attr_reader :user, :record
def destroy?
return true if (user.id == record.player_left.id || user.id == record.player_right.id) && record.status == 'pending'
false
end
end
|
require 'spec_helper'
describe Member do
describe 'methods' do
let(:member) { new_member }
let(:no_name_member) { FactoryBot.create(:member, name: nil) }
let(:no_identity_member) { FactoryBot.create(:member, name: nil, nickname: nil) }
let(:challenge) { FactoryBot.create(:challenge) }
describe '... |
class Order < ActiveRecord::Base
include PublicActivity::Model
tracked owner: ->(controller, model) {controller && controller.current_user}
has_many :items
belongs_to :user
def subtotal
self.items.inject(0) { |sum, x| sum + x.price }
end
end
|
class Api::V1::ItemsController < Api::V1::BaseApiController
before_action :set_task, only: [:create, :destroy]
before_action :set_item, only: [:destroy]
def index
batch = Cultivation::Batch.find(params[:batch_id])
raw_materials = Inventory::Catalogue.raw_materials.where(facility_id: batch.facility_id)
... |
include UserHelpers
feature "User sign up" do
let(:user) { FactoryGirl.build(:user) }
scenario "I can sign up as a new user" do
expect { sign_up(user) }.to change(User, :count).by(1)
expect(page).to have_content ("Welcome, #{user.email}")
expect(User.first.email).to eq(user.email)
end
scenario "with a pas... |
require 'belafonte/errors'
require 'optionally/required'
module Belafonte
# Processes command line arguments
class ArgumentProcessor
include Optionally::Required
def initialize(options = {})
check_required_options(options, :argv, :arguments)
@argv = options[:argv]
@arguments = options[:... |
require 'test_helper'
class CartTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "add only one line_item for each product" do
cart = Cart.create
product = Product.create(title: "My Book Title",
description: "yyy",
price: 1,
image_url: ... |
module BaccaratStrategies
def underdog_Nx(game)
s = game.simulation
g = game
if s.position_on_a_run
g.bet_position = s.position_on_a_run
g.bet_amount = s.unit_cost
elsif s.current_underdog
ud = s.current_underdog
puts "betting underdog #{s.unit_cost} on #{... |
class Account < ActiveRecord::Base
has_many :agents
scope :with_agent_count, -> {
select('accounts.*, count(agents.id) AS agent_count').
joins(:agents).group(:id)
}
def agent_count
if count = read_attribute('agent_count')
count.to_i
else
agents.length
end
end
end
|
class Card
attr_reader :value, :symbol
def initialize(value, symbol)
@value = value
@symbol = symbol
end
end
|
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'seqtrimbb/version'
Gem::Specification.new do |spec|
spec.name = "seqtrimbb"
spec.version = Seqtrimbb::VERSION
spec.authors = ["Rafael Nuñez", "Dario Guerrero"]
spec.... |
require 'rails_helper'
RSpec.describe Recipe do
describe 'validations' do
let(:category) { FactoryBot.create(:category) }
let(:recipe) { FactoryBot.create(:recipe, category: category) }
it 'validates name' do
recipe.name = ''
recipe.unit_price = ''
expect(recipe).to_not be_valid
... |
require 'test_helper'
class StudentTest < ActiveSupport::TestCase
def setup
@student = students(:one)
end
test "class exists" do
assert @student.valid?
end
test "invalid without name" do
@student.name = nil
refute @student.valid?
assert_not_nil @student.errors[:name]
end
test "inv... |
# cups commandline lpstat,lpoptions
# and snmp based printer classes
require 'rexml/document'
require 'open3'
class PrinterJob
attr_reader :id, :size, :user, :printer, :time
def initialize(id, user, size, time, printer)
@id = id
@size = size
@user = user
@time = time
@printer ... |
mysql_user = attribute('mysqlUser', default: 'mysql', description: 'Name of mysql User')
mysql_password = attribute('mysqlPassword', default: 'root', description: 'Password of mysql User')
mysql_ipAddress = attribute('mysqlAddress', default: '127.0.0.1', description: 'Ip address of mysql')
control "mysql--log-erro... |
module ApplicationHelper
def parent_layout(layout)
layout = layout.to_s
layout = "layouts/#{layout}" unless layout.include?('/')
@view_flow.set(:layout, output_buffer)
output = render file: layout
self.output_buffer = ActionView::OutputBuffer.new(output)
end
def modal_for(id, modal_title ... |
# frozen_string_literal: true
class ApplicationController < ActionController::Base
before_action :set_turbolinks_header
protect_from_forgery with: :exception
helper_method :current_cart
def set_turbolinks_header
response.set_header('Turbolinks-Location', request.fullpath)
end
def current_cart
@ca... |
#!/usr/bin/env ruby
require 'gnomecanvas2'
class Point
attr_accessor :x, :y
def initialize(x, y)
@x = x
@y = y
end
def to_a
[@x, @y]
end
def -(p)
Point.new(@x - p.x, @y - p.y)
end
end
class Caixa < Gtk::VBox
def initialize
super
@offset = 10
@canvas = Gnome::Canvas.... |
require 'rails_helper'
RSpec.describe Order, :type => :model do
it { should belong_to :user }
it { should belong_to :credit_card }
it { should have_many :order_items }
it { should validate_presence_of :order_status }
end
|
class Incident < ActiveRecord::Base
has_many :behaviors
belongs_to :student
end
|
class WallbaseProfilesController < ApplicationController
before_filter :require_admin
def new
@profile = WallbaseProfile.new wallbase_style_type_id: params[:id]
end
def edit
@profile = WallbaseProfile.find params[:id]
end
def create
@profile = WallbaseProfile.new(wallbase_profile_params)
... |
require 'tmpdir'
module StartupsByCity
module DataFile
class << self
def get_path(method)
`mkdir -p #{File.join(BASE_PATH, 'data')}`
data_file = Dir[File.join(BASE_PATH, 'data', 'crunchbase_*.csv')].last
if method == :download || !data_file
fetch
elsif method == :... |
require "spec_helper"
describe Bibliovore::Title do
before :each do
@data = JSON.parse(TITLE_RESPONSE)
@title = Bibliovore::Title.new(@data, @client)
end
describe "#id" do
it "returns the correct id" do
@title.id.should eq '12345678901234'
end
end
describe "#title" do
it "returns ... |
class SkuFactory
attr_reader :type, :featured_x, :featured_y
attr_accessor :x, :y, :z, :state, :name, :shop_quantity, :bankrupt, :already_purchased
def initialize(args)
@name = args[:name]
@image = Gosu::Image.new(args[:window], "img/store/#{args[:image_link]}")
@window = args[:window]
@original... |
Rails.application.routes.draw do
get '/', to: 'static_page#home'
get '/contact', to: 'static_page#contact'
get '/news', to: 'static_page#news'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.0'
gem 'rails', '~> 5.2.3'
#==================================================
# RAILS CORE
#==================================================
gem 'bootsnap', '>= 1.1.0', require: false
gem 'pg', '>= 0.18', '< 2.... |
require 'rjb'
require 'securerandom'
# http://github.com/itext/itextpdf/releases/latest
EXT_PATH = File.expand_path('../ext', __dir__)
Rjb::load("#{File.join(EXT_PATH, 'itextpdf-5.5.9.jar')}:" \
"#{File.join(EXT_PATH, 'bcprov-jdk15on-156.jar')}:" \
"#{File.join(EXT_PATH, 'bcpkix-jdk15on-156.jar')}"... |
require 'rails_helper'
RSpec.describe "offices/new", type: :view do
before(:each) do
assign(:office, Office.new(
:company => nil,
:user => nil,
:nombre => "MyText",
:calle_numero => "MyText",
:colonia => "MyText",
:codigo_postal => 1,
:latitud => "MyString",
:longi... |
require 'securerandom'
module DrillSergeant
class App < Padrino::Application
register Padrino::Mailer
register Padrino::Helpers
register Padrino::WebSockets
enable :sessions
##
# Caching support.
#
# register Padrino::Cache
# enable :caching
#
# You can customize... |
class SensorsController < ApplicationController
before_action :authenticate_admin!
before_action :set_sensor, only: [:show, :edit, :update, :destroy]
# GET /sensors
# GET /sensors.json
def index
@sensors = Sensor.order(created_at: :desc).all
end
def assigned
@sensors = Sensor.order(created_at: :d... |
module CloudPrint
class PrintJob
STATUSES = %w{QUEUED IN_PROGRESS DONE ERROR SUBMITTED}
def initialize(data)
@data = data
end
def refresh!
@data = Util.normalize_response_data(self.class.find_by_id(id))
self
end
def delete!
response = CloudPrint.connection.get('/dele... |
class DbGroup < ActiveRecord::Base
# Relations
has_and_belongs_to_many :databases
Reusable.has_many_translations(self)
# Sort order (":order => 'name ASC'" is depreciated); 'ASC' is default
default_scope { includes("db_group_#{I18n.locale.to_s}").order("db_group_#{I18n.locale.to_s}s.name") }
def translate... |
require 'rails_helper'
describe "Items BI API" do
describe "Item class" do
it '.most_revenue' do
item_1 = create(:item, id: 4)
item_2 = create(:item, id: 5)
item_3 = create(:item, id: 6)
merchant = create(:merchant)
customer = create(:customer)
invoice = create(:invoice, mer... |
module V1::User::AnsSubmission
extend ActiveSupport::Concern
def submit
find_ans
mail_failure if @sta == :error
render json: { status: :success }
end
private
def find_ans
@anss = current_user.current_answering
@answer = @anss.answers.find_or_create_by(ans_params)
update_ans if @answ... |
class Cart < ApplicationRecord
belongs_to :product
belongs_to :customer
end |
class SaveUser
prepend SimpleCommand
attr_reader :args
def initialize(args = {}, current_user)
@args = args
@current_user = current_user
end
def call
if args[:id].present?
user = User.find(args[:id])
user.email = args[:email]
user.password = args[:password]
user.first_na... |
require './lib/bike_container'
class ContainerHolder; include BikeContainer; end
describe BikeContainer do
let(:bike) { Bike.new }
let(:holder) { ContainerHolder.new }
it 'should accept a bike' do
expect(holder.bike_count).to eq(0)
holder.dock!(bike)
expect(holder.bike_count).to eq(1)
end
it ... |
module Acceptance; end
module Acceptance::Task
module Helpers
def visit_unless_current(path)
visit(path) unless current_path == path
end
def reload_page
visit current_path
end
end
PAGE_PATH = '/'
class Widget
include Capybara::DSL
include Helpers
def new_project_sn
... |
class JobsController < ApplicationController
def index
@jobs = Job.all
end
def show
@job = Job.find(params[ :id])
end
def new
@job = Job.new
end
def create
Job.create(job_params)
redirect_to jobs_path
end
def edit
@job = Job.find(params[ :id])
end
def update
@job = Job.find(params[ :id])... |
class DropNullConstraintOnShiftLimit < ActiveRecord::Migration[6.0]
def change
change_column_null :shifts, :limit, true
end
end
|
class OrderMailer < Base
default bcc: ADMIN_EMAIL if Rails.env.production?
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.order_mailer.paid.subject
#
def paid(order)
@order = order
@certificates = order.certificates
@charities ... |
module AnnotationsHelper
ANNOTATIONS = {
'**' => 'Prices are inclusive of taxes',
'*' => 'For products whose prices are not inclusive of taxes'
}.freeze
ANNOTATION_HUMAN = {
prices_inclusive_taxes: '**'
}.freeze
def taxes_inclusive_annotation(product)
if product.tax_inclusive?
'**'
... |
class Api::V1::UserSerializer < Api::V1::BaseSerializer
serializes :User
# Links
link :self do
#url_for([:api, object])
api_user_path(object)
end
link :groups do
"#{api_user_path(object)}/groups"
end
link :group_memberships do
"#{api_user_path(object)}/group_memberships"
end
# At... |
# frozen_string_literal: true
require 'common/models/form'
require 'common/models/attribute_types/httpdate'
module MHVAC
class UpgradeForm < Common::Form
include ActiveModel::Validations
attribute :user_id, Integer
attribute :form_signed_date_time, Common::HTTPDate
attribute :form_upgrade_manual_da... |
require 'test_helper'
module Soffes::Blog
class PostsControllerTest < Test
def test_empty
assert_equal 0, PostsController.posts.length
assert_equal 0, PostsController.total_pages
end
def test_inserting
assert PostsController.insert_post factory(key: 'test')
assert_equal 'test', P... |
class LinkedList
attr_reader :size
def initialize(*seeds)
@size = 0
seeds.each do |item|
add_item(item)
end
end
def add_item(payload)
if @size == 0
@first_item = LinkedListItem.new(payload)
else
current_item = @first_item
until current_item.last?
current_ite... |
namespace :after_party do
desc "Deployment task: Backfill court_report_submitted_at and court_report_status"
task backfill_court_report_submitted_at: :environment do
puts "Running deploy task 'backfill_court_report_submitted_at'" unless Rails.env.test?
CasaCase.where(court_report_submitted: true).in_batche... |
require './board'
class Tile
POS_DIFF = [[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1], [-1,0],[-1,-1]]
attr_accessor :bombed, :flagged, :revealed, :pos
def initialize(win,pos, board)
@pos = pos # array of two elements
@x,@y = pos[0],pos[1]
@bombed = false
@flagged = false
@revealed = false
... |
class RootSerializer < ActiveModel::Serializer
include ApplicationSerializer
def _links
base_links = super.merge({
"self" => {
"href" => root_url
},
"todos:incomplete" => {
"templated" => true,
"href" => "#{todos_url}{?page,per_page}",
"name" => "Incomplete tod... |
RSpec.describe "User account management", type: :system, js: true do
subject { "/users/edit" }
before do
sign_in(@user)
visit subject
end
it "should change an user name" do
name = @user.name + "aaa"
fill_in "Name", with: name
fill_in "user_current_password", with: @user.password
click_... |
class HomeController < ApplicationController
private
def chart_data
[
{
name: "Average",
data: Category.expenses.inject({}) do |hash, category|
hash.merge(category.name => category.average(range).abs)
end
}
] + LineItem.months.last(3).map do |month|
{
... |
class RuleInstancesController < ApplicationController
# GET /events
# GET /events.json
def index
@rule_instances = RuleInstance.occurrences_between(Date.today - 1.year,Date.today + 1.year)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @rule_instances.to_json(:m... |
class Attachment < ActiveRecord::Base
has_attached_file :attachment,
styles: lambda { |a| a.instance.is_image? ? {:small => "x200>", :medium => "x300>", :large => "x400>"} : {:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10}, :medium => { :geometry => "300x300#", :format => 'jpg', :time => 10}}... |
class Artist
attr_accessor :name, :songs
@@all=[]
def initialize(name)
@name = name
@songs = []
end
def add_song(song)
@songs << song #this is to trak of the songs
end
def save
@@all << self #saves the artist name to the all array
end
def self.all
@@all #displays the all... |
class AddRequests < ActiveRecord::Migration
def up
create_table :requests do |t|
t.integer :startup_id
t.integer :skill_id
t.text :message
t.integer :sender_id
t.integer :receiver_id
t.timestamps
end
add_index :requests, :sender_id
add_index :requests, :receiver_id... |
class ApplicationController < ActionController::API
# 修复wechat gem导致的无法render问题
include ActionView::Rendering
def render_to_body(options)
_render_to_body_with_renderer(options) || super
end
attr_accessor :current_user
# 参数值不在允许的范围内
# HTTP Status 400
#
# { error: 'ParameterInvalid', message: '原... |
class Feeling < ApplicationRecord
belongs_to :user
belongs_to :brand
validates :comment, length: { maximum: 140 }
with_options presence: true do
validates :flavor
validates :aroma
validates :body
validates :sharp
validates :favorite
end
end
|
# frozen_string_literal: true
require 'bolt/error'
require 'bolt/util'
module Bolt
class Target
attr_accessor :inventory
# Target.new from a data hash
def self.from_hash(hash, inventory)
target = inventory.create_target_from_hash(hash)
new(target.name, inventory)
end
# Target.new f... |
#! /usr/bin/ruby
#
# filtMapped.rb
#
# Copyright (c) 2016 - Ryo Kanno
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#
require_relative "SAMReader.rb"
require "optparse"
Version="1.1.7"
banner = "Usage: filtMapped.rb [option] <input SAM file>\n+Filter aligned pai... |
require 'fog/model'
module Fog
class Bluebox
class BlockInstantiationError < StandardError; end
class Server < Fog::Model
identity :id
attribute :memory
attribute :storage
attribute :hostname
attribute :cpu
attribute :ips
attribute :status
attribute :flavor... |
class AddNumberimageToLodges < ActiveRecord::Migration[5.0]
def change
add_column :lodges, :image2, :string
add_column :lodges, :image3, :string
end
end
|
require 'digest/md5'
module CodeRay
module Scanners
# Scanner for plain text.
#
# Yields just one token of the kind :plain.
#
# Alias: +plaintext+, +plain+
load :debug
class Text < Debug
register_for :text
title 'Dzn'
KINDS_NOT_LOC = [:plain] # :nodoc:
def i... |
require 'fog/model'
module Fog
module Rackspace
class Servers
class Server < Fog::Model
identity :id
attribute :addresses
attribute :flavor_id, :aliases => 'flavorId'
attribute :host_id, :aliases => 'hostId'
attribute :image_id, :aliases => 'imageId'
... |
# 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 ChangeIndexRatings < ActiveRecord::Migration
def up
change_column :ratings, :user_id, :integer, references: :users, index: true
change_column :ratings, :recipe_id, :integer, references: :recipes, index: true
end
def down
end
end
|
class AddTwitterHandlerToCompanies < ActiveRecord::Migration
def change
add_column :companies, :twitter_handler, :string
end
end
|
class Fixnum
def fact
(2..self).inject(1){|s, n| s * n }
end
end
class Facts
def self.[] (x)
facts[x]
end
def self.facts
@@facts ||= (0..9).collect{|i| i.fact }
end
def self.sum_fact_digits(x)
x.to_s.each_char.inject(0){|s, c| Facts[c.to_i] + s }
end
end
nums = (10..(9.fact * 7) ).s... |
class Question < ApplicationRecord
is_impressionable counter_cache: true
validates :content,length: {maximum: 255}
belongs_to :user
has_many :answers
end
|
class UsersController < ApplicationController
before_action :view_user, only: %i[ ]
def index
@users = User.all
@props = {
component_name: 'users',
component_data: @users
}
end
def show
@recipes = Recipe.where(user_id: params[:id])
@pr... |
class Review < ApplicationRecord
belongs_to :interaction
belongs_to :person
def owner
@person
end
end
|
# encoding: UTF-8
# Copyright 2017 Max Trense
#
# 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
#
# Unless required by applicable law or agre... |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', require: false
# Use postgresql if you're tired of SQLite errors.
# gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails'
# Use Uglifier as co... |
class Question < ActiveRecord::Base
# has many
has_many :answers, dependent: :destroy
# validation
validates :question_type,
presence: true,
inclusion: { in: VALID_QUESTION_TYPE.keys }
validates :question, presence: true
after_save :validate_answers
accepts_nested_attributes_for :answers, reje... |
name "cloud9"
maintainer "Antons Kranga"
maintainer_email "akranga@gmail.com"
license "Apache 2.0"
description "Installs/Configures cloud9"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1"
%w{ ubuntu }.each do |os|
supports os
end
depend... |
require 'spec_helper'
describe Guard::Guard do
describe '#initialize' do
it 'assigns the defined watchers' do
watchers = [ Guard::Watcher.new('*') ]
guard = Guard::Guard.new(watchers)
guard.watchers.should eql watchers
end
it 'assigns the defined options' do
options = { :a => 1... |
class Person
attr_accessor :name
attr_accessor :age
attr_accessor :type
def initialize
@name = name
@age = age
@type = type
end
def register_as(type)
@type = type
end
end |
class PlayerSerializer < ActiveModel::Serializer
attributes :id, :user_id, :game_id, :username, :strikes, :active
has_many :turns
belongs_to :game
belongs_to :user
end
|
require "rails_helper"
describe "AppRouting" do
it {
expect(root: "books", action: "index")
}
it {
expect(get: "books/12/reserve").to route_to(controller: "reservations", action: "reserve", book_id: "12")
}
it {
expect(get: "books/1/take").to route_to(controller: "reservations", actio... |
Rails.application.routes.draw do
resources :batches, only: [:index, :show]
get '/batches/detail/:accession_number',
to: 'batches#detail',
as: :batch_item,
format: false,
constraints: { accession_number: /.+/ }
post '/validate_new', to: 'validation#validate_new', as: :validate_new
patch ... |
describe 'Datoki.db number' do
before {
CACHE[:datoki_db_number] ||= begin
reset_db <<-EOF
CREATE TABLE "datoki_test" (
id serial NOT NULL PRIMARY KEY,
parent... |
require 'snmp2mkr/config_types/base'
require 'snmp2mkr/config_types/metric_definition_collection'
module Snmp2mkr
module ConfigTypes
class MetricDiscoveryRule < Base
def setup(hash)
metrics_hash = hash.fetch('metrics')
if !metrics_hash.kind_of?(Hash) || metrics_hash.any? { |k,v| !k.kind_of?... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.