text
stringlengths
10
2.61M
class WelcomeNotification extend Notify::Notification # The delivery platforms this notification should use. The fallback # will be the default list of all platforms. self.deliver_via = :action_mailer # The mailer that will be used if delivering via ActionMailer. Specify # the mailer name (and the action ...
require 'sequencescape-api/resource' require 'sequencescape/tag' class Sequencescape::Tag2LayoutTemplate < ::Sequencescape::Api::Resource attribute_reader :name composed_of :tag, :class_name => 'Tag' has_create_action :resource => 'tag2_layout' end
require "rails_helper" RSpec.feature "logged in user can view dashbaord" do scenario "they view user info and trips/listings" do user = create(:user_with_orders) login(user) click_on user.first_name click_on "Dashboard" expect(current_path).to eq "/dashboard" click_on "My Trips" expect(current...
require "rails_helper" RSpec.feature "VisitorCanViewCategories", type: :feature do context "as a visitor" do it "can view all existing items" do Category.create(name: "hats") Category.create(name: "boots") Category.create(name: "shirts") visit items_path click_link("Categories") ...
Rails.application.routes.draw do # How does this routing play in with the front end, # considering we want to have the review appear on # the "gears" show page? Waiting to hear back from Sergio on this. devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' } root to: 'gears#index' ...
require 'helper' require 'deviantart' class DeviantArt::Client::Gallery::Test < Test::Unit::TestCase setup do @da, @credentials = create_da end sub_test_case '#get_gallery_all' do setup do @username = fixture('gallery-input.json').json['username'] @gallery_all = fixture('gallery_all.json') ...
#a method that returns an array that contains every other element of an input array #the values in the return list should have the odd index #input: array #output: array def oddities(input_array) return "This is not a valid input" if input_array.is_a?(Array) == false new_array = [] input_array.map.with_index do ...
require 'rails_helper' RSpec.describe User, type: :model do before { @user = build(:user) } subject { @user } it "is not valid without email" do @user.email = "" expect(@user).to_not be_valid end it "is not valid without password" do @user.email = "user@example.com" @user.password = "" expect(@user)....
require_relative 'spec_helper' require_relative 'model' describe ActsAsFile do let(:subject) { TestPost.new } after { File.unlink(subject.filename) if File.exist?(subject.filename) } context '#body=' do it { expect { subject.body = 'aaaa' }.not_to raise_error } end context '#body' do context 'get f...
class Game attr_accessor :board, :turn, :player1, :player2 def initialize @board = [] 6.times { @board << ['_','_','_','_','_','_','_'] } @turn = 1 puts "Hello! What is player 1's name?" @player1 = STDIN.gets.chomp puts "And what is player 2's name?" @player2 = STDIN.gets.chomp puts "\nW...
class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authenticate_user! def after_sign_in_path_for(resource) request.env['omniauth.origin'] || user_portfolios_path(current_user) end private def require_permission if current_user != Portfolio.fi...
class Network < ApplicationRecord belongs_to :hot_catch_app # Возвращает массив x и y для построения графика # Формат: # x: [[легенда оси y1, легенда оси x1], [легенда оси y2, легенда оси x1], # [легенда оси y3, легенда оси x2], [легенда оси y4, легенда оси x2], ...] # y: [[легенда оси y1, входящий трафик,...
require "spell_check" describe 'spell_check' do it 'will return the inputed string' do expect(spell_check("", [])).to eq "" end it 'will return an incorrect string with the correct prefix and suffix chars' do expect(spell_check("dg", ["dog"])).to eq "~dg~" end it 'will return a fl...
module DirectiveRecord module Query class SQL def initialize(base) @base = base end def to_sql(*args) options = to_options(args) validate_options! options original_options = options.deep_dup original_options.reject!{|k, v| v.nil?} check_path_de...
class CreateBroadcasts < ActiveRecord::Migration def change rename_table :songs_stations, :broadcasts end end
# frozen_string_literal: true class CreateCampusesTable < ActiveRecord::Migration[4.2] def up create_table "campuses", :force => true do |t| t.string "name" t.integer :borough_id t.datetime "created_at", :null => false t.datetime "updated_at", :null => f...
# frozen_string_literal: true # Provides methods related to tokenizing an input file, and writing to # a new file all words in the input less than a specified length. # # @author Zach Baruch module Truncator # Reads from +input_file+, and writes to +output_file+ all of the words # in +input_file+ containing only l...
Rails.application.routes.draw do mount_devise_token_auth_for 'User', at: 'user_auth' # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html namespace :api, defaults: { format: :json } do namespace :v1 do mount_devise_token_auth_for 'User', at: 'user_auth', ...
require 'pry' class Translate attr_reader :character_set def initialize @character_set = ("a".."z").to_a << " " end def do_rotations(message, keys) message.downcase.chars.map.with_index do |char, index| if @character_set.include?(char) rotated_character_set = @character_set.rotate(keys[...
require "rails_helper" describe Record do before do @record = FactoryBot.create(:record) end describe "スコア投稿の保存" do context "スコア投稿が保存できる場合" do it "全てが入力されていれば投稿できる" do expect(@record).to be_valid end it "タイトルが空でも投稿できる" do @record.title = "" expect(@record).to b...
# LogFriend makes it easy to do quick, easy logging in dev/test with output that includes # the name of object being logged. # For example: # arg = "42" # @ivar = "Hello" # d arg # d @ivar # Outputs: # ["arg", "42"] # ["@ivar", "Hello"] # module LogFriend module Extensions if Rails.env.development? ||...
# == Schema Information # # Table name: representatives # # id :integer not null, primary key # abbreviated_name :string # bwc_quote_completion_date :date # company_name :string # current_payroll_period_lower_date :date # curren...
class RenameCostToPriceOnDishes < ActiveRecord::Migration def change rename_column :dishes, :cost, :price end end
# frozen_string_literal: true module Decidim module Participations # Exposes the participation vote resource so users can vote participations. class ParticipationVotesController < Decidim::Participations::ApplicationController include ParticipationVotesHelper helper_method :participation ...
class SubmissionProofPdf < Prawn::Document # To-dos: # 1. set default font for majority of doc in initialize() # 2. code for individual cell alignments, row-coloring, adjust table size to page width in Section D - compare to old code # 3. should spacing between sections be controlled in main calling proc ?...
class AddPlaidAccountIdIndexToTransactions < ActiveRecord::Migration def change add_index :transactions, :plaid_account_id end end
class CreateStockInputDetails < ActiveRecord::Migration def change create_table :stock_input_details do |t| t.references :stock_input, index: true t.references :purchase_order_detail, index: true t.decimal :amount t.string :status t.integer :user_inserts_id t.integer :user_upda...
require 'spec_helper' require 'yt/models/comment' describe Yt::Comment, :server_app do subject(:comment) { Yt::Comment.new attrs } context 'given an existing comment (non-reply) ID' do let(:attrs) { {id: 'z13kc1bxpp22hzaxr04cd1kreurbjja41q00k'} } it { expect(comment.parent_id).to be_nil } it { expect...
require './controller' require 'test/unit' require 'rack/test' set :environment, :test class FakeTableTest < Test::Unit::TestCase include Rack::Test::Methods # Look a mixin! def app FakeTableApplication end def test_home_ok get '/' assert last_response.ok? end def test_detail_ok get '/d...
require 'spec_helper' describe Gpdb::InstanceRegistrar do let(:owner) { FactoryGirl.create(:user) } let(:valid_instance_attributes) do { :name => old_name, :port => 12345, :host => "server.emc.com", :maintenance_db => "postgres", :provision_type => "register", :d...
# == Schema Information # # Table name: relationships # # id :integer not null, primary key # follower_id :integer not null # followed_id :integer not null # created_at :datetime not null # updated_at :datetime not null # # Indexes # # index_relationships_on_f...
Sequel.migration do up do create_table(:settings) do primary_key :id String :name String :value end self[:settings].insert({:name => "theme", :value => "smoothness"}) end end
class Product < ActiveRecord::Base attr_accessible :cost, :description, :name, :stock validates_presence_of(:name, :description) #també val d'esta manera: #validates_presence_of :name, :description #has_and_belongs_to_many :purchases has_many :line_items has_many :purchases, :through => :line_items, :uniq...
class Review < ActiveRecord::Base belongs_to :bead belongs_to :user end
class AppointmentsController < ApplicationController before_action :set_appointment, only: [:show, :edit, :update, :destroy] before_action :authenticate_user!, except: [:index, :showcase] before_filter :disable_nav, only: [:showcase] before_filter :update_date_params, only: [:create, :update] # GET /appointm...
class UserStepsController < ApplicationController include Wicked::Wizard steps :restaurant_type, :location, :serves, :credit_card before_filter :get_resource def show case step when :location @resource.restaurants.build if @resource.restaurants.empty? when :serves @restaurant = @resour...
class Operation < ActiveRecord::Base belongs_to :company has_many :category_operations has_many :categories, through: :category_operations validates_presence_of :invoice_num, :company_id, :invoice_date, :amount, :operation_date, :kind, :status validates_numericality_of :amount, greater_than: 0 validates_...
class CollageImage < ActiveRecord::Base belongs_to :collage has_attached_file :picture, :styles => { :original => "300x" }, :default_url => "" validates_attachment_content_type :picture, :content_type => /\Aimage\/.*\Z/ validates_attachment_size :picture, :less_than => 5.megabytes, :unless => Proc.new {|m| m[:...
class Release < ActiveRecord::Base belongs_to :user belongs_to :template attr_accessor :edit_override before_validation do self.token ||= SecureRandom.hex self.fields ||= {} end validates :production_start_date, :date => { :message => 'must be a valid date' } validates :production_end_d...
class ChangeAcceptanceToTerms < ActiveRecord::Migration[5.1] def change remove_column :users, :acceptance add_column :users, :terms, :boolean end def down remove_column :users, :terms end end
#!/bin/env ruby # encoding: utf-8 require 'scraperwiki' require 'nokogiri' require 'pry' require 'open-uri/cached' OpenURI::Cache.cache_path = '.cache' class String def tidy self.gsub(/[[:space:]]+/, ' ').strip end end def noko_for(url) Nokogiri::HTML(open(url).read) end def scrape_list(url) noko = nok...
class CreatePiggyBanks < ActiveRecord::Migration[5.2] def change create_table :piggy_banks do |t| t.string :name t.string :currency t.string :description t.float :balance, default: 0.0 t.float :total_credit, default: 0.0 t.float :total_debit, default: 0.0 t.belo...
module MultiInfo class API # MultiInfo API Error exception. class Error < StandardError attr_reader :code, :message def initialize(code, message) @code, @message = code, message end # Creates a new Error from a MultiInfo HTTP response string def self.pars...
Rails.application.routes.draw do # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html resources :tasks # get 'tasks', to: 'tasks#index' # get 'tasks/new', to: 'tasks#new' # post 'tasks', to: 'tasks#create' # get 'tasks/:id', to: 'tasks#show', as: 'task' # g...
module Spreadable extend ActiveSupport::Concern def gen_sceneid raise "Instance method :gen_sceneid is not defind in #{self}" end def get_sceneid gen_sceneid if self.sceneid.blank? return self.sceneid end end
class DestinationSerializer < ActiveModel::Serializer attributes :id, :name, :latitude, :longitude, :street_number, :street, :city, :state, :zip_code, :image, :tags has_many :favorites has_many :forecasts has_many :favorite_tags, through: :favorites has_many :users, through: :favorites def tags tag_na...
class Employee < ActiveRecord::Base has_many :absences, :dependent => :destroy validates_presence_of :first_name validates_presence_of :first_last_name validates_presence_of :unique_id validates_uniqueness_of :unique_id def full_name "#{self.first_name} #{self.first_last_name}" end end
json.array!(@orderdetails) do |orderdetail| json.extract! orderdetail, :id, :order_id, :product_id, :quantity, :unit_price json.url orderdetail_url(orderdetail, format: :json) end
class CreateInnovateApplicantTests < ActiveRecord::Migration[5.2] def change create_table :innovate_applicant_tests do |t| t.references :applicant, foreign_key: true t.integer :lang t.string :a1 t.string :a2 t.string :a3 t.timestamps end end end
# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provider "virtualbox" do |v| v.memory = 2048 v.cpus = 2 end # need a private network f...
require File.expand_path(File.dirname(File.dirname(__FILE__)) + '/spec_helper') require 'rule/total_greater_than' describe Rule::TotalGreaterThan do let(:total_threshold) { 50 } let(:rule) { Rule::TotalGreaterThan.new total_threshold} let(:promotion_rules) { [rule] } let(:product_total) { 49 } describe '#process...
class CreateAllMembers < ActiveRecord::Migration def change create_table :all_members do |t| t.datetime :event t.timestamps end end end
# Encoding: utf-8 require 'spec_helper' describe 'yum-pydio::default' do let(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'centos', :version => '6.5' ) do |node| node.automatic['kernel']['machine'] = 'x86_64' end.converge('yum-pydio::default') end it 'creates yum repo...
# 1 flintstones = ["Fred", "Barney", "Wilma", "Betty", "Pebbles", "BamBam"] flintstones_hash = {} flintstones.each_with_index do |name, index| flintstones_hash[name] = index end p flintstones_hash # 2 ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 5843, "Eddie" => 10, "Marilyn" => 22, "Spot" => 237 } p ag...
module Payment class CreditCard < Base include IuguBase attr_accessor :token private def taxes cart.total_card_fee end def payment_method 'credit_card' end def due_date { due_date: Date.tomorrow.in_time_zone.strftime('%d/%m/%Y') } end def charge_param ...
module SearchApi class Result include SearchApi::Helpers attr_reader :items, :filters, :sorts, :results_per_page, :selected_filters_url_string def initialize(raw_fields) fields = JSON.parse(raw_fields).with_indifferent_access @items = fields[:items] @filters = fields[:filters] @...
class AddENamesToPenguins < ActiveRecord::Migration[5.0] def change add_column :penguins, :e_name, :string end end
class Paper < ApplicationRecord belongs_to :student, class_name: 'User' belongs_to :assignment state_machine initial: :in_progress do event :submit do transition in_progress: :submitted end event :check do transition submitted: :marked end end end
require 'glossary_asset_tag_helper_patch' require 'labelled_form_for' require 'term_link_helper' Redmine::Plugin.register :redmine_test do name 'Redmine Test plugin' author 'Author name' description 'This is a plugin for Redmine' version '0.0.1' url 'http://example.com/path/to/plugin' author_url 'http://ex...
class ApplicationController < ActionController::API rescue_from StandardError, with: :rescue_with_error def parse_date(date_to_parse) DateTime.parse(date_to_parse) end private def rescue_with_error(exception) render json: { error: exception.to_s }, status: :unprocessable_entity end end
# frozen_string_literal: true # StringActions Module module KepplerFrontend module Concerns module StringActions extend ActiveSupport::Concern private def not_special_chars chars = ('a'..'z').to_a << '_' chars << ':' end def without_special_characters self....
# 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 。 # # 请找出这两个有序数组的中位数。要求算法的时间复杂度为 O(log (m+n)) 。 # # 示例 1: # # nums1 = [1, 3] # nums2 = [2] # # 中位数是 2.0 # 示例 2: # # nums1 = [1, 2] # nums2 = [3, 4] # # 中位数是 (2 + 3)/2 = 2.5 require 'json' # @param {Integer[]} nums1 # @param {Integer[]} nums2 # @return {Float} def find_median_sorted...
# frozen_string_literal: true # slap.rb # Author: William Woodruff # ------------------------ # A Cinch plugin that provides user slapping for yossarian-bot. # ------------------------ # This code is licensed by William Woodruff under the MIT License. # http://opensource.org/licenses/MIT require_relative "yoss...
# frozen_string_literal: true # rubocop:todo all # Copyright (C) 2014-2020 MongoDB Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
class City < ApplicationRecord mount_uploader :image, ImageUploader has_many :recipes end
require_relative 'test_helper' # DISCLAIMER # These tests are not examples of proper usage of ImageMagick. # In fact, most of them are entirely invalid. The point is to # test the logic of building strings. class ConvertTest < Skeptick::TestCase include Skeptick def test_dsl_method_convert_available assert_re...
class Bowling::Game attr_accessor :frames def initialize( data = nil ) @frames = Array.new( 10 ){ |i| Bowling::Frame.new i, self } load data if data end def load( data ) raise ArgumentError.new '#load needs array' unless data.instance_of? Array data.each_with_index{ |frame, i| @frames[i].lo...
class Api::GraphqlController < Api::ApiApplicationController include CanvasSupport # Defined in order of increasing specificity. rescue_from Exception, with: :internal_error rescue_from GraphQL::ParseError, with: :invalid_query rescue_from JSON::ParserError, with: :invalid_variables rescue_from ActiveReco...
class MydbsController < ApplicationController before_action :set_mydb, only: [:show, :edit, :update, :destroy] # GET /mydbs # GET /mydbs.json def index @mydbs = Mydb.all end # GET /mydbs/1 # GET /mydbs/1.json def show end # GET /mydbs/new def new @mydb = Mydb.new end # GET /mydbs/1...
require 'acceptance/acceptance_helper' feature 'Running reports', %q{ In order to see what is going on in the system As an admin I want to run reports } do background do # Given I am an admin @i_am_an_admin = FactoryBot.create(:admin) # And I have signed in sign_in_as @i_am_an_admin # Wh...
class Assignment < ApplicationRecord extend ActiveHash::Associations::ActiveRecordExtensions belongs_to :project belongs_to :machine delegate :name, to: :project, prefix: true delegate :name, to: :machine, prefix: true def role project.kind.roles.find { |r| r.id == role_id } end end # == Schema In...
class Period < ActiveHash::Base self.data = [ { id: 1, name: '選択してください (任意)' }, { id: 2, name: '短期' }, { id: 3, name: '中期' }, { id: 4, name: '長期' } ] include ActiveHash::Associations has_many :investments end
# # This test assumes the NFS share of the storage in question is mounted on the appliance. # require 'manageiq-gems-pending' require 'ostruct' require 'MiqVm/MiqVm' require 'logger' $log = Logger.new(STDERR) $log.level = Logger::DEBUG DDIR = "/mnt/vm/7fd0b9b2-e362-11e2-97b7-001a4aa8fcea/rhev/data-center/773f2ddf-77...
class RenameNewColumns < ActiveRecord::Migration[6.0] def change rename_column :entries, :new_read, :read rename_column :entries, :new_pod, :pod rename_column :feeds, :new_display, :display end end
class AddRouteRefToEvaluations < ActiveRecord::Migration[5.2] def change add_reference :evaluations, :route, foreign_key:{on_delete: :cascade} end end
# ========================================================================== # Project: Lebowski Framework - The SproutCore Test Automation Framework # License: Licensed under MIT license (see License.txt) # ========================================================================== # # It may be that in your parti...
class AddNewsletterSettingsToSmoochBot < ActiveRecord::Migration[4.2] def change b = BotUser.smooch_user unless b.nil? settings = b.settings.deep_dup.with_indifferent_access settings[:settings].each_with_index do |s, i| if s[:name] == 'smooch_workflows' # Add a new property: New...
class AddTargetPointsToGroupsTable < ActiveRecord::Migration[6.0] def change add_column :groups, :target_points, :integer, default: BASE_LEVEL_PTS end end
class BidsController < ApplicationController skip_before_action :require_login, only: [:create, :edit, :update_amount] skip_before_action :scope_current_company, only: [:create, :edit, :update_amount] def index # Use's ActiveModel::Serializer to serialize records into JSON. render json: ReduxDataQuery.ca...
class VendorsController < ApplicationController def index @vendors = Vendor.all end def new @vendor = Vendor.new end def create @vendor = Vendor.new(params[:vendor]) if @vendor.save flash[:notice] = "Vendor created." redirect_to vendors_path else render 'new' end end def show @vendor = ...
class ProfileController < ApplicationController before_action :authenticate_user! def index end def edit_password @profile = current_user end def change_password @profile = current_user if @profile.valid_password?(profile_params[:old_password]) @profile.password = profile_params[:passwor...
# Incoming Message module API::Entity class InMessage attr_reader :content def initialize xml_source @xml_source = xml_source @content = Hash.from_xml(xml_source)['xml'] end def type @content['MsgType'] end def to_s @xml_source end def from @content['Fr...
require 'formula' class GnustepMake < Formula homepage 'http://gnustep.org' url 'http://ftpmain.gnustep.org/pub/gnustep/core/gnustep-make-2.6.2.tar.gz' sha1 '3f85cb25f4f7fd35cdcbd8d948a2673c84c605ff' def install system "./configure", "--prefix=#{prefix}", "--with-config-file=#{pr...
require 'singleton' module Redmine::Installer class Command include Singleton include Redmine::Installer::Utils RAKE = 'bundle exec rake' def bundle_install(env) run('bundle install', get_bundle_env(env), :'command.bundle_install') end def rake_db_create(env) run(RAKE, 'db:crea...
# == Schema Information # # Table name: documents # # id :integer not null, primary key # folder_id :integer # folder_type :string # name :string(50) # content :text # created_at :datetime not null # updated_at :datetime not null # # Indexes # # index_documents_o...
class Person attr_reader :first_name, :last_name, :gender def initialize(first_name, last_name, gender) @first_name = first_name @last_name = last_name @gender = gender end def fullname(fullname) @fullname = "#{@first_name}" + "#{@last_name}" end def doctor(doctor) @doctor = "Dr. " + ...
class RemoveNameFromCreateCampaigns < ActiveRecord::Migration[5.1] def change remove_column :campaigns, :name, :text end end
class User < ApplicationRecord mount_uploader :avatar, AvatarUploader ratyrate_rater acts_as_voter has_many :tutorials has_many :comments validates :username, presence: true devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :omniauthable, ...
class User < ActiveRecord::Base has_many :comments has_many :group_memberships has_many :groups, through: :group_memberships has_many :images #acts_as_taggable # Alias for acts_as_taggable_on :tags # acts_as_taggable_on :skills, :interests validates :email, presence: true, uniqueness: true validates :pas...
require "test_helper" describe CartsController do let (:product1) { products(:cake1) } let (:order_item_hash1) { { order_item: { product_id: product1.id, qty: 5 } } } it "should get a cart's show if order exists" do post order_items_path, params: order_item_hash1 ...
class Public::CustomersController < ApplicationController def create @customer = Blog.new(blog_params) if @blog.save redirect_to blog_path(@blog.id) else render :new end end def show @customer = Customer.find(params[:id]) @comments = @customer.comments.order("created_at DES...
require 'rails_helper' RSpec.describe ApplicationHelper, type: :helper do describe '#full_title' do context 'when not receives any param' do it 'show title' do expect(helper.full_title).to eql('SGTCC') end end context 'when receives param' do it 'show {param} | title' do ...
# frozen_string_literal: true # Starts with the code displayed by the lock and then tests alternate up and down values class StartOppositeDisplayStrategy def initialize @guess = [nil,nil,nil,nil] @unlocked = false @guesses = 0 end def run(padlock) @padlock = padlock opposite_code = opposite(...
class Cms::UsersController < ApplicationController layout 'cms' def show user=User.select(:id, :username).find params[:id] if user.is_admin? head :not_found else @articles = user.articles.select(:id, :summary, :title, :logo).order(id: :desc).page params[:page] @title = t 'cms.users.sh...
module APIHelpers def warden env['warden'] end def api_authenticate error!(response_error(I18n.t('service_api.errors.invalid_api_key'), 401), 200) unless HALALGEMS_API_KEY.include?(headers["Apikey"]) end def session env['rack.session'] end def current_user User.where(authentication_to...
# == Schema Information # # Table name: taggings # # id :bigint not null, primary key # tag_topic_id :integer not null # url_id :integer not null # created_at :datetime not null # updated_at :datetime not null # class Tagging < ApplicationRecord va...
# -*- coding: utf-8 -*- require 'test_helper' class CityTest < ActiveSupport::TestCase test '抽税后, 人口数量小于税率 * 1000' do city_hash = {:name => '衡水', :pos_x => 0, :pos_y => 0, :tax_rate => 0.2, :gold => 100, :food => 1000, :human => 100 } city = City.create city_hash ...
class WelcomeController < ApplicationController def index @users = User.where(1).order(:created_at) @symptoms = Symptom.joins(:user).order("created_at DESC").take(50) end end
class Tag < ActiveRecord::Base has_many :tag_types has_many :blurbs, :through => :tag_types has_many :events, :through => :tag_types has_many :image_videos, :through => :tag_types end
require 'rails_helper' describe "Items API" do it "sends a list of items" do merchant = Merchant.create!(name: 'Lady Jane') items = create_list(:item, 3, merchant: merchant) get '/api/v1/items' expect(response).to be_success items = JSON.parse(response.body) expect(items.count).to eq(3) ...