text stringlengths 10 2.61M |
|---|
require 'VMTConn'
require 'nokogiri'
require 'active_support/core_ext/hash/conversions'
require 'yaml'
require 'cgi'
class Group
attr_accessor :vmt_userid,
:vmt_password,
:vmt_url
def initialize(vmt_userid, vmt_password, vmt_url)
#Instance Vars
@vmt_userid = vmt_userid
@vmt_password = vmt_pas... |
FactoryGirl.define do
factory :user do
first_name "First"
last_name "Name"
username "test"
password "test"
address "123 Street"
email "test@gmail.com"
end
end
|
def each_manifest(&block)
Dir.glob("manifests/*.pp") do |filename|
yield filename
end
##
## We're going to ignore all the submodules, since we don't really care how
#crappy their code is
ignores = []
regex = /(".*?")/
File.open('.gitmodules').each_line do |line|
matches = line.match(regex)
... |
require "paperclip/callbacks"
require "paperclip/validators"
require "paperclip/schema"
module Paperclip
module Glue
LOCALE_PATHS = Dir.glob("#{File.dirname(__FILE__)}/locales/*.{rb,yml}")
def self.included(base)
base.extend ClassMethods
base.send :include, Callbacks
base.send :include, Va... |
class NewsArticlesController < ApplicationController
before_filter :load_resources
def show
@news_article = NewsArticle.find(params[:id])
respond_with @news_article
end
protected
def load_resources
@sections = Section.all
end
end |
require "lucie/io"
require "lucie/log"
require "sub-process"
class Debootstrap
include Lucie::IO
attr_accessor :arch
attr_accessor :exclude
attr_accessor :http_proxy
attr_accessor :include
attr_accessor :package_repository
attr_accessor :suite
attr_accessor :target
attr_accessor :dry_run # :nodoc... |
require 'rails_helper'
RSpec.describe User, type: :model do
context 'when being created' do
it 'generates three profiles' do
user = FactoryBot.create(:user)
expect(user.profiles.size).to eq(3)
end
end
describe '#generate_default_profiles' do
before(:each) do
@user = FactoryBot.crea... |
class Qa::HomeController < ApplicationController
include Qa::Captcha
uses_viewpoints_tiny_mce :raw_options => "setup: attach_tinymce_character_count, editor_deselector: 'mceNoEditor'"
helper 'qa/links', 'qa/qa', 'qa/questions'
layout 'qa_home'
def index
featured_question_ids = CobrandParamCach... |
Capistrano::Configuration.instance(true).load do
namespace :shared do
desc "Creates missing shared dirs"
task :dirs, :roles => :app do
fetch(:shared_dirs).each do |dir|
run "mkdir -p #{shared_path}/#{dir}"
end
end
desc "Sets correct permissions on shared folders"
task :permiss... |
# Insert the `lib/` subdirectory in front of the require path
lib = File.join(File.dirname(__FILE__), 'lib')
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'blackjack/game'
RSpec.describe Blackjack::Game do
describe '#generate_deck' do
it 'generates a deck of 52 cards' do
game = Blackjack... |
class Favorite < ApplicationRecord
has_many :favorite_tags
belongs_to :destination
belongs_to :user
has_many :tags, through: :favorite_tags
has_many :forecasts, through: :destination
end
|
class Import < ActiveRecord::Base
belongs_to :account
serialize :messages
validates_presence_of :account_id
validates_associated :account
def self.create_from_importer(importer, options)
create!(:description => options[:description],
:records => importer.records, :creat... |
#Tealeaf calculator
VALID_OPERATIONS = ["1","2","3","4"]
def calculate(operation, num1, num2)
case operation
when "1"
result = num1.to_i + num2.to_i
when "2"
result = num1.to_i - num2.to_i
when "3"
result = num1.to_i * num2.to_i
when "4"
result = num1.to_f / num2.to_f
end
result
en... |
# frozen_string_literal: true
require_relative '../lib/board'
require_relative '../lib/turn'
require_relative '../lib/display'
require_relative '../lib/constants'
describe Board do
# Initialise
describe '#initialise board' do
context 'when board class instantiated empty board created' do
subject(:board_... |
class ModifyTodos20140728 < ActiveRecord::Migration
def change
change_column :todos, :sts, :string
end
end
|
require 'zip/zipfilesystem'
class GoogleProductReviewFeed
attr_accessor :max
attr_reader :file_count, :offset, :processed_count, :review_count, :cobrand
def initialize(options)
self.max = options[:max]
self.file_count = 1
@conditions = options[:conditions]
@lookup_identifiers_proc = op... |
source 'https://rubygems.org'
ruby '2.5.1'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
#gem 'mysql2', '>= 0.4.4', '< 0.6.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
gem 'rails-ujs'
#FROM DC
source 'http://gems.gemfury.com/fHtphqCq9zLeDRvssKD4/'
gem 'rails', '~> 4.2'
gem 'prot... |
$:.push File.expand_path("lib", __dir__)
# Maintain your gem's version:
require "enju_seed/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "enju_seed"
s.version = EnjuSeed::VERSION
s.authors = ["Kosuke Tanabe"]
s.email = ["nabeta@fastmail.... |
ActiveAdmin.register Product do
permit_params :name, :image, :price, :text, :category_id, :stock
form do |f|
f.inputs do
f.input :name
f.input :image
f.input :price
f.input :text, as: :text
f.input :category
f.input :stock
end
f.actions
end
# See permitted para... |
class AddMeterMetertypeid < ActiveRecord::Migration[5.0]
def change
add_column :meters, :metertype_id, :integer
end
end
|
# SketchUp to DXF STL Converter
# Last edited: February 18, 2011
# Authors: Nathan Bromham, Konrad Shroeder (http://www.guitar-list.com/)
#
# License: Apache License, Version 2.0
require 'sketchup.rb'
module CommunityExtensions
module STL
module Exporter
def self.export_mesh_file
model = Sketchup.act... |
class Item < ApplicationRecord
belongs_to :menu
has_many :order_items
has_many :orders, through: :order_items
end
|
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
def index
# @posts = Post.all
@search = Search.new(:post, params[:search])
@search.order = 'created_at'
@posts = @search.run
render 'posts/index'
end
def show
end
def new
... |
require 'spec_helper'
describe ExperiencesController, :type => :controller do
before { Warrior.create.build_experience }
let(:warrior) { Warrior.first }
before { Warrior.stub find: warrior }
describe 'GET /warriors/:warrior_id/experience' do
it 'assigns the parent member vars' do
get :edi... |
class RenameColumnsToParticipant < ActiveRecord::Migration
def change
rename_column :participants, :rh_glove_size, :right_glove_size
rename_column :participants, :lh_glove_size, :left_glove_size
end
end
|
class Admin::RestaurantsController < Admin::BaseController
before_action :set_restaurant, only: [:show, :edit, :update, :destroy]
def index
@restaurants = Restaurant.order(created_at: :asc).page(params[:page]).per(10)
end
def new
@restaurant = Restaurant.new
end
def create
@restaurant = R... |
require "test_helper"
describe "Homepage Integration Test" do
it "may be empty" do
visit root_path
page.must_have_content('Nothing Planned')
page.must_have_link('New')
end
context "with events" do
before do
future_event = Event.create!( :name => "event in the future", :starts => Date.to... |
require 'test_helper'
class CardValidator::ValidatorTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::CardValidator::VERSION
end
def test_validates_card_number
assert CardValidator::Validator.valid?("4408 0412 3456 7893")
end
def test_invalidates_card_number
refute CardVa... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 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
#
# Unless... |
class Api::V4::BloodSugarTransformer < Api::V4::Transformer
class << self
def to_response(blood_sugar)
super(blood_sugar)
.merge("blood_sugar_value" => blood_sugar["blood_sugar_value"].to_f)
end
end
end
|
Deface::Override.new(:virtual_path => "spree/products/show",
:name => "add_stock_email_to_products",
:insert_bottom => "[data-hook='cart_form']",
:partial => "spree/stock_emails/form",
:disabled => false) |
class ReadingTakesWater < ActiveRecord::Base
belongs_to :reading_assignment
auto_strip_attributes :business_name, :address, :colony, :water_meter, :diameter, :reference, :observations, :sx, :ux, :stage, :account_number, :abnormalities, :lecture, :data_access, :reading_assignment_id, :successfully_completed, :creat... |
class Course < ApplicationRecord
belongs_to :studio
has_many :reviews, dependent: :destroy
has_many :has_category
has_many :categories, through: :has_category
#validates :name, presence: true, uniqueness: true
#after_save :save_categories
def categories=(value)
@categories = value
end
#def s... |
# ------------------------------------------------------------------------------
# Have any changes happened inside the actual library code?
# ------------------------------------------------------------------------------
def app_changes?
!git.modified_files.grep(/lib/).empty?
end
# ---------------------------------... |
class RenameUriToHref < ActiveRecord::Migration
def change
rename_column :rentals, :debit_uri, :debit_href
rename_column :rentals, :credit_uri, :credit_href
rename_column :users, :customer_uri, :customer_href
add_index :users, :customer_href
end
end
|
class UserEvent < ActiveRecord::Base
belongs_to :user
before_save do
# タイムラインには30件までしか掲載されないように
user_event = UserEvent.where(user_id: self.user_id)
if user_event.count >= 30
user_event.order('created_at').first.destroy
end
end
def start_time
self.created_at ##Where 'start' is a attri... |
# Singleton for Transporter class
def transporter
@transporter ||= Transporter.new
end
# This class is to navigate across application using URLs
class Transporter
include Capybara::DSL
# Method that goes to specified URL
# @param url that represent the page URL
def go_to_url(url)
visit("https://#{url}")... |
class AddLevelStudyToWorkers < ActiveRecord::Migration
def change
add_column :workers,:lastgrade, :string
end
end
|
require "test_helper"
require "open_weather_raoni/open_weather_map_api"
require "webmock/minitest"
class OpenWeatherRaoniTest < Minitest::Test
def test_next_five_days_weather
@open_weather_api = OpenWeatherRaoni::OpenWeatherMapApi.new("any")
url = "https://api.openweathermap.org/data/2.5/forecast" +
... |
require 'spec_helper'
describe LinksController do
let(:link) { FactoryGirl.create(:link) }
describe '#index' do
before :each do
get :index
end
it 'should assign @links' do
links = Link.all
expect(assigns(:links)).to eq(links)
end
it 'should render index.html' do
expect(response).to rende... |
class AddAddrToUser < ActiveRecord::Migration
def change
add_column :users, :addr, :string
end
end
|
class Splam::Rules::GeoIP < Splam::Rule
def run
return unless @request # no ip available
return unless @request[:remote_ip] # no ip available
ip = @request[:remote_ip]
return if ip == "127.0.0.1"
if result = self.class.check_blacklist(ip)
add_score 120, "IP address (#{ip}) appears... |
module Castronaut
module Presenters
class ProxyValidate
MissingCredentialsMessage = "Please supply a username and password to login."
attr_reader :controller, :your_mission, :proxy_ticket_result, :proxies
attr_accessor :messages, :login_ticket
delegate :params, :request, :to => :control... |
class Links::Game::HockeyVizHomeTeamZone < Links::Base
def site_name
"Hockey Viz"
end
def description
"Home Zone Deployment"
end
def url
"http://hockeyviz.com/game/#{game.game_number}/homeZone"
end
def group
4
end
def position
8
end
end
|
module Mastermind
class Participant
include Ruote::LocalParticipant
attr_accessor :resource, :provider
def on_workitem
Mastermind.logger.debug :provider => type, :action => action, :params => params, :fields => fields
@resource = Mastermind.resources[self.class.type].new(params)
Mast... |
class Item < ApplicationRecord
belongs_to :user, foreign_key: 'user_id'
belongs_to :buyer, class_name: "User", foreign_key: :buyer_id, optional: true
belongs_to :brand,foreign_key: 'brand_id', optional: true
has_many :categories,through: :item_categories
has_many :comments
has_many :photos... |
require File.dirname(__FILE__) + '/../test_helper'
class OpenidControllerTest < ActionController::TestCase
def setup
@request.remote_addr = '1.2.3.4'
@openid_params = {
'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select',
'openid.identity' => 'http://specs.openid.net/au... |
require 'time'
class Lego
@@counter = 0
# El método de clase attr_accessor crea
# por nosotros lo setters/geters para las
# variables de insancia @size, @color en este caso
attr_accessor :color, :size
def initialize(color,size)
date = Time.now
@color = color
@size = size
@@counter += 1
... |
class DesignFirm
def initialize(name,website,phone,email,address,staff_size)
@name = name
@website = website
@phone = phone
@email = email
@address = address
@staff_size = staff_size
@joined = "#{Time.now.month}/#{Time.now.day}/#{Time.now.year}"
end
attr_accessor :name, :joined, :web... |
module AdminCanteen
class OrdersController < AdminCanteen::ApplicationController
load_and_authorize_resource
before_action :init_params, only: :archived
before_action :init_objects, only: :archived
has_scope :index, only: :index, default: nil, allow_blank: true
has_scope :archive, only: :archived, defa... |
require 'rails_helper'
describe "a user can sign up" do
context "a user visits the root" do
context "a user clicks the sign up button" do
context "a user fills out the form and signs up" do
it "a new user account is created" do
visit "/"
all(".top-nav-links")[2].click
... |
require "metra_tracker"
require "time"
describe MetraTracker do
before(:each) do
MetraTracker::Mongo.should_receive(:store)
end
context "in Chicagoland" do
it "reports in bounds" do
naperville = ["41.845013", "-88.308105"]
params = {"latitude" => naperville.first, "longitude" => naperville... |
class UpdateMatchesAddForecast < ActiveRecord::Migration
def change
add_column :matches, :forecast_hg, :integer
add_column :matches, :forecast_ag, :integer
add_column :matches, :forecast_homewin, :float
add_column :matches, :forecast_draw, :float
add_column :matches, :forecast_awaywin, :float
... |
class CreateAccountJoinTables < ActiveRecord::Migration
extend MigrationHelpers
def self.up
create_table "account_features_account_types", :id => false do |t|
t.column :account_feature_id, :integer
t.column :account_type_id, :integer
end
foreign_key(:account_features_acco... |
class AddLastname < ActiveRecord::Migration
def change
add_column :organization_admins, :first_name, :string
rename_column :organization_admins, :name, :last_name
end
end
|
require 'rails_helper'
RSpec.describe "taisanlops/index", type: :view do
before(:each) do
assign(:taisanlops, [
Taisanlop.create!(
:tentaisan => "Tentaisan",
:donvitaisan => "Donvitaisan",
:nguontaisan => "Nguontaisan",
:soluong => 2,
:lop => nil
),
Taisa... |
#chainring = voorblad, aantal tanden
#cog = achterblad, aantal tanden
#ratio 4 : een trapomwenteling = 4 wielomwentelingen
#gear inches = wheel diameter * gear ratio
# wheel diameter = rim diameter + (tire diameter * 2)
#circumference of wheel = PI * diameter
class Gear
attr_reader :chainring, :cog, :rim, :tire # enc... |
class Pond < ActiveRecord::Base
has_many :frogs, :dependent => :destroy
has_many :tadpoles
end
|
module Queries
module Invoices
class Sorter < Queries::Common::Sorter
SORTERS = {
'total' => Invoices::Sorters::Total
}
end
end
end
|
require 'webmachine'
require 'twilio-ruby'
class TwilioMenuResource < Webmachine::Resource
def content_types_provided
[['application/xml', :to_xml]]
end
def allowed_methods
['OPTIONS', 'GET', 'POST']
end
def post_form_data
@post_form_data ||= Hash[URI.decode_www_form(request.body.to_s)]
end
... |
# frozen_string_literal: true
module Mutations
class AddAlbum < ::Mutations::BaseMutation
description 'アルバムを追加する'
argument :apple_music_id, ::String, required: true, description: 'Apple Music か iTunes のアルバムを登録'
field :album, ::Types::Objects::AlbumObject, null: true, description: '追加されたアルバム'
def m... |
FactoryBot.define do
factory :reserved_domain do
sequence(:name) { |i| "domain#{i}.ee" }
end
end
|
require 'spec_helper'
describe WorkfileDraftController do
let(:valid_attributes) { { :content => "Valid content goes here", :workfile_id => 3939 } }
let(:user) { users(:owner) }
let!(:draft) do
workfile_drafts(:default).tap do |draft|
draft.content = "Valid content goes here"
draft.owner_id = use... |
class Vehicle
def initialize(input_hash)
@speed = input_hash[:speed] || 0
@direction = 'north'
end
def brake
@speed = 0
end
def accelerate
@speed += 10
end
def turn(new_direction)
@direction = new_direction
end
end
class Car < Vehicle
attr_accessor :fuel_type, :make, :mo... |
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Load tasks from gems
require 'capistrano/composer'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
# Customize this path to change the location of your custom tasks.
#... |
require_relative 'game_turn'
require_relative 'treasure_trove'
module StudioGame
class Game
attr_reader :title
# create initial state of game with a name and container for players
def initialize(title)
@title = title.capitalize
@players = Array.new
end
# add players to the @players ar... |
require 'net/http'
require 'uri'
require 'json'
require 'cgi'
require 'easy_http/request/connection_adapter'
require 'easy_http/request/request_params'
class EASY_HTTP
include Easy_http_Request
# attr_accessor :url
def self.get(url, options = {})
puts 'hello'
self.request_type Net::HTTP::Get, url, option... |
module Visualization
class HeatmapPresenter < Presenter
include DbTypesToChorus
delegate :rows, :x_bins, :y_bins, :x_axis, :y_axis, :type, :filters, :to => :model
def to_hash
{
:x_bins => x_bins,
:y_bins => y_bins,
:x_axis => x_axis,
:y_axis => y_axis,
:type... |
# == Schema Information
#
# Table name: application_with_versions
#
# id :integer not null, primary key
# application_id :integer indexed
# version :string
# created_at :datetime not null
# updated_at :datetime not null
# deleted_at :datetime ... |
require 'base64'
RSpec.describe CompaniesHouseXmlgateway::Service::CorporateMemberAppointment do
let(:valid_expected_response) { file_fixture('ch_default_response.xml').read }
let(:invalid_expected_response) { file_fixture('ch_invalid_response.xml').read }
DEFAULT_ADDRESS_CORPORATE_LLP_APPOINTMENT = {
premi... |
require 'wsdl_mapper/runtime/middlewares/abstract_logger'
module WsdlMapper
module Runtime
module Middlewares
class SimpleResponseLogger < AbstractLogger
def call(operation, response)
log "Response for #{operation.name}"
log response.body
[operation, response]
... |
class TaskSerializer < ActiveModel::Serializer
type :task
attributes :id, :name, :card_id, :done, :created_at, :updated_at
belongs_to :card
end
|
class AddColumnToUsers < ActiveRecord::Migration
def change
add_column :users, :type, :integer
add_column :users, :state, :integer
add_column :users, :firstname, :string
add_column :users, :lastname, :string
end
end
|
require 'pry'
def second_supply_for_fourth_of_july(holiday_hash)
# given that holiday_hash looks like this:
# {
# :winter => {
# :christmas => ["Lights", "Wreath"],
# :new_years => ["Party Hats"]
# },
# :summer => {
# :fourth_of_july => ["Fireworks", "BBQ"]
# },
# :fall => {
... |
# frozen_string_literal: true
module Stocks
class Create < ::Callable
def initialize(user:, params:)
@user = user
@params = params
end
def call
Stock.create(stock_params)
end
private
attr_reader :params, :user
def stock_params
params.merge(user: user, intere... |
require 'minitest/autorun'
require_relative 'odd_words'
class OddWordsTest < Minitest::Test
def test_reverse_odd_words_happy_path
test = OddWords.new("whats the matter with kansas.").reverse_odd_words
assert_equal("whats eht matter htiw kansas.",test)
end
def test_reverse_odd_words_edge_cases
test1... |
module Decoder
class County
include ::CommonMethods
attr_accessor :name, :fips
def initialize(args)
self.name = args[:name]
self.fips = args[:fips].to_i if args[:fips]
end
end
end |
module Xen
class XenInstance
attr_accessor :name, :memory, :id, :vcpus, :state, :time
def initialize(name, options=())
@name=name
@memory=options[:memory]
@id=options[:id]
@vcpus=options[:vcpus]
@state=options[:state]
@time=options[:time]
end
def running?... |
require 'spec_helper'
require 'mongo_doc/database_cleaner'
describe "MongoDoc::DatabaseCleaner" do
describe "#clean_database" do
let(:collections) { [people_collection, system_collection, remove_system_collection] }
let(:database) { stub(:collections => collections) }
let(:people_collection) { stub(:na... |
class Colegio < ActiveRecord::Base
has_many :docentes
has_attached_file :logo, styles: { croppable: "491x343", medium: "1280x720" }
validates_attachment_content_type :logo, content_type: /\Aimage\/.*\Z/
before_save :default_values
cattr_accessor :current_usuario
def default_values... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe RailsAdmin::Config::LazyModel do
subject { RailsAdmin::Config::LazyModel.new(:Team, &block) }
let(:block) { proc { register_instance_option('parameter') } } # an arbitrary instance method we can spy on
describe '#initialize' do
it "doesn't ... |
class Project < ActiveRecord::Base
validates :title, :description, presence: true
validates :place, presence: true
has_many :quotations, dependent: :destroy
end
|
class AdminsController < ApplicationController
layout 'application-admin'
before_filter :authenticate_admin!
def show
if current_employee.blank?
flash.now[:notice] = "Please sign in as a user and then visit www.zenmaid.com/admins/show"
authenticate_employee!
end
@users = User... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Brcobranca::Boleto::Safra do
let(:valid_attributes) do
{
valor: 0.0,
local_pagamento: 'Pagável preferencialmente na Rede Bradesco ou Bradesco Expresso',
cedente: 'Kivanio Barbosa',
documento_cedente: '12345678912',
... |
require 'test_helper'
describe Reference do
it "added to shelf automagically" do
shelf = create(:shelf)
reference = build(:reference)
reference.include_in_shelf = shelf.id
reference.save.must_equal true
shelf.references.must_include reference
end
it "is libre by its license" do
license ... |
# Write a program that takes a String argument and outputs the String in reverse.
# my attempt below, I thought I could do it like the previous problem of stringlengthmethod.rb
# puts "Please enter some text"
# string = gets.chomp
#
# def reverse(x)
# string = "#{x.reverse}"
# puts reverse
# end
# reverse(x)
# s... |
RSpec::Matchers.define :have_unique do |field_name|
match do |model_object|
factory_name = model_object.class.name.underscore.to_sym
created = FactoryGirl.create(factory_name)
objekt = FactoryGirl.build(factory_name, field_name => created.send(field_name).to_s)
objekt.valid?
objekt.errors[field_na... |
require 'spec_helper'
describe "Order shipments" do
stub_authorization!
let(:shipment) { create(:shipment, number: "H100") }
let(:order) { shipment.order }
context "index page" do
it "say 'Order has no shipments' when order has no shipments" do
order.shipments.clear
visit spree.admin_order_sh... |
require 'spec_helper'
describe Admin::UsersController do
let(:user) { FactoryGirl.create(:user) }
shared_examples("full access to users") do
describe 'GET #index' do
it "populates an array of all users" do
first_user = create(:user)
second_user = create(:user)
get :index
... |
module Entities
class User < ROM::Struct
def authenticate(password)
BCrypt::Password.new(password_digest) == password
end
end
end
|
name "application_drupal"
maintainer "ZehnerGroup"
maintainer_email "aduro@zehnergroup.com"
license "Apache 2.0"
description "Deploys and configures Drupal PHP-based applications"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1.2"
depends "... |
class ProposalsController < ApplicationController
before_action :hide_nav
def view
@content = render_to_string partial: params[:client]
end
end
|
class User < ApplicationRecord
has_one :account
# has_many :orders, :through => :accounts
validates :email, :presence => true
validates :email, :uniqueness => true
validates :username, :presence => true
validates :username, :uniqueness => true
validates :password, :presence => true
devise :database_... |
class Robot
attr_reader :status, :current_facing_direction, :current_sector, :lost_sector
def initialize(current_facing_direction)
@status = 'ACTIVE'
@current_facing_direction = current_facing_direction
end
def set_sector(sector)
@current_sector = sector
end
def lost!
@lost_sector = @curr... |
require_relative '../spec_helper'
require 'constants'
describe "Action page" do
before do
allow(Blog::PostManager).to receive(:manage_post)
allow(Kernel).to receive(:redirect)
end
it "manages the post" do
expect(Blog::PostManager).to receive(:manage_post)
post "/action"
end
it "redirects to... |
namespace :import_csv do
desc '動物データをインポートするタスク'
task animal_data: :environment do
#データベースのアニマルデータを消去
Animal.destroy_all
# 現在のアニマルデータをインポートした配列を作成
animal_list = Import.csv_data(path: 'db/csv_data/animal.csv')
# アニマルデータをデータベースに投入
Animal.create!(animal_list)
puts 'アニマルデータの投入に成功しました'
end... |
class AddFixesForReports < ActiveRecord::Migration
def change
add_timestamps(:empresas)
end
end
|
class Array_operations
def arr_length(arr)
array_length = arr.length
return array_length
end
def arr_reduce(arr)
array_reduce = arr.reduce { |sum, num| sum + num }
return array_reduce
end
def arr_map(arr)
array_map = arr.map { |n| n * 2 }
return array_map
end
end
describe Array_operations do
cont... |
class Restaurant < ActiveRecord::Base
extend FriendlyId
friendly_id :name, :use => [:slugged]
has_attached_file :logo, :styles => {:admin_thumb => '150x150', :thumb => '200x200'}
validates_attachment_content_type :logo, :content_type => /image/
acts_as_list
default_scope { order('position ASC') }
has_ma... |
require 'rails/generators/base'
module Dust
module Generators
class Base < Rails::Generators::Base #:nodoc:
def self.source_root
@_dust_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'dust', generator_name, 'templates'))
end
def self.banner
"#{$0} dust:#{gen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.