text
stringlengths
10
2.61M
require 'sinatra/base' module Sinatra ## # Helpers for Tweet controller module TweetHelpers ## # do an action (favorite, retweet) with a tweet def action_tweet(action) must_login if action == :retweet model = Retweet elsif action == :favorite model = Favorite ...
require "yaml" MESSAGES = YAML.load_file("./loan_calculator_messages.yaml") LANGUAGE = "en" def prompt(message, after = nil) main_message = MESSAGES[message] ? MESSAGES[message][LANGUAGE] : message suffix = after ? " #{after}" : "" puts("=> #{main_message}#{suffix}") end def valid_number?(number) (number.to_...
include_recipe 'unicorn' Chef::Log.info "-" * 70 Chef::Log.info "Unicorn Config" template "#{node['errbit']['deploy_to']}/shared/config/unicorn.conf" do source "unicorn.conf.erb" owner node['errbit']['user'] group node['errbit']['group'] mode 00644 end template "/etc/init.d/unicorn_#{node['errbit']['name']}"...
class Card attr_reader :number, :kind def initialize(number, kind) @kind = kind @number = number end def color if [:hearts, :diamonds].include? @kind :red else :black end end end class Game attr_reader :play, :name @@deck = [] def initialize(name) @play = []...
class Trabalho < ApplicationRecord belongs_to :disciplina validates :descricao, presence: true end
Rails.application.routes.draw do root to: 'portfolios#index' resources :portfolios, only: :index resources :experiences, only: :index resources :skills, only: :index resources :productions, only: :index end
require 'rails_helper' RSpec.describe Event, :type => :model do describe ".sum_enrollment_time" do subject { Event.sum_enrollment_time Event.all } let!(:user) { Fabricate(:user) } context "総在籍時間が59秒以下" do context "レコードが1件のとき" do before do datetime = DateTime.new(2017, 3, 1) ...
module Stradivari module Concerns module CssFriendly extend ActiveSupport::Concern def css_friendly dom_id dom_id.gsub( /[\[\]:.,]/, '_' ) end end end end
module ReportsKit class RelativeTime LETTERS_DURATION_METHODS = { 'y' => :years, 'M' => :months, 'w' => :weeks, 'd' => :days, 'h' => :hours, 'm' => :minutes, 's' => :seconds } LETTERS = LETTERS_DURATION_METHODS.keys.join def self.parse(string, prevent_excepti...
module Neo4j module ActiveRel module Callbacks #:nodoc: extend ActiveSupport::Concern include Neo4j::Shared::Callbacks def save(*args) unless _persisted_obj || (from_node.respond_to?(:neo_id) && to_node.respond_to?(:neo_id)) fail Neo4j::ActiveRel::Persistence::RelInvalidError,...
module Steam class Hero attr_reader :raw_hero def initialize(raw_hero) @raw_hero = raw_hero end def id @raw_hero['id'] end def name @raw_hero['name'].split('_')[3..-1].join(' ').capitalize end end end
require 'spec_helper' describe Admin::DiscountsController do let(:discount) {FactoryGirl.create(:discount)} context "with user" do before do @request.env["devise.mapping"] = Devise.mappings[:user] sign_in user end let(:user) {FactoryGirl.create(:user, :username => 'kat')} describe "GET 'index'" do ...
class Admin::BaseController < ApplicationController before_action :require_admin def require_admin return if current_user.admin? redirect_to root_path end end
class MergeConsultantIdIntoFacilitatorId < ActiveRecord::Migration def change Review.with_deleted.where.not(consultant_id: nil).find_each do |r| r.update_column(:facilitator_id, r.consultant_id) end remove_column :reviews, :consultant_id end end
module EasyPatch module WikiFormattingPatch def self.included(base) base.extend(ClassMethods) base.send(:include, InstanceMethods) base.class_eval do alias_method_chain :wikitoolbar_for, :easy_extensions end end module InstanceMethods # after_submit: html_fragm...
Capistrano::Configuration.instance.load do set_default(:resque_user) { user } set_default(:resque_pid) { "#{current_path}/tmp/pids/resque.pid" } set_default(:resque_log) { "#{shared_path}/log/resque.log" } set_default(:resque_workers, 2) set_default(:resque_queue, "*") set(:resque_env){ unicorn_env } set(:resque_nam...
class User < ActiveRecord::Base # attr_accessible :title, :body validates_presence_of :name validates_presence_of :email validates_presence_of :password #validates_uniqueness_of :email attr_accessible :email, :password before_save do |record| unless self.unique then raise "An user with tha...
require 'rails_helper' RSpec.describe StringDate, type: :model do describe 'method' do describe 'to_date' do it 'for date' do expect(described_class.new('2000-1-1').to_date).to eq Date.new 2000, 1, 1 end it 'handles empty' do expect(described_class.new('').to_date).to be_nil ...
class CreateTransactions < ActiveRecord::Migration def change create_table :transactions do |t| t.string :street t.string :city t.integer :zip t.string :state t.integer :beds t.integer :sq_feet t.string :category t.datetime :sale_date t.float :price t.fl...
class AddAttachmentAttachmentToIncidentattachments < ActiveRecord::Migration[6.0] def self.up change_table :incidentattachments do |t| t.attachment :attachment end end def self.down remove_attachment :incidentattachments, :attachment end end
require 'deck' require 'spec_helper' describe 'deck' do let(:deck) { Deck.new } it 'should have 52 cards' do expect(deck.count).to eq(52) end it 'should deal out cards' do taken_cards = deck.take(5) expect(deck.count).to eq(47) expect(taken_cards.count).to eq(5) end it "should be a...
# -*- encoding : utf-8 -*- require 'spec_helper' require 'bitcoin_reward_era/version' Module BitcoinRewardEra do it 'has a constant VERSION' do BitcoinRewardEra::VERSION.must_equal '0.0.2' end end
# require "rails_helper" # # # let(:team) { Team.find_by(name: "Tropics") } # # it "creates a team" do # expect(team).to_not be_nil # end # # it "redirects to the new team's page" do # expect(current_path).to eq(team_path(team)) # end # describe TeamsController, type: :controller do # let(:attributes) do ...
require "minitest/autorun" require_relative '../../lib/action/place.rb' require_relative './robot_maker.rb' class TestPlace < Minitest::Test def test_act_place place = Game::Place.new robot = RobotMaker::create(1, 3, "WEST") x, y, direction = place.act(robot, "PLACE 1,3,WEST") assert_equal 1, x ...
class MoveDeliveryTimeFromChannelToAssignment < ActiveRecord::Migration[6.0] def change remove_column :channels, :delivery_time, :time, null: false, default: '07:00:00' add_column :book_assignments, :delivery_time, :time, null: false, default: '07:00:00' end end
namespace :db do desc "Fill database with sample data" task populate: :environment do admin = User.create!(name:"Sarah",email:"dow213@lehigh.edu",password:"123456",password_confirmation:"123456") admin.toggle!(:admin) 98.times do |n| name = Faker::Name.name email = "test-#{n+1}@lehigh.edu" ...
module YesOrNo def yes_or_no?(string) string = string.dup.chomp.downcase.strip ['yes', 'no', 'y', 'n'].include?(string) end def yes?(string) string = string.dup.chomp.downcase.strip return true if string == 'yes' || string == 'y' false end def no?(string) string = string.dup.chomp.downcase.strip ...
#!/usr/bin/env ruby require 'pp' require 'pathname' require 'fileutils' require_relative '../lib/osgeo/termbase.rb' # require 'pry' filepath = ARGV[0] if filepath.nil? puts 'Error: no filepath given as first argument.' exit 1 end if Pathname.new(filepath).extname != ".csv" puts 'Error: filepath given must hav...
class CreateGeneralUseRegistersCpus < ActiveRecord::Migration def change create_table :general_use_registers_cpus do |t| t.string :pc t.string :ir t.string :mar t.string :mbr t.string :r1 t.string :r2 t.string :r3 t.string :r4 t.string :r5 t.string :r6 ...
class Card RANKS = (2..10).to_a + [:J, :Q, :K, :A] SUITS = [:S, :D, :H, :C] include Comparable attr_reader :rank, :suit def initialize(rank, suit) @rank = rank @suit = suit end def value case rank when :K 13 when :Q 12 when :J 11 when :A 1 else ...
class Transaction::InternalTransfer::InactivityFee < Transaction::InternalTransfer FEE_PERCENTAGE = 10 FIXED_FEE = 10 def self.charge_person(person) from_account = person.account balance = from_account.balance return if balance <= 0 if balance <= 10 fee = balance else fee = ((bal...
require 'spec_helper' describe DeploymentTargetMetadata do it { should belong_to(:deployment_target) } it { should validate_presence_of(:agent_version) } it { should validate_presence_of(:adapter_version) } it { should validate_presence_of(:adapter_type) } end
require 'test_helper' class AnswersControllerTest < ActionController::TestCase setup do @answer = answers(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:answers) end test "should get new" do get :new assert_response :success end ...
require 'socket' module Bitcourier module Network class Server attr_reader :port def initialize(context, options = {}) @context = context @port = options.fetch(:port, Bitcourier::CONFIG[:default_port]) end def run @server = TCPServer.new port puts "S...
require 'spec_helper' require 'street_address' describe Locuser do before(:context) do Locuser.config.parser_class = ::StreetAddress::US end after(:context) do Locuser.config.parser_class = nil end context 'parsing addresses with StreetAddress gem' do let(:addr) { Locuser.config.parser_class = ...
class ListContainer attr_accessor :lists, :block def initialize(&block) @lists = [] @block = block end def add(list_id, list = nil, text = nil, options = {}, &block) text, options, list = list, text, block if block_given? options, text = text, options if Hash === text if list and (Proc ==...
require 'spec_helper' describe 'openstacklib::db::mysql::host_access' do let :pre_condition do "include mysql::server\n" + "openstacklib::db::mysql { 'nova':\n" + " password_hash => 'AA1420F182E88B9E5F874F6FBE7459291E8F4601'}" end shared_examples 'openstacklib::db::mysql::host_access examples' do ...
class GamesController < ApplicationController before_action :authenticate_user!, only: [:new, :create, :edit, :update, :destroy] def index @games = Game.all end def new @game = Game.new end def create @game = current_user.games.create(game_params) if @game.valid? redirect_to root_...
# -*- mode: ruby -*- # vi: set ft=ruby : # A Vagrantfile to set up three VMs, a webserver, a database server # and a admin webserver, connected together using an internal # network with manually-assigned IP addresses for the VMs. # Original author: David Eyers (COSC349 Lab06) # Modified by: Jakob Harvey Vagrant.conf...
class User < ApplicationRecord authenticates_with_sorcery! has_many :book_assignments, dependent: :destroy has_many :subscriptions, dependent: :destroy scope :activated_in_stripe, -> (active_emails) { where(plan: :free).where(email: active_emails) } # stripeで購読したけどまだDBの支払いステータスに反映されていないuser scope :canceled...
require_relative '../../test_helper' class ImageTest < Minitest::Test def setup @printer = Escpos::Printer.new end def test_image image_path = File.join(__dir__, '../../fixtures/tux_mono.png') image_file = File.new image_path image = Escpos::Image.new image_file, processor: "MiniMagick" ...
require 'spec_helper' describe Vote do subject(:vote) { build(:vote) } describe "#sum_unique_candidate" do let(:candidate) { create(:candidate) } let!(:votes) { create_list(:vote, 2, candidate: candidate) } before :each do votes.each { |vote| vote.active! vote.email_hash } end it "incre...
class AddDisplayOption < ActiveRecord::Migration def change add_column :peer_allies, :display, :boolean end end
# frozen_string_literal: true require_relative 'test_helper' module Dynflow class ExecutionPlan describe Hooks do include PlanAssertions let(:world) { WorldFactory.create_world } class Flag class << self attr_accessor :raised_count def raise! self.rais...
class ApplicationController < ActionController::Base protect_from_forgery before_filter :find_root_categories, :initialize_cart private def initialize_cart @cart = session[:cart] ||= Cart.new end def find_root_categories @root_categories = Category.roots.order(:position) end ...
require 'test_helper' class SaleTest < ActiveSupport::TestCase def setup @voucher = products(:voucher) @tshirt = products(:tshirt) @mug = products(:mug) end # test method get_discount_product(product,sale_quantity) test "get_discount_product without params c0" do discount = Sale.get_discou...
class AddSubtotalToEntries < ActiveRecord::Migration def change add_money :entries, :subtotal, amount: { null: true, default: nil } end end
class SessionsController < ApplicationController def new end def create # find the user using the email user = User.find_by_email params[:email] # if the user is found and the user's password authenticates if user && user.authenticate(params[:password]) # store the user_id in the ...
class ChangeMessagesEnabledToDefaultToTrueOnIdea < ActiveRecord::Migration def self.up change_column_default :ideas, :messages_enabled, true end def self.down change_column_default :ideas, :messages_enabled, false end end
World(Rack::Test::Methods) Given /^I sent a valid json order data with one product$/ do header 'Accept', 'application/json' header 'Content-Type', 'application/json' post '/api/order.json',{ :customer => { :first_name => 'Calvin', :last_name => 'Tee', :email => 'calvin@example.com'}, :products => [{ :id ...
require File.dirname(__FILE__) + '/test_helper' context "StructoUrlGen" do test "It can generate a correct CREATE query with NO attributes" do resource = StructoUrlGen.create_query "app_name", "Person", "11111", "22222" assert resource.url == "app_name.structoapp.com/api/person.json?public_key=11111&private_...
#encoding: utf-8 require_relative '../lib/pdist' require 'test/unit' class TestPDist < Test::Unit::TestCase def setup @a = %w(a b c d) @b = @a.reverse @c = %w(b d c a) end def test_distances assert_equal([0,0,0,0], PDist.distances(@a,@a)) assert_equal([3,1,1,3], PDist.distances(@a,@b)) assert_equal([3...
require 'rails_helper' RSpec.feature "visitor can search for spaces" do scenario "they enter a valid search query into the homepage search" do planet = create(:planet) user = create(:user) spaces = create_list(:space, 4, planet: planet, approved: true) user.spaces << spaces # unmatching_space_1 =...
#require_relative '~/BearReps/project3/app/helpers/scraper.rb' require 'faker' # 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 rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movie...
class ProblemsController < ApplicationController before_action :authenticate_user! before_action :set_problem, only: %i[show edit update destroy] before_action :authorize_user!, only: %i[edit update destroy] def index #Query searches category column of problem table for full/partial matches from user entered...
# Given a string of words separated by spaces, write a method that takes this # string of words and returns a string in which the first and last letters of # every word is swapped. # You may assume that every word contains at least one letter, and that the # string will always contain at least one word. You may als...
require_relative 'pixel' class Screen attr_accessor :width attr_accessor :height attr_accessor :matrix def initialize(width, height) self.width = width self.height = height self.matrix = [] row = [] for var in 1..width do row.push(nil) end for var in 1..height do matrix.p...
FactoryBot.define do factory :user do first_name { FFaker::Name.first_name } last_name { FFaker::Name.last_name } email { FFaker::Internet.email } password 'password' trait :with_motherboard do before(:create) do |user| user.motherboards.build end end end ...
class AddBoostCountToUsers < ActiveRecord::Migration[5.2] def change add_column :users, :boost_count, :integer, default: 0 add_column :users, :priority_count, :integer, default: 0 add_column :users, :post_requests_count, :integer, default: 0 end end
class ModerationController < ApplicationController skip_before_action :require_token before_action :require_secure_request def callback # Try to find the given ActiveRecord or Redis object model_class = params[:model_class].to_s.constantize @model = if params[:model_id].present? if mode...
require 'spec_helper' describe Analyst::Entities::Class do let(:parser) { Analyst.for_file("./spec/fixtures/music/music.rb") } let(:artist) { parser.classes.detect { |klass| klass.full_name == "Artist" } } let(:singer) { parser.classes.detect { |klass| klass.full_name == "Singer" } } let(:amp) { parser.cla...
require 'ffwd/plugin/datadog/utils' describe FFWD::Plugin::Datadog::Utils do describe "#safe_string" do it "should escape unsafe characters" do expect(described_class.safe_string("foo bar")).to eq("foo_bar") expect(described_class.safe_string("foo:bar")).to eq("foo_bar") end end describe "#m...
class Kid < ActiveRecord::Base has_and_belongs_to_many :candies end
# Suppose a hash representing a directory. All keys are strings with names for either folders or files. # Keys that are folders point to nested hashes. Keys that are files point to "true". # Write a function that takes such a hash and returns an array of strings with the path to each file in the hash. # file_list(f...
require_relative 'actionable.rb' module Game class Move < Game::Actionable SPEED = 1 MOVE_FROM = { "WEST" => lambda { |x,y| return x -= Game::Move::SPEED, y }, "EAST" => lambda { |x,y| return x += Game::Move::SPEED, y }, "NORTH" => lambda { |x,y| return x, y += Game::Move::SPEED }, ...
# == Schema Information # # Table name: projects # # id :integer not null, primary key # position :integer # title :string(255) # description :text # url :string(255) # user_id :integer # client_id :integer # created_at :datetime # updated_at :datetime # class Project...
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_version ">= 1.7.0" Vagrant.configure("2") do |config| provisioner = Vagrant::Util::Platform.windows? ? "ansible_local" : "ansible" hostsFile = Vagrant::Util::Platform.windows? ? "ansible/hosts/hosts_windows.txt" : "ansible/hosts/hosts_linux.txt" c...
class Game < ApplicationRecord validates :player1, :player2, :point1, :point2, presence: true after_initialize :increase_win_loss def increase_win_loss if (point1 > point2) winner = player1 loser = player2 else winner = player2 loser = pl...
class EventsController < ApplicationController protect_from_forgery def index @in_state_events = Event.where(state: current_user.state).includes(:host, :users) @out_of_state_events = Event.where.not(state: current_user.state).includes(:host, :users, :state) end def create event = Event.create( event_param...
class Question < ActiveRecord::Base has_many :choices belongs_to :questionaire validates :content, presence: true validates :questionaire_id, presence: true end
# frozen_string_literal: true require 'journey' describe Journey do let(:journey) { double :journey } let(:station) { double :station } let(:station_name) { double :station_name } # let(:journey){ {entry_station: entry_station, exit_station: exit_station} } describe '#touch_in' do it 'Commences a journ...
class CreateMatches < ActiveRecord::Migration def change create_table :matches do |t| t.integer :team1_id t.integer :team2_id t.integer :team1_results t.string :team2_results t.boolean :confirmed t.datetime :dateted_to t.string :place t.string :map_latlng t.st...
namespace :easyproject do desc <<-END_DESC EasyProject installer Example: bundle exec rake easyproject:install RAILS_ENV=production END_DESC task :install_with_environment => :environment do unless EasyProjectLoader.can_start? puts "The Easy Project cannot start because the Redmine is no...
RSpec.describe Actual::Export do let(:partner_organisation) { create(:partner_organisation) } let(:activities) { Activity.where(organisation: partner_organisation) } let(:export) { Actual::Export.new(activities) } let(:quarter_headers) { export.headers.drop(2) } let(:actual_data) { export.rows } let!(:proje...
class BuildsController < ApplicationController def index @builds = scope.paginated_by_date(params[:page], 50) respond_to do |format| format.html format.json { render :json => @builds } end end def show @build = scope.find(params[:id]) respond_to do |format| format.html ...
class Customer attr_reader(:name, :wallet, :age, :drunkenness) def initialize(name, cash, age) @name = name @wallet = cash @drunkenness = 0 @drinks = [] @foods = [] @age = age end def drink_count() return @drinks.count() end def add_drink(drink) @drinks.push(drink) end ...
require_relative 'questions_database.rb' class QuestionLike def self.all results = QuestionsDatabase.instance.execute('SELECT * FROM question_likes') results.map { |result| QuestionLike.new(result) } end def self.find_by_question_id(question_id) result = QuestionsDatabase.instance.execute(<<-SQL, qu...
class ProjectsController < ApplicationController include CurrentUser before_action :current_user before_action :set_project, only: [:show, :edit, :update, :destroy, :success] before_action :logged_in_user, only: [:edit, :update, :destroy, :index, :show] # GET /projects # GET /projects.json def index if ...
require 'test_helper' class SomethingsControllerTest < ActionDispatch::IntegrationTest setup do @something = somethings(:one) end test "should get index" do get somethings_url assert_response :success end test "should get new" do get new_something_url assert_response :success end t...
class Route attr_accessor :first, :last def initialize(first, last) @list = [] @list << first.name @list << last.name end def add_station(station) raise "Неверный тип станции #{station.class}" unless station.is_a?(RailwayStation) @list.insert(-2, station.name) end def remove_station(s...
# frozen_string_literal: true # link_titling.rb # Author: William Woodruff # ------------------------ # A Cinch plugin that autotitles any links sniffed by yossarian-bot. # ------------------------ # This code is licensed by William Woodruff under the MIT License. # http://opensource.org/licenses/MIT require "...
require "./lib/dictionary" class NightReader attr_reader :file_in, :file_out, :incoming_text def initialize @file_in = ARGV[0] @file_out = ARGV[1] @dictionary = Dictionary.new end def orchestrate_english_conversion read_file write_file puts display_message ...
module Api module V1 class UsersController < ApplicationController include ApiHelper after_filter :cors_set_access_control_headers # before_filter :authenticate_user_from_token! # before_filter :authenticate_api_v1_user! def index #Show all users @users...
module OHOLFamilyTrees module NotableObjects def self.read_notable_objects(filesystem, path, others = []) notable = others.clone filesystem.read(path) do |f| while line = f.gets notable << line.to_i end end return notable end end end
require 'test_helper' class RegistrationTest < ActiveSupport::TestCase test "it is valid when user and account are valid" do registration = Registration.new( nickname: 'dave', email: 'dave@example.com', password: 'secret', password_confirmation: 'secret' ) assert registration.val...
require 'rails_helper' describe Purchase, type: :model do describe 'Validations' do it 'is invalid without a purchase date' do purchase = Purchase.new(transaction_date: '12/18/2018', description: 'zebra pens, bic pens', amount: 50.1) ...
# Analyze the Errors # I worked on this challenge [by myself, with: ]. # I spent [#] hours on this challenge. # --- error ------------------------------------------------------- cartmans_phrase= "Screw you guys " + "I'm going home." # This error was analyzed in the README file. # --- error -------------------------...
# == Schema Information # # Table name: users # # id :integer not null, primary key # name :string(255) # email :string(255) # created_at :datetime not null # updated_at :datetime not null # encrypted_password :string(255) # salt...
class Disc < Product attr_accessor :year, :genre def self.from_file(path) lines = File.readlines(path, chomp: true, encoding: 'UTF-8') data = { title: lines[0], creator: lines[1], genre: lines[2], year: lines[3], price: lines[4], amount: lines[5] } ...
require 'rails_helper' RSpec.describe PaymentsController, type: :controller do let (:user) { FactoryGirl.create :user } let (:payment) { FactoryGirl.create :payment } context 'for an authenticated user' do before(:each) { sign_in user } describe "GET #index" do it "returns http success" do ...
class CreateLeagueMatchCommEdits < ActiveRecord::Migration[5.0] def change create_table :league_match_comm_edits do |t| t.belongs_to :created_by, null: false, index: true, foreign_key: true t.integer :comm_id, null: false, index: true t.text :content, null: false t.timestamps null: fal...
# frozen_string_literal: true require 'ruby2d' require 'colorize' require_relative 'components/utilities' require_relative 'truncator/truncator' # Main Countdown game. # # @author Zach Baruch module Countdown MAX_CONSONANTS = 6 MAX_VOWELS = 5 # The "gameplay" part of the game. The Countdown Clock music will be...
require 'rules/base' require 'util/time_adjuster' module Rules class IsOutsideRegularSchedule < Base DEFAULTS = { minimum_daily_hours: 0.0, maximum_daily_hours: 0.0, minimum_weekly_hours: 0.0, maximum_weekly_hours: 0.0, overtime_days: ["sat...
FactoryGirl.define do factory :user, class: User do sequence(:email){ |n| "user-#{n}@iuvare.mx" } first_name 'Test' last_name 'User' password '12345678' roles {[FactoryGirl.create(:role)]} trait :inactive do active false end end factory :premier, class: Premier do sequence(...
module API class EndpointController < ApplicationController def self.errors_to_rescue [ AirMonitor::UnauthorizedAccessError, ActiveRecord::RecordNotFound, ActionController::RoutingError, ActionController::ParameterMissing ] end rescue_from(*errors_to_...
class EndDateAfterStartDateValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return unless value unless end_date_after_start_date(record.planned_start_date, record.planned_end_date) record.errors.add :planned_end_date, :not_before_start_date end end private def...
require 'test_helper' class UserTest < ActiveSupport::TestCase def setup @user = User.new(name: "Example User", email: "user@example.com", password: "foobar", password_confirmation: "foobar") @user.save @found_user = User.find_by(email: @user.email) @user_for_invalid_password = @...
class ApplicationController < ActionController::Base protect_from_forgery with: :exception helper_method :current_user before_action :require_login, except: [:new,:create] def current_user @current_user ||= User.find_by_id(session[:user_id]) end def require_login if session.has_key?(:user_id) ...
module Users class OwnersController < ApplicationController def create result = create_owner_and_room if result.success? redirect_to room_path( room_secret_id: result.room.secret_id, user_secret_id: result.owner.secret_id ) else flash[:error] = 'Inval...
Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" config.vm.define "mongod" do |mongod| mongod.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--cpus", "2", "--memory", "3072"] end mongod.vm.network :private_network, ip: "192.168.19.100" mongod.vm....