text stringlengths 10 2.61M |
|---|
require "test_helper"
describe DriversController do
let (:driver) {
Driver.create(name: "Tom", vin: "6ERL")
}
describe "index" do
it "can get index" do
get drivers_path
must_respond_with :success
end
it "can get the root path" do
get root_path
must_respond_with :success
... |
class CreateToyotaEpcPartNumberListParents < ActiveRecord::Migration
def change
create_table :toyota_epc_part_number_list_parents do |t|
t.string :part_name_code
t.string :part_name
t.string :region_area
t.timestamps
end
end
end
|
class PingPPService
def self.create_payment(order, client_ip, channel, success_url=nil)
charge_body = (order.line_items.map { |line_item| line_item.product.name }).to_json
Pingpp::Charge.create(
order_no: order.sn,
amount: (order.total_price + order.ship_fee) * 100,
subject: '开街网订单',
... |
class Designation < ApplicationRecord
belongs_to :designable, polymorphic: true
end
|
#!/usr/bin/env ruby
## Distributed under the CC0 public domain license.
## By Alison Sanderson. Attribution is encouraged, though not required.
## See licenses/cc0.txt for more information.
## GenBuild: Generates a Ninja build file for the project.
require 'set'
def hash s
res = 0
s.each_codepoint{|ch| res = re... |
require 'test_helper'
class ColectortsControllerTest < ActionDispatch::IntegrationTest
setup do
@colectort = colectorts(:one)
end
test "should get index" do
get colectorts_url
assert_response :success
end
test "should get new" do
get new_colectort_url
assert_response :success
end
t... |
# frozen_string_literal: true
require 'rspec'
require 'spec_helper'
require 'yaml'
describe 'kube-apiserver' do
let(:link_spec) do
{
'kube-apiserver' => {
'address' => 'fake.kube-api-address',
'instances' => []
},
'etcd' => {
'address' => 'fake-etcd-address',
'p... |
class AddImgUrlAndBlurbToUsers < ActiveRecord::Migration
def change
add_column :users, :img_url, :string, default: "http://www.freeiconspng.com/uploads/profile-picture-icon-png-people-person-profile--4.png"
add_column :users, :blurb, :string, default: "No blurb available."
end
end
|
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'pages#home'
# match 'contact' => 'pages#home', :as => 'contact', :via => :g... |
#---
# Excerpted from "Rails 4 Test Prescriptions",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit ... |
module Fog
module Storage
class GoogleJSON
class Mock
include Utils
include Fog::Google::Shared
MockClient = Struct.new(:issuer)
def initialize(options = {})
shared_initialize(options[:google_project], GOOGLE_STORAGE_JSON_API_VERSION, GOOGLE_STORAGE_JSON_BASE_URL)... |
class User < ApplicationRecord
has_secure_password
validates :first_name,:last_name,:email,:password, presence: true
has_many :events
has_many :event_frequencies, through :events
has_many :event_notifcations, through :events
end
|
module Mail
module Matchers
def have_sent_email
HasSentEmailMatcher.new(self)
end
class HasSentEmailMatcher
def initialize(_context)
end
def matches?(subject)
matching_deliveries = filter_matched_deliveries(Mail::TestMailer.deliveries)
!(matching_deliveries.empty?... |
require_relative '../../test_helper'
require 'sidekiq/testing'
class Bot::SmoochTest < ActiveSupport::TestCase
def setup
super
setup_smooch_bot
end
def teardown
super
CONFIG.unstub(:[])
Bot::Smooch.unstub(:get_language)
end
test "should be valid only if the API key is valid" do
asse... |
module Skiima
module Db
module Helpers
module Mysql
#attr_accessor :version
def supported_objects
[:database, :table, :view, :index, :proc]
end
def execute(sql, name = nil)
# relying on formatting inside the file is precisely what i wanted to avoid...
... |
module Api
class WorkoutController < ApplicationApiController
def create
if current_user
@workout = Workout.new workout_params
log_params.each do |current_log|
log = Log.new
if current_log[:exercise] && (valid_exercise? current_log[:exercise][:_id][:$oid])
log.exercise = Exercis... |
# frozen_string_literal: true
# ApplicationController
class ApplicationController < ActionController::API
include Knock::Authenticable
include ApplicationHelper
before_action :authenticate_user
undef_method :current_user
def invalid_resource!(resource)
Rails.logger.error "resouce_errors => #{resource.er... |
# ruby 的字符串是简单的8位字节序列, 他们通常保存可打印字符序列, 也可以保存二进制数据,
# 可以使用 #{表达式} 把任何表达式插入字符串, 如果表达式是全局变量/类变量/实例变量, 可以省略大括号
a = "my age : #{11 + 11}"
b = "line no. #$."
puts a
puts b
# 使用%q, %Q 构建字符串
x = %q(i am yut ain en)
y = %Q{waht the fuck}
z = %Q/这样也行/
h = %q[
zi fuchan
字符串
打印
]
puts x
puts y
puts z
puts h
|
class AddStatusToRentals < ActiveRecord::Migration[5.2]
def change
add_column :rentals, :checkedout, :boolean, :default => true
end
end
|
DISCUSSION_URL = %r{^/discussions?$}
DISCUSSION_ID_URL = %r{^/discussions?/(?<id>[\w\d]{24})$}
before '/discussions?/*' do
@entity_name = Discussion.name
end
[DISCUSSION_ID_URL].each do |url|
before url do
@id = params[:id]
@entity_name = Discussion.name
#discussion = Discussion.first({course_id: @id... |
class AddPreviousSessionAtToSession < ActiveRecord::Migration
def self.up
add_column :sessions, :previous_visit_at, :datetime
end
def self.down
remove_column :sessions, :previous_visit_at
end
end
|
require "rails_helper"
RSpec.feature "VisitorCanViewItems", type: :feature do
context "as a visitor" do
let!(:item) do
Item.create(title: "Parka",
description: "Stay warm in the tundra",
price: 3000,
image: "https://s-media-cache-ak0.pinimg.com/236x/90/... |
require 'fastimage'
require 'fastimage_resize'
require 'fileutils'
class VehiclePhoto < ActiveRecord::Base
MAX_IMAGE_HEIGHT = 150
MAX_IMAGE_WIDTH = 200
MAX_IMAGE_SIZE = 1024**2 * 5 # 5 MB
belongs_to :vehicle
attr_accessible :content_type, :filename, :physical_location, :virtual_path, :vehicle, :thumbnail_p... |
EventbriteClone::Application.routes.draw do
root to: "users#index"
get "/users/new", to: "users#new", as: "signup"
get "/login", to: "sessions#new", as: "login"
get "/logout", to: "sessions#destroy", as: "logout"
resources :sessions, only: [:new, :create, :destroy]
resources :users
get "/help", to: "stat... |
require 'test/unit'
require "./lib/import/parser11.rb"
class TestParser11 < Test::Unit::TestCase
def parser
Parser11.new "data/view-program2011.csv"
end
def test_title
assert_equal "Lean UX: Getting out of the deliverables business", parser[:title]
end
def test_desc
assert parser[:descriptio... |
# frozen_string_literal: true
# helper class to support subdomain routing
class Subdomain
# check if the request is for a subdomain
def self.matches?(request)
own_subdomains = %w[www img mail blog shop ftp docs mx forum admin store
cdn app]
request.subdomain.present? && !own_subdoma... |
class RenameColumnNameForPostTable < ActiveRecord::Migration
def change
rename_column :posts, :destription, :description
end
end
|
module Square
# LoyaltyApi
class LoyaltyApi < BaseApi
# Creates a loyalty account. To create a loyalty account, you must provide
# the `program_id` and a `mapping` with the `phone_number` of the buyer.
# @param [CreateLoyaltyAccountRequest] body Required parameter: An object
# containing the fields ... |
Given("I am on Add pressure page") do
visit new_profile_pressure_path(profile_email: @my_profile.email)
end
Then("I should be redirected to the pressures page") do
expect(page).to have_current_path(profile_pressures_path(profile_email: @my_profile.email))
end
Given("I am on pressures page") do
visit profi... |
#!/usr/local/bin/ruby
module Fluent
class ZabbixInput < Input
Fluent::Plugin.register_input('zabbix_alerts', self)
def initialize
super
require 'json'
require 'date'
require '/opt/microsoft/omsagent/plugin/zabbixapi'
require_relative 'zabbix_lib'
@watermark_file = '/var/opt/microsoft/omsa... |
namespace :vue do
desc 'Run vue-cli create and regenerate configuration'
task :create do
require_relative '../helpers/scripts/vue_create'
VueCreate.run!
end
desc 'Add template/style support: formats=pug,slm,sass,less,stylus'
task :support, [:formats] do |_t, args|
require_relative '../helpers/scr... |
require 'rails_helper'
describe SessionsController do
describe "GET 'new'" do
it "should be successful" do
get :new
expect(response).to be_success
end
it "should return a new user" do
get :new
expect(assigns(:user)).to be_a(User)
end
end
describe "POST 'create'" do
... |
class ApplicationController < ActionController::Base
include Clearance::Controller
include PublicActivity::StoreController
# before_action :screening
@@last_post = nil
@@last_update = nil
protected
def authorize *authorized_level
redirect_back_no_access_right unless authorized_level.include? cu... |
require 'spec_helper'
describe ToSpreadsheet::Rule::DefaultValue do
let :spreadsheet do
build_spreadsheet(haml: <<HAML)
- format_xls 'table' do
- default 'td.price', 100
%table
%tr
%td.price
%td.price 50
HAML
end
let :row do
spreadsheet.workbook.worksheets[0].rows[0]
end
context 'defa... |
class StoreProfile
include Mongoid::Document
include Mongoid::Timestamps
embedded_in :user
field :name, type: String
field :contacts, type: String
field :requisites, type: String
field :phone, type: String
field :site, type: String
field :email, type: String
field :info, type: String
field :slug... |
class Feature < ActiveRecord::Base
enum complexity: [:simple, :medium, :complex]
belongs_to :project
end
|
class PrinciplesController < EvaluationsController
before_action :require_resort_or_group_leader
before_action :validate_correct_group
def index
@evaluation = Evaluation.find(params[:evaluation_id])
end
def update
@principle = Principle.find(params[:id])
@principle.update(principle_params)
end... |
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
false
end
def show?
scope.where(:id => record.id).exists?
end
def create?
false
end
def new?
create?
end
def update?
false
#return tr... |
class CreateEmailTemplatesFaxAssignableJoinsFaxSourcesAndFaxes < ActiveRecord::Migration
def up
create_table "email_templates", :force => true do |t|
t.string "name", :default => "", :null => false
t.text "subject", :null => false
t.text "body", :n... |
# frozen_string_literal: true
module Api
module V2
class MovieSerializer < BaseSerializer
attributes :id,
:title
belongs_to :genre
end
end
end
|
require 'listing1.14.rb'
class Book
include Printable
def initialize(message)
@message = message
end
def print
"Book: #{@message}"
end
end |
require_relative 'report'
class Contact::Position
attr_reader :bearing
include Positionable
def initialize(reports)
@reports = Array(reports)
update_details
end
def add_report(report)
if report.time > time
@reports = Array(report)
update_details
elsif report.time == time
... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.manager?
can :manage, :all
elsif user.supervisor?
can [:update, :create, :read, :destroy ], [ FitnessGoal,
Feature,
Attendan... |
module SyntaxHighlighting
class Highlighter
def initialize(config = SyntaxHighlighting.config)
raise "theme_file not setup in config" unless config.theme_file
raise "theme_file not setup in config" unless config.language_files
@repository = SyntaxHighlighting::MultiLanguageRepository.new(config... |
class Admin::FaqsController < AdminController
def index
@groups = FaqGroup.order :position
end
def new_group
@group = FaqGroup.new
end
def create_group
@group = FaqGroup.new(params[:faq_group])
if @group.save
redirect_to admin_faq_index_path, :notice => 'FAQ group succesfully cr... |
class FloatFormatValidator < ActiveModel::EachValidator # :nodoc:
def validate_each(record, attribute, value)
Float(value)
rescue ArgumentError, TypeError
record.errors.add(attribute, 'is not a Float format')
end
end |
class PosicosController < ApplicationController
before_action :set_posico, only: [:show, :edit, :update, :destroy]
# GET /posicos
# GET /posicos.json
def index
@posicos = Posico.all
end
# GET /posicos/1
# GET /posicos/1.json
def show
end
# GET /posicos/new
def new
@posico = Posico.new
... |
require 'rails_helper'
RSpec.describe Api::V1::SessionsController do
describe 'POST #create' do
let!(:existing_user) { create(:user, password: 'SWAGLORD') }
context 'successful' do
it 'returns ' do
session_attributes = {
email: existing_user.email,
password: 'SWAGLORD'
... |
require 'rails_helper'
RSpec.describe Users::RegistrationsController do
include UsersHelper
before :each do
@request.env["devise.mapping"] = Devise.mappings[:user]
end
describe "user not registered" do
before :all do
@user = attributes_for(:user)
end
describe "GET #new" do
it "r... |
require 'rails_helper'
describe OrderItem, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:build_menu) }
it { is_expected.to belong_to(:order) }
it { is_expected.to belong_to(:combo_item) }
it { is_expected.to have_many(:order_item_combos) }
it { is_expected.to have_man... |
class User < ActiveRecord::Base
belongs_to :felica
belongs_to :group
has_many :events
def internal?
role == "internal"
end
end
|
# code here!
class School
attr_accessor :school, :roster
def initialize(name)
@school = name
@roster = {}
end
def add_student(students, grade)
roster[grade] ||= []
roster[grade] << students
# students.each do |student|
# roster[grade]<<student
# end
end
def gr... |
require 'spec_helper'
describe Maestro::Util::Shell do
# it 'should create a script' do
# path = subject.create_script "some shell command"
#
# File.exists?(path).should be_true
# end
# it 'should create a script without random path' do
# subject = Maestro::Util::Shell.new("/tmp/maestro-test... |
class AddMoreColumnsToPaymentOrders < ActiveRecord::Migration
def change
add_column :payment_orders, :perception, :string
add_column :payment_orders, :total, :string
add_column :payment_orders, :sub_total, :string
add_column :payment_orders, :guarantee_fund_n1, :string
add_column :payment_orders, ... |
class Post < ActiveRecord::Base
validates :title, :author, presence: true
validates :subs, length: { minimum: 1 }
belongs_to :author,
class_name: :User
has_many :post_subs, dependent: :destroy
has_many :subs, through: :post_subs
has_many :votes, as: :votable
# has_many :comments
def comments
... |
class PostsComment < ActiveRecord::Base
validates :content, :presence => true, :length => {:maximum => 120}
belongs_to :post
belongs_to :user
belongs_to :provider
has_many :posts_comments_likes, :include => :user
# post to remote
def remote! provider_id = nil
return false unless (self.valid?)
... |
require 'rails_helper'
RSpec.describe ProductsController, type: :controller do
describe "products#index action" do
it "should launch and sign into the products page correctly" do
user = FactoryBot.create(:user)
sign_in user
get :index
expect(response).to have_http_status(:success)
en... |
class Users::InvitationsController < Devise::InvitationsController
prepend_before_action :prepare_invite, only: [:edit, :update]
before_action :load_invite, only: [:edit, :update]
def edit
self.resource = resource_class.find_by_invitation_token(params[:invitation_token], true) || resource_class.new
# ... |
# @author Communication Training Analysis Corporation <info@ctacorp.com>
#
# Base Controller class; integrates Authlogic and provides gate keeper
# before_filter functions.
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :require_user
helper_method :current_user_session, :c... |
# frozen_string_literal: true
# rubocop:todo all
$sdam_formatter_lock = Mutex.new
module SdamFormatterIntegration
def log_entries
@log_entries ||= []
end
module_function :log_entries
def clear_log_entries
@log_entries = []
end
module_function :clear_log_entries
def assign_log_entries(example_i... |
require_relative "../config/environment.rb"
require 'active_support/inflector'
require 'pry'
class Song
def self.table_name
self.to_s.downcase.pluralize
# Note that the .pluralize method only works because we required reflector up top.
end
def self.column_names
DB[:conn].results_as_hash = true
... |
CURRENT_MOVIE_KEY = "CurrentMovie"
class DemoTableViewController < UITableViewController
def initWithStyle(tableStyle)
super(tableStyle)
plistPath = NSBundle.mainBundle.pathForResource("DemoMovies", ofType:"plist")
plistData = NSData.dataWithContentsOfFile(plistPath)
error_ptr = Pointer.... |
require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'capybara/rspec'
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper.rb"` to ensure that it is only
# l... |
require 'rails_helper'
RSpec.describe Book, type: :model do
before do
@book = Book.create(title: "title", author: "author", price: 5000, genre: 5, released_at: "2020-05-05", story: "story", icon: "icon_URL")
@user= User.new(name: "name", introduce: "introduce", icon: "icon_URL", admin: false, email: "test@e... |
class Video < ActiveRecord::Base
validates :video_id, presence: true
validates :title, presence: true
validates :duration, numericality: { greater_than: 0 }
validates :file_size, numericality: { greater_than: 0 }
validate :upload_date, :valid_date?
def valid_date?
date = upload_date_before_type_cast
... |
require 'pdf-reader'
require 'strscan'
class Importers
end
class Importers::PdfEcad
CATEGORIES = {"CA" => "Author", "E" => "Publisher", "V" => "Versionist", "SE" => "SubPublisher"}
def works
res = []
curr = {}
reader = PDF::Reader.new("careqa.pdf")
reader.pages.each do |page|
... |
class WeatherService
def initialize(latitude, longitude)
@latitude = latitude
@longitude = longitude
end
def get_weather
response = darksky_conn.get("forecast/#{ENV['DARKSKY_API_KEY']}/#{@latitude},#{@longitude}")
JSON.parse(response.body, symbolize_names: true)
end
private
def dark... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Silkey::Settings, type: :model do
subject { described_class }
it { expect(described_class.SCOPE_DIVIDER).to eq(',') }
it { expect(described_class.MESSAGE_TO_SIGN_GLUE).to eq('::') }
it { expect(described_class.SILKEY_REGISTERED_BY_NAME).to ... |
module Guard
class Unity
module Options
DEFAULTS = {
test_on_start: true,
project_path: Dir.pwd,
unity: '/Applications/Unity/Unity.app/Contents/MacOS/Unity',
results_path: Dir.pwd + '/UnitTestResults.xml'
}
class << self
def with_de... |
#---
# Excerpted from "Rails 4 Test Prescriptions",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit ... |
require 'spec_helper'
describe WordSerializer do
let(:word) { create(:word) }
let(:serializer) { WordSerializer.new(word).to_json }
let(:response) { JSON.parse(serializer, symbolize_names: true) }
it "should return id" do
expect(response[:id]).to eq(word.id)
end
it "should return name" do... |
# frozen_string_literal: true
module EtAzureInsights
# The feature detector is used to conditionally define code depending on dependency requirements.
# This is used to enable certain features depending on the environment.
#
# For example, if you have sidekiq installed, it will hook into it. If you don't, the... |
require 'rails_helper'
RSpec.describe MiniDraftPicksController, type: :routing do
describe 'routing' do
it 'routes to #index' do
expect(get: 'leagues/1/draft_picks').to route_to('draft_picks#index', league_id: '1')
end
it 'does not route to #new' do
expect(get: 'leagues/1/draft_picks/new').t... |
class InvalidGuessError < StandardError
end
class PlayerDeadError < StandardError
end
class Guesser
NUM_LIVES_DEAD = 0
attr_accessor :number, :lives
def initialize
@number = 10
@lives = 2
end
def guess(num)
begin
if num.class != Fixnum
raise... |
class AddOldImageIdToArtists < ActiveRecord::Migration
def change
add_column :artists, :id_old_image, :integer
add_column :artists, :audio_sample_title, :string
end
end
|
class DataPoint < ActiveRecord::Base
attr_accessible :chromosome, :end_point, :probe, :start_point, :y_point
has_and_belongs_to_many :subjects
has_and_belongs_to_many :annotations
def as_json(opts = {})
{
start: start_point,
end: end_point,
y: y_point.to_f
}
end
end |
# Build a simple guessing game
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: correct answer, guess
# Output: is guess equal to answer
# Steps:
# create instance of GuessingGame class with answer as argument
# guess is random
# if guess is correct, dis... |
require 'spec_helper'
describe Notification do
before do
@notification = Factory(:notification)
@comment = Factory(:comment)
@recipe = Factory(:recipe)
end
it "should be valid with all attributes" do
@notification.should be_valid
end
it "should not be valid without a sender" do
@notific... |
# encoding: UTF-8
class Treet::Gitfarm < Treet::Farm
attr_reader :author
def initialize(opts)
raise ArgumentError, "No git farm without an author for commits" unless opts[:author]
super
@repotype = Treet::Gitrepo
@author = opts[:author]
end
def self.plant(opts)
super(opts.merge(:repotype ... |
require 'rails_helper'
RSpec.describe BillController, type: :controller do
describe 'GET #bill' do
render_views
let(:action) { get :show }
it 'returns a 200 success' do
action
expect(response.status).to eql 200
end
context 'when there is no bill' do
before { allow(Bill).to r... |
Gem::Specification.new do |spec|
spec.name = "diverge"
spec.version = "1.5.2"
spec.summary = "Distribution divergences."
spec.description = "A simple collection of functions for determining the divergence between two distributions."
spec.authors = ["Evan Senter"]
spec.email = "evans... |
module HsMath
module OperationDefinerHelper
def self.included(mod)
class << mod
def define_unary_operation(opr_name)
define_singleton_method(:included) do |cls|
cls.class_eval do
define_singleton_method(opr_name) do |_a|
raise NotImplementedError
... |
class FavoritesController < ApplicationController
before_filter :require_user, :except => :show
def show
@knotebook = Favorite.find(params[:id])
@comments = @knotebook.comments
@original = @knotebook.original
respond_to do |format|
format.html { render 'knotebooks/show' }
end
end... |
# frozen_string_literal: true
require "rails_helper"
RSpec.describe User, type: :model do
it "is invalid with a duplicate email address" do
FactoryBot.create(:user, email: "hoge@example.com")
user = FactoryBot.build(:user, email: "hoge@example.com")
user.valid?
expect(user.errors[:email]).to include... |
class Event < ApplicationRecord
belongs_to :creator, foreign_key: :creator_id, class_name: 'User'
end
|
module Alf
module Iterator
module Base
#
# Wire the iterator input and an optional execution environment.
#
# Iterators (typically Reader and Operator instances) work from input data
# that come from files, or other operators, and so on. This method wires
# this input data t... |
class DriversController < ApplicationController
before_action :set_driver, only: [:show, :edit, :update, :destroy]
before_action :set_gopay
skip_before_action :authorize, only: [:new, :create]
def index
@drivers = Driver.where("id = ?", session[:driver_id])
respond_to do |format|
format.html { r... |
class User < ApplicationRecord
has_secure_password
validates :password,
:length => { in: 6..64 },
:allow_nil => true
end
|
class Sea
attr_accessor :colums, :rows , :matrix_sea
def initialize(m, n)
@colums, @rows = m, n
@matrix_sea = Array.new(n) { Array.new(m) }
(0..n-1).map{|i| (0..m-1).map{|j| @matrix_sea[i][j]= rand(2)} }
print_matrix_sea(@matrix_sea)
end
def set_islands_at_random(matrix_sea, row, col, visited_... |
RSpec.describe EditorConfigGenerator::FileGenerator do
context 'A collection of one EditorConfig object is provided' do
let(:configs_sensible_defaults) do
[EditorConfigGenerator::EditorConfig.new(root: true,
indent_style: 'space',
... |
class Network < ActiveRecord::Base
has_and_belongs_to_many :users, :join_table => :networks_users
ActiveRecord::Base.include_root_in_json = false
attr_accessor :password
before_save :encrypt_password
validates_confirmation_of :password
validates_presence_of [:name], :on => :create
validates_presence_of ... |
require 'rails_helper'
RSpec.describe "Application page - As a user", type: :feature do
before(:each) do
@shelter_1 = Shelter.create( name: "Henry Porter's Puppies",
address: "1315 Monaco Parkway",
city: "Denver",
sta... |
class Api::V1::GamesController < ApplicationController
def create
@game = Game.create(game_param)
if @game.valid?
@game.user.ranking = @game.new_ranking
render json: { game: GameSerializer.new(@game) }, status: :created
else
render json: { error: 'failed to create game' }, status: :not_... |
%w{personal oss}.each do |dir|
directory "#{node['sprout']['home']}/#{node["workspace_directory"]}/#{dir}" do
owner node['current_user']
mode "0755"
action :create
end
end
|
class Stats::DailyLimitsQuery
attr_reader :user
def self.call(user:)
new(user: user).call
end
def initialize(user:)
@user = user
end
def call
user.days.where(date: current_month).order(date: :asc).each_with_object({}) do |day, memo|
memo[day.date] = day.limit_amount_cents / day.limit_am... |
class Poll < ActiveRecord::Base
validates :user_id, :question, presence: true
belongs_to :user
has_many :responses, dependent: :destroy
end
|
module Types
class User < Types::BaseObject
description "A user"
field :id, ID, null: false
field :token, String, null: false
field :role, String, null: false
field :email, String, null: false
field :encrypted_password, String, null: false
field :created_at, GraphQL::Types::ISO8601DateT... |
class Place < ActiveRecord::Base
include FriendlyId
attr_accessible :name, :key, :keywords, :description, :order, :province_id
# Associations
belongs_to :province, :counter_cache => true
has_many :areas, :as => :areable, :dependent => :destroy
# FriendlyId
friendly_id :key, :use => :slugged
#Simple... |
require_relative "../models/dice"
require 'forwardable'
class MethodMissingDelegation
def initialize
@dice = Dice.new(100)
end
def method_missing(method, *args, &block)
@dice.send(method, *args, &block) if Dice.method_defined? method.to_sym
end
end
dice = MethodMissingDelegation.new
puts dice.roll
... |
class CreateTitleTypes < ActiveRecord::Migration
def change
create_lookup_table :title_types
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.