text stringlengths 10 2.61M |
|---|
class UserFolloweesController < ApplicationController
def index
user = User.find_by(username: params[:username])
is_following = current_user ? current_user.following?(user) : false
following_users = user.following
following_count = following_users.length
follower_count = user.followers.length
... |
# == Schema Information
#
# Table name: coaches
#
# id :integer not null, primary key
# user_id :integer
# slug :string
# description :string
# created_at :datetime not null
# updated_at :datetime not null
#
require 'rails_helper'
describe Coach do
before(:each) ... |
module Bibliovore
# Circulation status of a title or copy
class Status
# @return [String] The id (a short tag) of the status.
attr_reader :id
# @return [String] The name (human-readable) status
attr_reader :name
def initialize(data)
@id = data['id']
@name = data['name']
end
... |
require 'spec_helper'
describe BeersController do
render_views
login_user
before(:each) do
@style = Factory(:style)
@style.save!
end
describe "GET index" do
before(:each) do
@brewery = Factory(:brewery)
@beers = [Factory(:beer, :brewery => @brewery)]
31.times do |n|
... |
#!/home/manezeu/.rbenv/shims/ruby
# rubocop:disable Metrics/ModuleLength
module Enumerable
def arr_range?(param)
param.class == Array || param.class == Range
end
def hash?(param)
param.class == Hash
end
def my_each
return to_enum unless block_given?
caller = self
if arr_range?(caller)
... |
#1 All players pick either Paper, Rock or Scissors
#2 You compare the choices: Paper > Rock, Rock > Scissors, Scissors > Paper. Tied if same.
#3 Ask to play again
CHOICES = {'p' => 'Paper', 'r' => 'Rock', 's' => 'Scissors'}
puts "Welcome to Paper, Rock, Scissors!"
def winning_display_message(winning_choice)
case w... |
# frozen_string_literal: true
module GraphQL
module StaticValidation
class VariablesAreUsedAndDefinedError < StaticValidation::Error
attr_reader :variable_name
attr_reader :violation
VIOLATIONS = {
:VARIABLE_NOT_USED => "variableNotUsed",
:VARIABLE_NOT_DEFINED => "variableN... |
module FastFilter
class Engine
attr_accessor :options
def self.load(name)
require_relative "engine/#{name}"
FastFilter.const_get("#{name.split('-').collect { |item| item.capitalize }.join}Engine")
end
def initialize(options = {})
self.options = options
end
def... |
Rails.application.routes.draw do
get 'search/show'
get 'place/show'
get 'character/show'
get 'chapter/show'
root 'greetings#get_chapter'
get '/search', to: 'search#searches'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :chapter
resource... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Language::Generation do
describe "#to_query_tring" do
let(:document) {
GraphQL.parse('type Query { a: String! }')
}
let(:custom_printer_class) {
Class.new(GraphQL::Language::Printer) {
def print_field_definition(pr... |
# How big is the room?
# Build a program that asks a user for the length and width of a room in meters and then displays the area of the room in both square meters and square feet.
# Note: 1 square meter == 10.7639 square feet
# Do not worry about validating the input at this time.
puts "Enter the length of the roo... |
# <!-- # Apple Picker
# ## Instructions
# Create a method, `apple_picker`, that will pick all the apples out of an array. Implement this only using `each`.
# ```ruby
# apple_picker(["apple", "orange", "apple"]) #=> ["apple", "apple"]
# ```
def apple_picker(array)
apples_only = []
array.each do |fruit|
apple... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# venmo_id :string(255)
# username :string(255)
# first_name :string(255)
# last_name :string(255)
# email :string(255)
# ph... |
require 'rom/lint/gateway'
require 'rom/lint/enumerable_dataset'
RSpec.shared_examples "a rom repository" do
before(:all) do
ROM::Deprecations.announce "[Adapter]::Repository is", <<-MSG
Please use [Adapter]::Gateway instead.
MSG
end
let(:gateway) { repository }
include_examples "a rom gateway"... |
require 'optparse'
require 'singleton'
require 'byebug'
module YoutubeMultipleDL
class CLI
include Singleton
def run(args)
params, url_param = parse_cli_args(args)
if params.has_key?(:start)
YoutubeMultipleDL::Queue.process(num_workers: params[:workers].to_i)
elsif param... |
class RemoveDateFromMatches < ActiveRecord::Migration[5.1]
def change
remove_column :matches, :date, :date
remove_column :matches, :referee_id, :integer
rename_column :matches, :home_team_id, :home_team_season_id
rename_column :matches, :away_team_id, :away_team_season_id
add_column :matches, :kic... |
module MorningPages
class User
include Mongoid::Document
include Mongoid::Timestamps
attr_accessible :email, :username
field :username, :type => String
field :email, :type => String
field :key, :type => String
validates_format_of :email, :with => /@/
validates_presence_of :email, :us... |
class Restaurant < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
mount_uploader :picture, PictureUploader
has_many :reviews
has_many :menus
has_many :chefs
has_many :images
devise :database_authenticatable... |
class Review < ApplicationRecord
belongs_to :restaurant
validates :content, :rating, presence: true
validates_inclusion_of :rating, in: 0..5
validates :rating, numericality: { integer: true }
end
|
require 'toad_spawn/base'
require File.dirname(__FILE__) + '/helper'
describe ToadSpawn::Base do
before(:each) do
reset_sandbox
end
describe "Path validation" do
it "Raise error if directory absent" do
lambda { ToadSpawn::Base.new('does/not/exist') } .should raise_error 'Directory does not exist... |
class Game
attr_accessor :word, :underline, :guess_count, :total_guesses, :result
def initialize(word)
@word = word
@underline = "_" * @word.length
@guess_count = 0
@total_guesses = @word.length
@indeces = []
@result = {}
end
def build_legend
counter = 0
@word.chars.each do |char|
@res... |
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :post, touch: :comments_updated_at
has_many :user_comment_votes, inverse_of: :comment, dependent: :delete_all
validates :user, :post, presence:true
attr_accessible :content, :user_id, :post_id
scope :visible, where("fan_score > -3")
en... |
module Shoperb module Theme module Editor
module Mounter
module Model
class Collection < Sequel::Model
extend Base::SequelClass
include Base::Sequel
fields :id, :name, :permalink, :handle, :image_id, :description
c_fields :product_ids, cast: Array
translates :name
... |
FactoryBot.define do
factory :purchase_history_address do
postal_code {'123-4567'}
prefecture_id{ Faker::Number.between(from: 2, to: 48)}
city{'八戸市'}
address{'1-1'}
building_name{'シャーメゾン'}
phone_number {'09012345678'}
token {'tok_abcdefghijk00000000000000000'}
end
end
|
FactoryGirl.define do
factory :order do
user
trait :with_items do
order_items { create_list(:order_item, 2) }
end
trait :checkout_package do
order_items { create_list(:order_item, 2) }
order_shipping { create :address_order, :shipping }
order_billing { create :address... |
class Trouble < ActiveRecord::Base
geocoded_by :address
# auto-fetch coordinates and the condition is for preventing fetching the same address more than once
after_validation :geocode, if: :address_changed?
end
|
class GroupNestingsController < ApplicationController
# GET /group_nestings
# GET /group_nestings.xml
helper_method :sort_column, :sort_direction
def index
@group_nestings = Group.find(:all, :conditions=>["id not in(?)", [1]]).paginate(:per_page=> 20, :page=>params[:page], :order=>(sort_column + " " + so... |
require 'net/https'
require 'json'
require 'pp' # dev
class FbAlbums
HOST = "https://graph.facebook.com"
USER = "3dmaking"
ALBUMS_URL = "#{HOST}/3dmaking/albums"
URL = "#{HOST}/%s" # id of the resource
PHOTOS_URL = "#{HOST}/%d/photos" # album_id
def albums
url = ALBUMS_URL
albums = get url
alb... |
class Cli
def call
generate_events
welcome
options
end
def generate_events
Scraper.scrape
#binding.pry
end
def welcome
puts "Here are some upcoming events happening in Houston:"
puts ""
puts ""
Events.all.each.with_index(1) do |event, index|
puts "#{index}. #{ev... |
class Api::FollowsController < ApplicationController
before_action :require_logged_in
def index
# debugger
@follows = @current_user.follows
render :index
end
def create
@follow = Follow.new(follow_params)
@follow.user_id = follow_params[:user_id]
@follow... |
require 'test_helper'
class LanguagesControllerTest < ActionDispatch::IntegrationTest
test "should get show" do
get '/languages/1/'
assert_response :redirect
end
#show needs to be rewritten to reflect new routes.
test "should get languages index " do
get '/languages/'
assert_response :redirect
end
#inde... |
class CheckIns::Onboard
include Interactor
context_requires :last_period, :cycle_length, :period_length, user: User
before do
context.last_period = context.last_period.to_date
context.cycle_length = context.cycle_length.to_i
context.period_length = context.period_length.to_i
end
def call
pe... |
module SDC
class Text
# Use these methods only if you want to treat outline and fill color as same
def color=(value)
self.outline_color = value
self.fill_color = value
end
def color
return self.fill_color
end
end
end
|
class ApplicationController < ActionController::Base
before_action :check_maintenance_mode
def check_maintenance_mode
if File.exists?(Rails.root.join('maintenance'))
return render '/maintenance', layout: nil
end
end
end
|
# frozen_string_literal: true
module GraphQL
module Analysis
module AST
# Used under the hood to implement complexity validation,
# see {Schema#max_complexity} and {Query#max_complexity}
class MaxQueryComplexity < QueryComplexity
def result
return if subject.max_complexity.nil?... |
#--
# Copyright (c) 2013 Michael Berkovich, tr8nhub.com
#
# 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 use, copy, modify, ... |
class LeiturasController < ApplicationController
before_action :set_leitura, only: [:show, :update, :destroy]
# GET /leituras
def index
@leituras = Leitura.order('updated_at DESC').limit(50).pluck(:valor)
render json: @leituras
end
# GET /leituras/1
def show
render json: @leitura
end
# P... |
describe Blackjack do
before() do
subject = Blackjack.new
end
it 'should return correct result' do
result =subject.score_hand(["5", "4", "3", "2", "A", "K"])
expect(result).to eql(25)
end
it 'should return correct result if contains three A ' do
result =subject.score_hand(["A", "10", "A", "A... |
class Demand < Sequel::Model
plugin :timestamps, update_on_create: true
plugin :auto_validations, not_null: :presence
plugin :validation_class_methods
plugin :geocoder
reverse_geocoded_by :latitude, :longitude
many_to_one :user
one_to_many :transactions
state_machine initial: :notifying do
state :... |
name 'memcached'
maintainer 'BRIAN STAJKOWSKI'
maintainer_email 'NO EMAIL'
license 'All rights reserved'
description 'Installs/Configures memcached'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.3'
|
class AddForeignKeyToEmployees < ActiveRecord::Migration[6.0]
def change
add_foreign_key :employees, :users, column: :manager_id, primary_key: :id
end
end
|
# frozen_string_literal: true
module GeoPattern
# Color generators
module ColorGenerators
# Simple one
class SimpleGenerator
private
attr_reader :color, :creator
public
# New
#
# @param [String] color
# HTML color string, #0a0a0a
def initialize(color, cr... |
class CreateAgeTags < ActiveRecord::Migration
def self.up
create_table :age_tags do |t|
t.integer :age_id
t.integer :tag_id
t.integer :tp
t.timestamps
end
add_index :age_tags,[:age_id,:tag_id,:tp], :unique => true
end
def self.down
drop_table :age_tags
end
end
|
class User < ApplicationRecord
has_many :posts
has_secure_password
def self.search(query)
where("name like ? OR email like ?", "%#{query}%", "%#{query}")
#code
end
end
|
class RegisteredApplication < ActiveRecord::Base
belongs_to :user
has_many :events, dependent: :destroy
validates :name, length: {maximum: 50}
validates :url, presence: true
end
|
=begin
Lettercase Counter
Write a method that takes a string, and then returns a hash
that contains 3 entries: one represents the number of characters
in the string that are lowercase letters, one the number of
characters that are uppercase letters, and one the number of
characters that are neither.
Examples
l... |
#!/usr/bin/env ruby
require 'erb'
document = %[
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><%= @name %></title>
</head>
<body>
<h1><%= @name %></h1>
<p><b>Breed:</b> <%= @breed %></p>
<p><b>Sex:</b> <%= @sex %></p>
<h2>Foals</h2>
<ul><% @foals.each do |foals| %>
<li><%= foals %></... |
require 'spec_helper'
describe Category do
let(:category) { Category.new(
name: "Some category",
description: "This is my category description.",
)
}
context "when given all correct parameters" do
it "should be valid" do
expect(category).to be_valid
end
end
con... |
class GenerateSubjectExamReport
attr_accessor :headers
def initialize(param,agb_id,maximum_marks)
@param = param
@agb_id = agb_id
@maximum_marks = maximum_marks
end
def fetch_report_data
@score_hash = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
@studentwise_score = Hash.new { |h,... |
class Player
attr_reader :id, :wins, :losses, :statistics
def initialize(id, wins, losses)
@id = id
@wins = wins
@losses = losses
@statistics = []
end
def games
return @wins + @losses
end
def difference
return @wins - @losses
end
def addHeroStatistics(heroStatistics)
if @... |
ActiveSupport::TimeWithZone.class_eval do
def to_s(format = :default)
return utc.to_s(format) if format == :db
return localtime.rfc822 if :rfc822 == format
formats = ::Time::DATE_FORMATS
formatter = formats[format]
unless formatter
default_formatters = I18n.translate(:'time.formats', :rais... |
class Api::GoalsController < ApiController
before_action :authenticate!
before_action :find_goal, only: [ :show, :update, :destroy, :like_toggle, :comments, :comment]
before_action :validate_goal_owner, only: [ :update, :destroy ]
def index
success(data: Goal.joined_by(current_user))
end
def show
... |
# == Informacion de la tabla
#
# Nombre de la tabla: *users*
#
# id :integer(11) not null, primary key
# nombre :string(100)
# apellido :string(100)
# total :integer(11) default(0)
# profesion_id :integer(11) de... |
require 'spec_helper'
describe "SSL requirements" do
let(:studio){ Factory :studio}
describe "non-admin namespaced routes" do
it "leaves HTTP requests alone" do
get "http://example.com/studios/#{studio.id}/movies"
response.code.should == '200'
end
it "leaves HTTPS requests alone" do
ge... |
class PlataformaMLv3 < Chingu::GameObject
traits :collision_detection, :bounding_box
def setup
@image = Image['base medianaLv3.png']
end
end |
class Job
attr_reader(:job, :description)
@@all_jobs = []
define_method(:initialize) do |attributes|
@job = attributes.fetch(:job)
@description = attributes.fetch(:description)
end
define_method(:save) do
@@all_jobs.push(self)
end
define_method(:job_name) do
@job
end
define_method(... |
class CreatePages < ActiveRecord::Migration
def change
create_table :pages do |t|
t.string :name
t.string :summary
t.text :content
t.text :meta_keywords
t.string :meta_title
t.string :subheading
t.text :page_description
t.string :page_icon_url
t.boolean :info_... |
# frozen_string_literal: true
require 'common/models/base'
module EVSS
module Letters
class BenefitInformationDependent < BenefitInformation
attribute :has_survivors_pension_award, Boolean
attribute :has_survivors_indemnity_compensation_award, Boolean
attribute :has_death_result_of_disability,... |
# frozen_string_literal: true
When(/^User creates a new user$/) do
@pages.login_book_page.create_new_user
@pages.register_book_page.register_user('first_name', 'last_name', 'user_name', 'password')
end
And(/^User logs in$/) do
user = Users.book_user
@pages.login_book_page.login(user.username, user.password)
... |
class Api::UsersController < ApplicationController
def new
@user=User.new
end
def index
user=User.all
render json: user, status: :ok
end
# def show
# @user=User.find(params[:id])
#end
def show
render json: User.find(params[:id]), status: :ok
end
... |
class Card < ActiveRecord::Base
include CardEnum
IMAGE_URL = 'http://wow.zamimg.com/images/hearthstone/cards/enus/medium'
class << self
def ransackable_attributes(auth_object = nil)
%w(name card_type race rarity player_class set)
end
end
def image
"#{IMAGE_URL}/#{hearthstone_id}.png"
en... |
require 'spec_helper'
describe ProvidersController do
describe "POST 'select'" do
it "sets the current provider in the session" do
post 'select', :provider_id => "my_mock"
response.should redirect_to(login_path)
session[:current_provider_id].should eq "my_mock"
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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
require "spec_helper"
describe CacheTasks::Twitter do
describe "#run" do
let(:task) { CacheTasks::Twitter.new('kpcc') }
let(:tweets) { ["tweet1", "tweet2"] }
it "doesn't do anything if tweets are blank" do
Rails.cache.fetch("twitter:kpcc").should eq nil
task.stub(:fetch) { false }
... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# 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
#... |
class RemoveLearningDynamicIdFromPresentationSlides < ActiveRecord::Migration
def change
remove_column :presentation_slides, :learning_dynamic_id, :integer, index: true
end
end
|
class ChangeDateToString < ActiveRecord::Migration
def up
change_column :workouts, :date, :string
end
def down
end
end
|
class RemoveFirstElectionFromRepresentative < ActiveRecord::Migration[6.0]
def change
remove_column :representatives, :first_election
end
end
|
class EtDefect < ActiveRecord::Base
belongs_to :EtDefect
default_scope order(:created_at)
default_scope order("created_at ASC")
end
|
# frozen_string_literal: true
module Mahonia
class IdentifierRegistrar
class << self
##
# @param type [Symbol]
# @param opts [Hash]
# @option opts [Mahonia::IdentifierBuilder] :builder
#
# @return [IdentifierRegistrar] a registrar for the given type
def for(type, **opts)... |
# frozen_string_literal: true
module CodeAnalyzer::CheckingVisitor
# Base class for checking visitor.
class Base
def initialize(options = {})
@checkers = options[:checkers]
end
def after_check; end
def warnings
@warnings ||= @checkers.map(&:warnings).flatten
end
end
end
|
class WelcomeController < ApplicationController
skip_before_action :redirect_if_not_logged_in
def home
@user = current_user
end
end
|
module LayoutHelper
def copyright_notice_year_range(start_year)
# In case the input was not a number (nil.to_i will return a 0)
start_year = start_year.to_i
# Get the current year from the system
current_year = Time.zone.now.year
# When the current year is more recent than the start year, return... |
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
after_initialize :generate_uuid, if: :new_record?
def generate_uuid
return unless self.class.columns_hash.has_key?("uuid")
self.uuid ||= SecureRandom.uuid
end
end
|
#!/usr/bin/env ruby
require 'gli'
require 'fileutils'
begin # XXX: Remove this begin/rescue before distributing your app
require 'telApp'
rescue LoadError
STDERR.puts "In development, you need to use `bundle exec bin/telApp` to run your app"
STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the... |
class SessionsController < ApplicationController
before_action :set_item, only: [:create,:index]
def index
unless user_signed_in?
redirect_to new_user_registration_path
end
@order_address = OrderAddress.new
if current_user == @item.user
redirect_to root_path
end
if @item.ord... |
# frozen_string_literal: true
class User < ApplicationRecord
devise :database_authenticatable, :registerable, :timeoutable, :trackable,
:recoverable, :rememberable, :validatable, :confirmable
has_one :student, foreign_key: :email
has_one :teacher, foreign_key: :email
before_validation { self.email.d... |
=begin
The public_methods method takes an optional argument that can be
set to false and if omitted, is assumed to be true.
While set to true, it will list all methods publicly available to
the class of the caller along with the superclass and above (Object, Kernel, etc).
So in order to strip out all the public me... |
module Headjack
module Transaction
include DefaultAdapter
def self.auto_filter result
results = result["results"].first
if results
expand_one_column_data(results["columns"], results["data"])
else
error = result["errors"].first
raise parse_error(error["code"]).new(err... |
class User < ActiveRecord::Base
attr_accessor :login
has_one :profile, dependent: :destroy
validates :email, format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
uniqueness: { case_sensitive: false },
length: { maximum: 40 }, confirmation: true
validates ... |
class Api::V1::Follow < ApplicationRecord
belongs_to :followee, class_name: "Api::V1::User"
belongs_to :follower, class_name: "Api::V1::User"
end
|
#! /usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "hanami/cli"
Hanami::CLI.tap do |cli|
cli.register "db create", Hanami::CLI::Commands::App::DB::Create
cli.register "db create_migration", Hanami::CLI::Commands::App::DB::CreateMigration
cli.register "db drop", Hanami::CLI::Comma... |
class UsersController < ApplicationController
before_action :save_login_state, :only => [:new, :create]
before_action :authenticate_user, :only => [:edit]
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
UserMailer.activation_link(@user).deliver
#... |
require 'formula'
class Mtoc < Formula
url 'http://www.opensource.apple.com/tarballs/cctools/cctools-839.tar.gz'
sha1 'af26af8bb068f51680ebcb828125f21a6863aa3b'
depends_on 'md' => :build
def install
# Don't use the 'intall' target on the Makefiles as it'll put stuff all
# over, even if you define DS... |
# frozen_string_literal: true
module Twitch
module Bot
# Base class for implementing chat commands
class CommandHandler < EventHandler
def self.handled_events
[:user_message]
end
def initialize(event:, client:)
super
@command_aliases = []
end
def call
... |
class AuctionsController < ApplicationController
before_action :set_auction, only: [:show, :edit, :update, :destroy]
# GET /auctions
# GET /auctions.json
def index
@auctions = Auction.all
end
# GET /auctions/1
# GET /auctions/1.json
def show
end
# GET /auctions/new
def new
@auction = Au... |
require_relative 'helpers/write_log_to_csv'
module Topographer
class Importer
module Helpers
def boolify(word)
return nil if word.nil?
case word.downcase
when 'yes'
true
when 'no'
false
when 'true'
true
when 'fals... |
require 'spec_helper'
require 'data_model/fields'
describe Moon::DataModel::Fields do
subject(:basic_model) { Fixtures::BasicModel.new(name: 'Henry', age: 26) }
context 'ClassMethods' do
context '.field' do
it 'should allow nil values if allow_nil is true' do
person = Fixtures::Person.new(first_... |
require 'base64'
require 'date'
require 'digest'
require 'multi_json'
require 'uuid'
module Talis
module Authentication
# Represents the user login flow for server-side applications.
# A prerequisite to using this class is having an application registered
# with Persona in order to obtain an app ID and s... |
class CreatePrefs < ActiveRecord::Migration
def change
create_table :prefs do |t|
t.string :code, length: 2
t.string :name, length: 10
t.string :name_alnum, length: 10
t.string :area, length: 10
t.string :area_alnum, length: 10
t.timestamps
end
add_index :prefs, :code,... |
Daughters::Application.routes.draw do
resources :sessions, only: [:new, :create, :destroy]
resources :users
get "/login", to: "sessions#new"
delete "/logout", to: "sessions#destroy"
get "/logout", to: "sessions#destroy"
get "/birthdays", to: "contacts#birthdays"
get "/ping", to: "application... |
class Solution < ApplicationRecord
# 必须有名称
validates :name, presence: true
# 必须有背景介绍
validates :background, presence: true
# 必须有简介
validates :desc, presence: true
# 必须有价值点
validates :value, presence: true
# 必须有图片
validates :solution_pic, presence: true
mount_uploader :solution_pic, AttachmentUplo... |
require 'active_support/cache'
require 'jwt'
require 'openssl'
require_relative '../spec_helper'
describe Talis::Authentication::Token do
let(:cache_store) do
cache_store = ActiveSupport::Cache::MemoryStore.new
Talis::Authentication::Token.cache_store = cache_store
cache_store
end
before do
Tali... |
# == Schema Information
#
# Table name: pages
#
# id :integer not null, primary key
# title :text
# content :text
# slug :string not null
# parent_id :integer
# created_at :datetime not null
# updated_at... |
class Array
def mixed_flatten!
result = []
self.replace(_mixed_flatten(result, self))
end
def mixed_flatten
result = []
_mixed_flatten(result, self)
end
private
def _mixed_flatten(result, data)
case data
when Array
data.each { |v| _mixed_flatten(result, v) }
when Hash
... |
class CreateItems < ActiveRecord::Migration[5.2]
def change
create_table :items do |t|
t.string :genre, null: false
t.string :prodct_name, null: false
t.string :image_id
t.string :material, null: false
t.integer :price, null: false
t.integer :status, null: false
t.datetim... |
json.array!(@cash_revenues) do |cash_revenue|
json.extract! cash_revenue, :id, :category_id, :customer_id, :number_of_customers, :initial_arpu, :start_date, :end_date, :recur_frequency, :customer_growth_type, :customer_growth_amount, :customer_growth_frequency, :arpu_growth_type, :arpu_growth_amount, :arpu_growth_fre... |
require "rails_helper"
RSpec.describe WasteExemptionsShared::BuildOrganisationContact, type: :service do
subject { described_class }
let(:organisation) { enrollment.organisation }
let(:contact) { organisation.contact }
context "when the organisation is an individual" do
let(:enrollment) { create(:commence... |
Rbpm::Application.routes.draw do
resources :systems do
member do
get :update_status
end
end
resources :workers do
collection do
get :spawn
end
end
resources :steps do
member do
get :follow
end
end
resources :links
resources :jobs do
member do
g... |
# SwitchInput creates a switch to toggle a true or false input
class SwitchInput < SimpleForm::Inputs::Base
# Generates the HTML output for the input
#
# @param wrapper_options [Hash] options for the wrapper
# @return [String] HTML markup of the input
def input(wrapper_options)
merged_input_options = mer... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.