text stringlengths 10 2.61M |
|---|
require 'spec_helper'
describe RubyLie::Vector do
a3 = RubyLie::Algebra.new(:alg_A, 3)
it "can initialize a Vector from an algebra instance or from hash" do
expect(RubyLie::Vector.new([1], :alpha, a3)).not_to be_nil
expect(RubyLie::Vector.new(Matrix[[1]], :alpha, a3)).not_to be_nil
expect(RubyLie::Vec... |
module Ai
class Robot
attr_reader :gene, :game, :tick, :cache, :flag
def initialize gene
@gene = gene
@game = Game.new
@cache = Cache.new
@tick = 0
@flag = false
end
def value
data = @game.grid.dump
blank = 0
ret = 0
Size.times do |x|
Size.times do |y|
if @game.grid.conten... |
# frozen_string_literal: true
module Slack
class Text
class << self
def message(user, text)
user || I18n.t('bot')
"#{I18n.t('user')}: #{user}\n#{I18n.t('message')}:\n#{text}\n"
end
end
end
end
|
class Madden18::RightEndScorer < BaseScorer
def score
case @style
when '43'
# In a 4-3 scheme, your defensive ends are your primary pass rushers.
# They need the moves to beat larger defensive tackles but they
# also need the speed and agility to get to the QB quickly.
# 4-3 ends are a... |
# Source: https://launchschool.com/exercises/e7a26cab
(1..99).to_a.each { |x| puts x if x.odd? }
|
Given(/^I am on the news page$/) do
visit news_index_path
end
Then(/^I fill in "([^"]*)" with "([^"]*)"$/) do |field, content|
fill_in field, with: content
end
Then(/^I attach file$/) do
attach_file('news[file]', "#{Rails.root}/spec/images/Agile_workflow.png", visible: false)
end
Given(/^the following news exi... |
require 'rails_helper'
feature 'user sees own todo' do
scenario "doesn't see other's todos" do
Todo.create!(title: 'Learn React', email: 'me@jsdev.com')
sign_in_as 'me@railsdev.com'
expect(page).not_to display_todo('Learn React')
end
end
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
# Access to APP_CONFIG hash of per-environment settings
require File.join(Rails.root.to_s, 'config',... |
require 'rails_helper'
describe Player do
it "has a valid factory" do
expect(FactoryGirl.build(:player)).to be_valid
end
it "is valid with a first_name,last_name, and birthday" do
player = create(:player)
player.valid?
expect(player).to be_valid
end
it "is invalid without a first_n... |
class User < ApplicationRecord
rolify
has_secure_password
require 'bcrypt'
after_create :assign_default_role
def assign_default_role
self.add_role(:basic_user) if self.roles.blank?
end
validates_uniqueness_of :emp_id
validates_uniqueness_of :email
validates_acceptance_of :sign_of_HOD, :message... |
require 'spec_helper'
describe Her::WebMock::Model do
let(:classic_model) { ClassicModel.new(id: 15, fake_attr: "Tissue") }
let(:classic_model_with_parent) { ClassicModel.new(id: 16, fake_attr: "Tissue", classic_parent_model: classic_parent_model) }
let(:classic_parent_model) { ClassicParentModel.new(id: 42) }
... |
class Comment < ActiveRecord::Base
attr_accessible :text, :user_id, :post_id, :likes
belongs_to :user
belongs_to :post
has_many :user_likes_comments, :dependent => :destroy, order: 'created_at desc'
end
|
Pod::Spec.new do |spec|
spec.name = 'OnPasteboardChange'
spec.version = ENV['LIB_VERSION'] || '1.0.0'
spec.summary = 'A SwiftUI View modifier that triggers a callback whenever the pasteboard changes.'
spec.description = <<-DESC
OnPasteboardChange is a SwiftUI View modifier that triggers a callback whene... |
class Empenho::InterestsController < ApplicationController
before_action :set_interest, only: [:show, :edit, :update, :destroy]
# GET /interests
# GET /interests.json
def index
@interests = Interest.order(:data_envio)
end
# GET /interests/1
# GET /interests/1.json
def show
end
# GET /... |
require_relative './bootstrap.rb'
require 'rubygems'
require 'fileutils'
gem "minitest"
require 'minitest/autorun'
require 'yaml'
require 'FileReader'
class FileReaderTest < Minitest::Test
def setup
#Write a test file
@temp_location = APP_ROOT + CONFIG['files']['temp_location']
FileUtils.rm_rf @temp_... |
require 'test_helper'
class DailyLogsControllerTest < ActionDispatch::IntegrationTest
setup do
@daily_log = daily_logs(:one)
end
test "should get index" do
get daily_logs_url, as: :json
assert_response :success
end
test "should create daily_log" do
assert_difference('DailyLog.count') do
... |
class PersonForm
include Virtus
include ActiveModel::Model
# extend ActiveModel::Naming
# include ActiveModel::Conversion
# include ActiveModel::Validations
attr_reader :person
attr_reader :phone_number
attr_reader :email
attribute :person_first_name, String
attribute :person_last_name, String
attribute :ph... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe CamaleonCms::Site, type: :model do
describe 'check metas relationships' do
let!(:site) { create(:site).decorate }
it 'creates metas with correct `object_class`' do
front_cache_elements = site.metas.where(key: 'front_cache_elements').... |
Pod::Spec.new do |s|
s.name = 'Pin'
s.version = '0.1.6'
s.summary = 'Collection of methods to help with Layout constraints'
s.description = 'Collection of functions to assist in creating NSLayoutConstraints'
s.homepage = 'https://github.com/joeypatino/Pin'
s.lic... |
require 'sinatra'
require 'yahoo_weatherman'
get '/' do
erb :home
end
post '/weather' do
@post = params[:post]['location']
@client = Weatherman::Client.new({unit: "f"})
@day = get_day(@post)
@weather = get_weather(@post)
@low = get_low(@post)
@high = get_high(@post)
@average = get_average(@low, @high)
@range... |
def add_bday(bday)
bday = bday.to_s.chars.map(&:to_i) # iterate through digits of integer by turning it into an array
bday = bday.reduce( :+ ) # reduces elements in an array to their sum
if bday > 9
bday = bday.to_s.chars.map(&:to_i)
bday = bday.reduce( :+ )
end
return bday
end
def message(bday)
pat... |
class DynamicRecord::Value::Integer < ActiveRecord::Base
include DynamicRecord::Value::Base
validates_numericality_of :value
end
|
# frozen_string_literal: true
module MondialRelay
module Shipments
class Trace
module Translations
PARAMS = {
shipment_number: :Expedition,
language: :Langue,
}.freeze
RESPONSE = {
libelle01: :last_status,
relais_libelle: :parcel_shop_name,
... |
require "spec_helper"
RSpec.describe "Day 1: Calorie Counting" do
let(:runner) { Runner.new("2022/01") }
let(:input) do
<<~TXT
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
TXT
end
describe "Part One" do
let(:solution) { runner.e... |
# frozen_string_literal: true
shared_examples "WeekdayTime" do
context "with 200 minutes" do
subject(:time) { described_class.new(200) }
its(:total_minutes) { is_expected.to eq(200) }
it { is_expected.to delegate_method(:to_s).to(:total_minutes) }
describe "#to_i" do
it "returns #total_minute... |
require File.join(File.dirname(__FILE__), '..', 'lib', 'rack', 'validator', 'sinatra')
require 'sinatra'
class App < Sinatra::Base
register Rack::Validator::Sinatra
helpers do
def missing_parameters
@env['validator.missing']
end
def invalid_parameters
@env['validator.invalid']
end
... |
require 'spec_helper'
require './spec/lib/data_helpers'
describe 'GetCart endpoint' do
before do
initialize_carts
end
after do
destroy_carts
end
it 'should return status 200 if cart was found' do
get '/5ab072faf8245d0001e4e1c1'
expect(last_response.status).to eq 200
end
it 'should retu... |
class Collect
class << self
KEYWORD =/(python|ruby|rails|javascript|program|learn|show hn|developer|code|api|django|code|course|web application|design|database|pattern|hack|librar|create|hackathon)/
NEWS = /techcrunch/
include RubyHackernews
def perform
update_links
end
private
... |
class User < ApplicationRecord
# model association
has_many :tweets, dependent: :destroy
# validations
validates_presence_of :username, :name, :avatar
end
|
class Owner::CourtsController < ApplicationController
before_action :authenticate_user!
before_action :set_court, only: [:show, :update, :destroy]
#GET court
def index
@courts=current_user.courts
json_response(@courts)
end
def create
... |
class Service < ActiveRecord::Base
require 'net/http'
validates :name, presence: true
def self.api_get(api_url)
url = URI.parse(api_url)
req = Net::HTTP::Get.new(url)
res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) }
return res.body
end
def self.get_val(url, key)
res... |
class CadastrarCampanhaProfessoresPage < SitePrism::Page
# MAPEAMENTO DE ELEMENTOS DO VESTUARIO PARA CADASTRODE CAMPANHA
element :bone_check, "input[id='form:bn']"
element :bota_check, "input[id='form:bt']"
element :camiseta_check, "input[id='form:cm']"
element :combat_check, "input[id='form:cs']"... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def current_account
Account.find(1)
end
helper_method :current_account
def current_account_id
1
end
... |
class EventItemSerializer < ActiveModel::Serializer
attributes :id, :event_id, :name, :cost, :bought
end
|
# frozen_string_literal: true
class Jet < ApplicationRecord
extend FriendlyId
friendly_id :name, use: :slugged
self.primary_key = :name
has_many :texts, class_name: 'Text', primary_key: 'slug', foreign_key: 'jet_id'
has_many :links, class_name: 'Link', primary_key: 'slug', foreign_key: 'jet_id'
has_many ... |
require 'rails_helper'
RSpec.describe EmployeesController, type: :controller do
# describe "GET #index" do
# it "returns http success" do
# get :index
# expect(response).to have_http_status(:success)
# end
# end
# describe "GET #show" do
# it "returns http success" do
# get :show
... |
class CharacterBirthright < ApplicationRecord
belongs_to :character, inverse_of: :character_birthrights
belongs_to :birthright, inverse_of: :character_birthrights, counter_cache: :characters_count
accepts_nested_attributes_for :birthright, allow_destroy: true
def display_name
"#{self.character.display_nam... |
class AddHrToAccounts < ActiveRecord::Migration
def change
add_column :accounts, :hr_use, :integer
add_column :accounts, :hr_cc, :integer
end
end
|
require './lib/person'
RSpec.describe Person, '#person' do
context 'test person first_name class method' do
it 'should return first name' do
sally = Person.new first_name: 'Sally'
result = sally.first_name
expect(result).to eq 'Sally'
end
end
end |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Segmentation
class Metadata
attr_reader :values
def initialize(values)
@values = values
end
def category_count
@category_count ||= values[:category_cou... |
require('minitest/autorun')
require('minitest/rg')
require_relative('../booking.rb')
class TestBooking < MiniTest::Test
def setup
options = {
'id' => 3,
'member_id' => 5,
'group_class_id' => 7
}
@booking = Booking.new(options)
end
def test_id
result = @booking.id()
assert... |
class Event < ActiveRecord::Base
belongs_to :schedule
# validates :date,presence: true
validates :start_time, presence: true
validates :end_time, presence: true
validates :activity, presence: true
validate :time_validation
def time_validation
if end_time < start_time
errors[:end_time] << "End Ti... |
module GoogleApps
# Represents a group.
class Group < Entry
get_all { "#{ENDPOINT}/group/2.0/#{GoogleApps.connection.domain}" }
get_one { |id| "#{ENDPOINT}/group/2.0/#{GoogleApps.connection.domain}/#{id}" }
post_new { "#{ENDPOINT}/group/2.0/#{GoogleApps.connection.domain}" }
put_updated { |g... |
# Source: https://launchschool.com/exercises/3c1388d3
INT_CONVERT = {
0 => '0',
1 => '1',
2 => '2',
3 => '3',
4 => '4',
5 => '5',
6 => '6',
7 => '7',
8 => '8',
9 => '9'
}.freeze # We freeze this because it's a mutable object assigned to a constant
def signed_integer_to_string(num)
out = num.digi... |
class BuildWalk < ActiveRecord::Migration
def change
add_column :walks, :flag_1, :boolean
add_column :walks, :flag_2, :boolean
add_reference :walks, :walker
add_reference :walks, :dogs
end
end
|
class ListProduct < ApplicationRecord
# associations
belongs_to :list
belongs_to :product
# validations
validates :amount, presence: true
# validates
end
|
class Product < ActiveRecord::Base
belongs_to :user
has_many :sales
validates_numericality_of :price,
greater_than: 49,
message: "must be at least 50 cents"
end
|
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
$:.push(File.expand_path(File.dirname(__FILE__)))
require 'evolution_simulation'
require 'pbox2d'
def triple_test
pop = EvolutionSimulation::... |
class MoveAccountToAccountingGroup < ActiveRecord::Migration
def change
rename_column :spree_transactions, :account,:accounting_group_id
change_column :spree_transactions, :accounting_group_id, :integer
end
end
|
Given(/^You are in the Accounting page$/) do
visit AutomationHomePage
on(LoginPage).login_yml
on(LandingPage).menus.when_present(10).click
on(LandingPage).accounting.when_present(10).click
sleep(3)
# Adding comments, testing github connections
# Adding comments to branch
end
And(/^I see Scheduled F... |
require 'test_helper'
class ApplicationsControllerTest < ActionDispatch::IntegrationTest
setup do
@applicant = create :applicant
@business = create :business
@job = create :job
@application = create :application
end
# applications#index
test 'should show all applications as an applicant' do
... |
# == Schema Information
#
# Table name: tags
#
# id :integer not null, primary key
# content :string
# created_at :datetime not null
# updated_at :datetime not null
#
FactoryGirl.define do
factory :tag do
content { "##{Faker::Lorem.characters(10)}" }
end
facto... |
require 'spec_helper'
describe 'users/confirmations/sent' do
include_context 'devise view'
before do
render
end
it "has title" do
rendered.should have_selector('h1', :text => 'Almost there!')
end
it "has a link to resend confirmation" do
rendered.should have_link('Click here to resend confir... |
#!/usr/bin/ruby -w
require './terminal'
class ZeroMachine
def initialize(filename=nil)
@file = File.open(filename) if filename
end
def run
if @file
# Do the file thing
else
terminal = Terminal.new
terminal.clear_screen
terminal.color(:magenta, :black)
terminal.show_cu... |
class UpdateExpenseAndReceipt
attr_reader :expense
def initialize(expense)
@expense = expense
@receipt = expense.receipt
end
def update(expense_params)
@params = expense_params
update_expense_and_receipt
unless @expense.valid?
merge_errors
return false
end
true
end
... |
require 'active_support/core_ext/hash/indifferent_access'
module Datapathy::Adapters
attr_reader :options
# Adapters should extend this class, and implement the 4 CRUD methods:
# create, read, update and delete.
#
# Convention has established the following terminology:
#
# * resource - an instance ... |
# frozen_string_literal: true
require 'fileutils'
module Puppler
class Git
# class encapsulating interaction with git repository of a puppet module
#
# when initialized with the path to a module repository it initializes two directories
#
# - a working copy of the module repo as source repo
... |
class Group < ApplicationRecord
has_many :inscriptions
belongs_to :event
end
|
require 'spec_helper'
describe "permissions/new" do
before(:each) do
assign(:permission, stub_model(Permission,
:user_id => 1,
:parent1_email => "MyString",
:parent2_email => "MyString",
:token => "MyString"
).as_new_record)
end
it "renders new permission form" do
render
... |
module Roglew
module GL
CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB ||= 0x00000004
GUILTY_CONTEXT_RESET_ARB ||= 0x8253
INNOCENT_CONTEXT_RESET_ARB ||= 0x8254
LOSE_CONTEXT_ON_RESET_ARB ||= 0x8252
NO_RESET_NOTIFICATION_ARB ||= 0x8261
RESET_NOTIFICATION_STRATEGY_ARB |... |
class Student
attr_accessor :firstName, :lastName, :email, :username
# must be snakecase
# attr_reader :username, :password
# @firstName
# @lastName
# @email
# @username = "mick"
# @Password
# attributes
def initialize(firstName, lastName, email, username, password)
@first... |
require "test_helper"
feature "As a user, I want to click on keywords to see memories associated with them" do
scenario "keywords have a show template with memories" do
keyword = keywords :k1
sign_in users(:user_1)
visit keyword_path(keyword)
page.find("#memory-#{memories(:user1_memory).id}").wont_... |
Rails.application.routes.draw do
resources :departamentos
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :produtos, only: [:new, :create, :destroy, :edit, :update]
get "/produtos/busca" => "produtos#busca", as: :busca_produto
root "produtos#index... |
class CreateLogs < ActiveRecord::Migration
def self.up
create_table :logs do |t|
t.string :r1
t.string :r2
t.string :r3
t.string :r4
t.string :r5
t.string :r6
t.string :r7
t.integer :total
t.timestamps
end
end
def self.down
drop_table :logs
end... |
module Rails
module Sequel
module Logging
def log_duration (duration, message)
@controller_runtime ||= 0
@controller_runtime += duration
ActiveSupport::Notifications.instrument('sql.sequel',
:sql => message,
:name => 'SQL',
:duration => duration * 1000
... |
require 'fog/model'
module Fog
class Slicehost
class Image < Fog::Model
identity :id
attribute :name
end
end
end
|
class CreateStores < ActiveRecord::Migration
def change
create_table :stores do |t|
t.string :name
t.string :kind #种类
t.integer :price #人均
t.integer :distance #附近距离
t.integer :level #评价
t.string :logo #logo
t.integer :creater_id #创建人id
t.string :address #地址
t... |
class CreatePosts < ActiveRecord::Migration[5.2]
def change
create_table :posts do |t|
t.decimal :longitude, null: false
t.decimal :latitude, null: false
t.string :blood_type, null: false
t.integer :blood_amount, null: false
t.string :name
t.string :age
t.text :descriptio... |
class CreateScores < ActiveRecord::Migration
def change
create_table :scores do |t|
t.integer :hometeam_id
t.integer :awayteam_id
t.integer :home_goals
t.integer :away_goals
t.integer :period
t.float :time_remaining
t.integer :hometeam_league_id
t.integer :awayteam_... |
class RestaurantsController < ApplicationController
def recent
@restaurants = Restaurant.all.limit(10).order(created_at: :desc)
render :index
end
def index
@restaurants = Restaurant.all
end
def show
@restaurant = Restaurant.find(params[:id])
@reviews = @restaurant.reviews.all
end
de... |
class Circle < ActiveRecord::Base
has_many :users, :through => :friendships, :class_name => "User"
has_many :friendships
validates :circle_name, :uniqueness =>true
end
|
class Team
attr_accessor :name,:players
def initialize (name, players =[])
raise Exception unless players.is_a? Array
@name = name
@players = players
raise Exception if @name && has_bad_name?
end
#checks if a team name contains bad words
def has_bad_name?
list_of_words = %w{crappy bad lousy}
lis... |
require "spec_helper"
describe "End-to-end test" do
let(:runner) { ApiBlueprint::Runner.new }
before do
stub_request(:get, "http://cities/?name=London").to_return body: { name: "London City" }.to_json
stub_request(:get, "http://cities/?name=Manchester").to_return body: { name: "Manchester City" }.to_json
... |
require "spec_helper"
module Ayi
describe RubyStrategy do
it { should respond_to :match_file_name? }
it { should respond_to :cleanup }
it "matches rubies" do
subject.match_file_name?("example.rb").should be_true
subject.match_file_name?("hello/world.rb").should be_true
subject.match_fi... |
module Axon
module ReaderTests
def test_header_dimensions
assert_equal @image.width, @reader.width
assert_equal @image.height, @reader.height
end
def test_header_components
assert_equal @image.components, @reader.components
end
def test_io_returns_too_much_data
io... |
require "test_helper"
feature "As a user, I want to edit the details of my memories" do
before do
@user = users :user_1
sign_in @user
end
scenario "users can see an edit link on their own memories" do
# given one of their own memories
memory = memories :user1_memory
# when a user visits tha... |
# frozen_string_literal: true
RSpec.describe UsersFinder do
let!(:user1) { create(:user, first_name: 'Aa', last_name: 'Aa', email: 'ccc@gmail.com', plan_type: 'trial') }
let!(:user2) { create(:user, first_name: 'Ab', last_name: 'Ab', email: 'eee@gmail.com', plan_type: 'free') }
let!(:user3) { create(:user, first... |
require 'spec_helper'
describe FilesController do
let(:good_user) { FactoryGirl.create(:user) }
let(:bad_user) { FactoryGirl.create(:user) }
let(:activity) { FactoryGirl.create(:activity) }
let(:folder) { FactoryGirl.create(:folder,
activity: activity,
... |
class UserInfosController < ApplicationController
before_filter :authorize
before_action :find_user
def new
@user_info = UserInfo.new({:user_id => session[:user_id]})
end
def create
@user_info = UserInfo.new(user_info_params)
@user_info.user_id = @user.id
if @user_info.save
flash[:no... |
Rails.application.routes.draw do
get 'sign_up', to: 'users#new'
get 'log_in', to: 'sessions#new', as: 'login'
# post 'users', to: 'users'
resources :users
resources :sessions
get 'users/create'
get 'dashboard/index'
root to: 'dashboard#index'
# For details on the DSL available within this file, see ht... |
require 'stringio'
module SCASM
class Statement
attr_accessor :addr
def assemble io
fail 'unimplemented'
end
def to_s
fail 'unimplemented'
end
# XXX HACK
def length
io = StringIO.new
assemble io
io.length/2
end
end
class Instruction < Statement
attr_reader :opsym, :a, :b
at... |
class ActorsController < ApplicationController
def morgan
actorID = Actor.where({ :name => "Morgan Freeman" }).first.id
movieIDs = Character.where({ :actor_id => actorID }).pluck(:movie_id)
@movies = Movie.where({ :id => movieIDs })
render({ :template => "movie_templates/morgan.html.erb" })
end
en... |
class AddSalaRefToSoftware < ActiveRecord::Migration
def change
remove_column :softwares, :sala
add_reference :softwares, :sala, index: true, foreign_key: true
end
end
|
module Avocado
class Config
class << self
attr_accessor :url, :headers, :document_if, :json_path, :ignored_params
def configure(&block)
yield self
end
def headers
Array(@headers) || []
end
def document_if
@document_if || -> { true }
end
... |
class AssignmentsController < ApplicationController
before_action :require_authentication
def create
if params[:user_id]
@user = User.find_by(id: params[:user_id])
assignment = @user.assignments.build(assignment_params)
else
@project = Project.find_by(id: params[:project_id])
assign... |
class AddStatusToRedpacks < ActiveRecord::Migration
def change
remove_column :redpacks, :sent, :boolean
add_column :redpacks, :status, :integer, default: 0, index: true
end
end
|
class Recipe < ApplicationRecord
require 'csv'
# Relationships
has_many :recipe_ingredients, dependent: :destroy
has_many :ingredients, through: :recipe_ingredients
# Accept recipe_ingredients nested attributes
accepts_nested_attributes_for :recipe_ingredients, reject_if: proc { |attributes| attributes['i... |
class BookingsController < ApplicationController
def new
#@booking = Booking.new
@flight = Flight.find(params[:flight_search][:flight])
@booking = @flight.bookings.build
@passengers_num = params[:flight_search][:passengers_num].to_i
@passengers_num.times { @booking.passengers.build }
end
def create
@fl... |
class ApiEnabledController < ApplicationController
private
def api_client
DefenceRequestServiceRota.service(:auth_api).new(session[:user_token])
end
def all_organisations_by(options = {})
OrganisationFinder.new(api_client, options).find_all
end
def find_organisation_by_uid(uid:)
OrganisationF... |
module Rails3JQueryAutocomplete
# Inspired on DHH's autocomplete plugin
#
# Usage:
#
# class ProductsController < Admin::BaseController
# autocomplete :brand, :name
# end
#
# This will magically generate an action autocomplete_brand_name, so,
# don't forget to add it on your routes file
#
... |
class Admin::ProjectsController < Admin::ResourcesController
private
def permitted_params
params.permit(project: [:name, :start_date, :end_date, member_ids: []])
end
end
|
# even_numbers.rb
# Print the even numbers from 1 to 99, inclusive. All numbers should be printed
# on separate lines.
# Solution 1:
puts "One:"
for i in 1..99
puts i if i.even?
end
puts "----"
# Solution 2:
puts "Two:"
for i in 1..99
puts i if i % 2 == 0
end
puts "----"
# Solution 3:
puts "Three:"
counter ... |
class CreateQuizzes < ActiveRecord::Migration[5.0]
def change
create_table :quizzes do |t|
t.integer :mileage
t.string :vehicle_type
t.string :seat_number
t.integer :wd
t.integer :year
t.integer :color
t.integer :type
t.timestamps
end
add_reference :quizzes,... |
class User < ApplicationRecord
has_secure_password
has_many :baskets
has_many :line_items
has_many :products, through: :line_items
end
|
class KeyAction < ApplicationRecord
validates :action, presence: true
end
|
# encoding: UTF-8
require_relative "../support/service"
class StoryServices::ParseFelEPUBService < Koal::Service
attr_reader :author, :stories
def call(folder:)
content_xml_file = File.join(folder, "content.opf")
content_xml_doc = File.open(content_xml_file) { |f| Nokogiri::XML(f) }
content_xml_doc.r... |
class PlaguesController < ApplicationController
before_action :set_plague, only: [:show, :edit, :update, :destroy]
# GET /plagues
# GET /plagues.json
def index
@plagues = Plague.all
end
# GET /plagues/1
# GET /plagues/1.json
def show
end
# GET /plagues/new
def new
@plague = Plague.new
... |
# This file was generated by GoReleaser. DO NOT EDIT.
class Jocasta < Formula
desc "Logger for CLI tool from standard I/O"
homepage ""
version "1.0.5"
bottle :unneeded
if OS.mac?
url "https://github.com/marema31/jocasta/releases/download/v1.0.5/jocasta_1.0.5_Darwin_x86_64.tar.gz"
sha256 "d1ca8f124098... |
require 'rails_helper'
RSpec.describe 'Meal Entries' do
it 'As user I can add entries from the dashboard' do
user = User.create!(username: 'Gwen', password: 'supersecret')
expect(user.entries.size).to eq(0)
sign_in_as(user)
expect(current_path).to eq(dashboard_index_path)
expect(page).to have_... |
class CreateFittings < ActiveRecord::Migration
def change
create_table :fittings do |t|
t.string :typo, null: false
t.integer :sub_typo, default: 0
t.integer :wattage, default: 10
t.timestamps null: false
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.