text
stringlengths
10
2.61M
class RenameColumnInCompetitions < ActiveRecord::Migration def up rename_column :competitions, :team_stats_type, :team_stats_config end def down rename_column :competitions, :team_stats_config, :team_stats_type end end
#!/usr/bin/env ruby # :title: PlanR::Plugins::Interpreter::R =begin rdoc Interpreter plugin for R scripts and the R process. (c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org> =end require 'tg/plugin' require 'plan-r/document/script' require 'plan-r/application/interpreter' require 'plan-r/application/script_...
class UserPaymentsController < ApplicationController before_action :set_user_payment, only: %i[ show edit update destroy ] before_action :authenticate_user, only: [:create, :index] def index @user_payments = UserPayment.all @unpaid_payments = UserPayment.where(user:@current_user).where('status= ? OR stat...
class AddForeignKey < ActiveRecord::Migration def change add_reference :books, :staff, index: true add_foreign_key :books, :staff add_reference :books, :author, index: true add_foreign_key :books, :author add_reference :books, :manufacturer, index: true add_foreign_key :books, :manuf...
# Homepage (Root path) require 'json' before do if session[:user_id] @user = User.find(session[:user_id]) else @user = User.new @user.cart = Cart.new @user.user_wish_list = UserWishList.new session[:user_id] = @user_id end # if loggedin? # @cart = User.find(session[:user_id]).cart # e...
class UserSerializer < ActiveModel::Serializer attributes :id, :name,:last_name, :profile, :avatar, :profile, :location, :company, :position, :phone, :email, :authentication_token, :industries, :areas, :status def avatar if object.image.url == "/images/original/missing.png" object.avatar.present? ? obje...
class SaeQualification < UserQualification def sae_label_method "#{self.user.full_name} SAE Qualification" end RailsAdmin.config do |config| config.model SaeQualification do visible false object_label_method do :sae_label_method end edit do fi...
# == Schema Information # # Table name: users # # id :integer not null, primary key # login :string(255) not null # email :string(255) not null # crypted_password :string(255) not null # password_salt :string(255) not null # persistence...
class Api::V1::User < ApplicationRecord has_secure_password has_many :followed_users, foreign_key: "follower_id", class_name: "Api::V1::Follow" has_many :followees, through: :followed_users has_many :following_users, foreign_key: "followee_id", class_name: "Api::V1::Follow" has_many :followers, th...
module Airmodel class Query include Enumerable def initialize(querying_class) @querying_class = querying_class end def params @params ||= { where_clauses: {}, formulas: [], order: @querying_class.default_sort, offset: nil } end def where(arg...
require 'faker' FactoryGirl.define do factory :party_a do city { Faker::Address.city } company { Faker::Company.name } end factory :party_b do name { Faker::Name.name } uuid { Faker::Code.ean } phone { Faker::PhoneNumber.cell_phone } card_number { Faker::Business.credit_card_number } ...
feature 'user sign in' do scenario 'a user can sign in with email and password' do User.create(name: 'Bob', email: 'bob@gmail.com', password: 'password', password_confirmation: 'password') expect{ sign_in }.not_to change(User, :count) expect(page).to have_content "Welcome, ...
require 'helper_frank' module Rdomino describe View do before do @db = Rdomino.local[:test].with_fixtures @people = @db.view 'People' @by_form = @db.view 'by Form' end it { @people.template.must_equal 'templi'} it "#pluck" do assert_equal %w(Frank Tobias),@people.pluck(:na...
class FayePublishWorker include Sidekiq::Worker def perform(channel, message) FayeClient.publish(channel, message) end end
#!/usr/bin/env ruby # http://tammersaleh.com/posts/the-modern-vim-config-with-pathogen # Other plugins # * Git # git://github.com/tpope/vim-fugitive.git # git://github.com/tpope/vim-git.git # * File explorer / navigation # git://github.com/scrooloose/nerdtree.git # git://github.com/vim-scripts/project...
module AdvancedFlash DELETED_CREDENTIAL_FLASH = '_deleted_credential' DELETED_CREDENTIAL_SESSION_ID = :deleted_credential_id DELETED_CALENDAR_FLASH = '_deleted_calendar' DELETED_CALENDAR_SESSION_ID = :deleted_calendar_id module ControllerSupport protected def add_deleted_credential_flash(dele...
class Quotation < ApplicationRecord belongs_to :currency INTERVALS = { 'day': {date_interval: 1.day, date_format: "%H", maxLabels: 6}, 'week': { date_interval: 7.day, date_format: "%b/%d", maxLabels: 7}, 'month': { date_interval: 1.month, date_format: "%b/%d", maxLabels: 15}, 'months': { date_inter...
class AddSpaceIdToTables < ActiveRecord::Migration def change add_column :resources, :space_id, :integer add_column :tools, :space_id, :integer add_column :strata, :space_id, :integer end end
require_relative "vehicle" class Minivan < Vehicle def to_s "The minivan: #{model} - #{type} - #{number}" end def max_passengers 10 end end
FactoryGirl.define do factory :organization do sequence(:name) { |n| "Fake Organization #{n}" } # need this for fake data process_ssrs false transient do children_count 0 has_protocols false end after :create do |organization, evaluator| create_list(:pricing_setup, 3, organiz...
class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :prepare_meta_tags, if: "request.get?" after_action :prepare_unobtrusive_flash after_action :store_location if Rails.env.production? or Rails.env.staging? rescue_from ActiveRecord::RecordNotFound, Act...
class StudentsProjectMembershipsController < ApplicationController before_action :set_students_project_membership, only: [:show, :edit, :update, :destroy] # GET /students_project_memberships # GET /students_project_memberships.json def index @students_project_memberships = StudentsProjectMembership.all e...
class ChangeColNameFromImageToImageUrlAndAddPublicIdColumn < ActiveRecord::Migration def change rename_column :photos, :image, :image_url add_column :photos, :public_id, :string change_column :photos, :public_id, :string, null: false end end
module ModelExtensions public def get_assocs(type = :belongs_to) aggregate_objs = self.reflect_on_all_associations(type) aggregate_objs.select{|m| m.name != :users}.map{|m| m.klass} end def attrs excludes = %w(audits accepted_roles created_at updated_at users id) attrs = [] self.column_n...
module Qiita # Qiita API アクセスクラス # 特定のタグがつけられた投稿を取得する。 # また、ブロックを受け取り、データ取得後に非同期で任意の処理を実行できるようにする。 # # @example # Qiita::Client.fetch_tagged_items('tag') { |items, error_message| # # 任意の処理 # } class Client # BASE_URL = 'https://qiita.com/api/v1' BASE_URL = 'http://qiita-server.herokuapp....
module Riopro module KillBill module Return class Itau < Riopro::KillBill::Return::Base # Verifies if parsed file is valid. Returns boolean def valid? valid = true @errors = [] unless self.transactions.size == self.trailer[:quantidade_detalhes] @err...
module ArRollout module Controller module Helpers def self.included(base) base.send :helper_method, :rollout? base.send :helper_method, :degrade_feature? end def rollout?(name) return false unless current_user ArRollout.active?(name, current_user) end ...
require 'open-uri' require 'pry' require 'nokogiri' class Scraper def self.scrape_index_page(index_url) html = open(index_url) doc = Nokogiri::HTML(html) students = [] #create a new hash for each student #push each hash onto the array doc.css("div.student-card").each do |student| st...
class RolesSerializer include FastJsonapi::ObjectSerializer attributes :name attribute :id do |object| object.id.to_s end end
class AddPeopleInvitedToEvents < ActiveRecord::Migration def change add_column :events, :people_invited, :text end end
class ProjectsController < ApplicationController before_action :authenticate_user!, except: [:dashboard] before_action :set_project, only: [:show, :edit, :update, :destroy] load_and_authorize_resource :project, :except => [:edit_status, :update_status] def dashboard if current_user.present? && current_u...
module MCollective module Util module IPTables class IPv4 def initialize configure end def configure @iptables_cmd = Config.instance.pluginconf.fetch("iptables.iptables", "/sbin/iptables") @logger_cmd = Config.instance.pluginconf.fetch("iptables.logger"...
Transform /^table:cards,card$/ do |table| table.map_headers! {|header| header.downcase.to_sym } table.map_column!(:player) {|player| ordinal.to_i } table.map_column!(:card_rank) {|rank| rank.to_i } table.map_column!(:card_suit) {|suit| suit.downcase.to_sym } table end Given /^"([^"]*)" players$/ do |number_o...
RailsAdmin.config do |config| config.main_app_name { ['NixTest', 'Admin'] } ### Popular gems integration config.authorize_with do authenticate_or_request_with_http_basic('Authorization required') do |email, password| user = User.find_by_email(email) if email if user && user.valid_password?(passwo...
# == Schema Information # # Table name: images # # id :integer not null, primary key # column :integer # row :integer # extra_height_in_lines :integer default(0) # image :string # caption_title :string # caption ...
module Qualtrics::API class Group < BaseModel attribute :id attribute :type attribute :organization_id attribute :division_id attribute :name attribute :all_users attribute :creation_date attribute :creator_id ## # Make the model serializeable by ActiveModelSerializer # ...
=begin Write a program that includes a method called multiply that takes two arguments and returns the product of the two numbers. multiply(2, 5) -> 10 =end def multiply(a,b) return a * b end puts multiply(2,5)
# frozen_string_literal: true FactoryGirl.define do factory :exam_section do title 'Test Exam' type 'Opción Múltiple' end end
class Admin < ApplicationRecord validates :user_name, presence: true validates :password, presence: true, length: {minimum: 8} has_secure_password end
#!/usr/bin/env ruby require 'tempfile' tmp_path = File.expand_path("../../", __FILE__) readme_path = File.expand_path("../../README.md", __FILE__) index_path = File.expand_path("../../docs/index.html", __FILE__) ribbon = %{ <a href="https://github.com/johnsusi/bluesky"> <img style="position: absolute; top: 0...
class User < ActiveRecord::Base validates :email, uniqueness: true has_many :participations has_many :themes, through: :participations has_many :expenses end
class AddAttachmentToPhotos < ActiveRecord::Migration def change add_attachment :photos, :pic end end
module Fog module Compute class Brkt class Real def update_server(id, options={}) request( :expects => [202], :method => "POST", :path => "v2/api/config/instance/#{id}", :body => Fog::JSON.encode(options) ) end ...
require 'spec_helper' describe "Home Page" do describe "get root path" do it "works if user is admin" do admin_user_login visit root_path current_path.should == root_path end it "fails if user is not an admin" do user_login visit root_path current_path.sho...
class ToDoItemsController < ApplicationController before_action :set_to_do_item, only: [:show, :edit, :update, :destroy] skip_before_action :verify_authenticity_token protect_from_forgery with: :null_session # GET /to_do_items # GET /to_do_items.json def index if params[:user] != nil @to_do_items...
class Account < ActiveRecord::Base validates :name, presence: true validates :number, presence: true, numericality: { greater_than: 0 } belongs_to :organization delegate :credits, :debits, to: :amounts has_many :amounts scope :asset_accounts, ->{ where(type: 'AssetAccount') } scope :liability_accounts...
class PhysiciansController < ApplicationController # Create # GET: /physicians/new get "/sign_up" do erb :"/physicians/new.html" end # POST: /physicians logging in post "/physicians" do if params[:name] == "" && params[:password] == "" redirect "/sign_up" else if Physician.fin...
# == Schema Information # # Table name: conversations_profiles # # profile_id :integer not null # conversation_id :integer not null # id :integer not null, primary key # # Indexes # # index_conversations_profiles_on_conversation_id_and_profile_id (conversation_id,profil...
require 'spec_helper' describe "file_uploads/index" do before(:each) do assign(:file_uploads, [ stub_model(FileUpload, :originalname => "Originalname", :filename => "Filename", :size => 1, :sha1_hash => "SHA1 hash", ), stub_model(FileUpload, :originalname...
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryPr...
require_relative 'temporal_operator' module ConceptQL module Operators # Trims the end_date of the LHS set of results by the RHS's earliest # start_date (per person) # If a the RHS contains a start_date that comes before the LHS's start_date # that LHS result is completely discarded. # # If t...
class CreateHours < ActiveRecord::Migration def change create_table :hours do |t| t.integer :zone end end end
namespace :hp do HP_URL = 'http://www.haskell.org/platform/download/2013.2.0.0/haskell-platform-2013.2.0.0.tar.gz' HP_TAR = "/var/tmp/#{HP_URL.split('/').last}" HP_DIR = "/var/tmp/#{HP_URL.split('/').last.split('.tar').first}" desc "install hp from source" task :install => [:build] do sh "cd #{HP_DIR} &&...
require 'rails_helper' RSpec.describe BirthdayParty, type: :model do describe "build_unwithdrew_redpacks" do let!(:party) { FactoryGirl.create(:birthday_party) } let!(:virtual_present) { FactoryGirl.create(:virtual_present, value: 708, price: 2000) } let!(:bless) { FactoryGirl.create(:bless, virtual_pres...
shared_examples_for 'php-fpm' do |enabled_suite, disabled_suite| # Basic tests describe service(get_helper_data_value(enabled_suite, :fpm_service_name)) do it { should be_enabled } it { should be_running } end if os[:family] == 'ubuntu' && os[:release] == '14.04' # On Trusty we need to check a TCP/IP s...
=begin - input: array of elements that can be sorted - output: same array with elements sorted - Data Structure: work directly with Array Algorithm: - if first element > second element then array[0], array[1] = array[1], array[0] - now second element compared to third => if array[1] > array[2] th...
require_relative '../../refinements/string' using StringRefinements module BankStatements class HashCategoryProcessor def initialize(category_hash, default = nil) @category_hash = category_hash @default = default || ['Misc'] @hash_info = HashCategoryInfo.new(@category_hash, @default) end ...
require 'test_helper' require 'place_service' class PlaceServiceTest < ActiveSupport::TestCase test "the truth" do assert true end id1 = "ohGSnJtMIC5nPfYRi_HTAg" id2 = "GXvPAor1ifNfpF0U5PTG0w" openingHourJSON = { "Days" => [ "monday", "tuesday", ...
class AssignmentTypesController < ApplicationController before_action :set_assignment_type, only: [:show, :edit, :update, :destroy] # GET /assignment_types # GET /assignment_types.json def index @assignment_types = AssignmentType.all.order("name") end # GET /assignment_types/1 # GET /assignment_type...
class Image < ApplicationRecord belongs_to :project mount_uploader :image_url, PhotoUploader end
object @user attributes :id child :runs do attributes :distance attributes :run_time attributes :notes attributes :id attributes :user_id node(:run_date) { |run| pretty_date(run.run_date)} node(:pace) { |run| pretty_pace(run.per_mile_pace)} node(:run_id) { |run| run.id} end
RSpec.describe Faye::Server do let(:user) { create(:user) } let(:circle) { create(:circle) } describe '#make_response' do it do message = { 'ext' => 'ext' } expect(subject).to receive(:make_response_without_ext).with(message).and_return({ 'successful' => true }) expect(subject.make_response...
class MakersController < ApplicationController before_action :require_admin before_action :set_maker, only: [:edit, :update, :show] def index @sort = [params[:sort]] @makers = Maker.paginate(page: params[:page], per_page: 25).order(@sort) end def new @maker = Maker.new end def show end def edit ...
class LikesController < ApplicationController def create user = current_user post = Post.find(params[:post_id]) likes = Like.where(:user_id => user, :post_id => post) response = "failure" if likes.size == 0 Like.create(:user => user, :post => post) response = "success" end res...
module Mpki::MpkiClient require "#{Rails.root}/lib/Mpki/userManagementServiceDriver.rb" class MpkiClient def initialize(uri_path) @driver = UserManagementOperations.new("https://pki-ws.symauth.com/" + uri_path) @driver.loadproperty("#{Rails.root}/config/mpki.properties") end def c...
require 'spec_helper' describe Like do let(:micropost) { FactoryGirl.create(:micropost) } before do @like = micropost.likes.build(micropost_id: micropost.id) @like.user_id = micropost.user.id end subject { @like } it { should respond_to(:micropost_id) } it { should be_valid } describe "when...
parsed_directories = JSON.parse(IO.read("config/directories.json")) def keys_to_sym data if data.is_a? Hash new_hash = {} data.each do |k, v| new_hash[k.to_sym] = keys_to_sym v end new_hash elsif data.is_a? Array data.map{|el| keys_to_sym el} else data end end DIRECTORIES = keys_...
# If we build an array like this: flintstones = ["Fred", "Wilma"] flintstones << ["Barney", "Betty"] flintstones << ["BamBam", "Pebbles"] # We will end up with this "nested" array: # ["Fred", "Wilma", ["Barney", "Betty"], ["BamBam", "Pebbles"]] # Make this into an un-nested array. p flintstones.flatten! # Maybe the...
# Sous-class Bdoc::Paragraphe class Bdoc class Paragraphe # ------------------------------------------------------------------- # Classe # ------------------------------------------------------------------- # => Extrait les paragraphes de +foo+ et retourne une liste d'instances # de Bd...
class VideoSerializer < ActiveModel::Serializer attributes :title, :type, :description, :youtube, :vimeo def href object.link end def type 'text/html' end def description object.video_description.empty? ? object.video_description : object.title end def youtube regExp = /^.*((youtu.be...
require "rdf" require "rdf/n3" class SocialNetworkRDFSerializer def initialize(social_network, include_visual_data = false) @social_network = social_network @include_visual_data = include_visual_data end def to_rdf base = options[:base_uri] RDF::Writer.for(:n3).buffer(options) do |writer| ...
class EditColumns < ActiveRecord::Migration def change remove_column :services, :socks_per_month add_column :services, :socks_per_month, :integer end end
class Banner < ActiveRecord::Base validates_presence_of :image, :category_id mount_uploader :image, ImageUploader belongs_to :category def as_json(opts = {}) { id: self.id, title: self.title || "", image_url: self.image_url, link: Setting.upload_url + "/banners/#{self.id}...
require 'test_helper' class AppointmentTest < ActiveSupport::TestCase fixtures :pets, :users test "Validate date of visit is not in the past" do appointment = Appointment.create(date_of_visit: DateTime.now - 1.day, pet: pets(:tommy), ...
describe Kafka::Protocol::Encoder do let(:io) { StringIO.new("") } describe '#write_varint' do context 'data = 0' do it do encoder = Kafka::Protocol::Encoder.new(io) encoder.write_varint(0) expect(binaries_in_io(io)).to eq ["00000000"] end end context 'data is posit...
require "test_helper" class EventTest < ActiveSupport::TestCase # Matchers should belong_to(:organization) should validate_presence_of(:organization_id) should allow_value(Date.current).for(:date) should allow_value(Date.tomorrow).for(:date) should allow_value(Date.yesterday).for(:date) should_not allow_...
require 'tmpdir' require 'fileutils' tmsupport_path = File.join(ENV['HOME'], 'Library', 'Application Support', 'TextMate') tmplugins_path = File.join(tmsupport_path, 'PlugIns') tmbundles_path = File.join(tmsupport_path, 'Bundles') plugin_repos = [ 'https://github.com/enormego/EGOTextMateFullScreen.git', 'https://...
# frozen_string_literal: true module Hanamimastery module CLI module Commands class ToPRO < Dry::CLI::Command desc 'Renders HTML out of Markdown' argument :episode, type: :integer, required: :true, desc: "Episode's ID to render" option :save, aliases: ['-s'], type: :boolean, default...
class CreateComments < ActiveRecord::Migration[6.0] def change create_table :comments do |t| t.string :pseudo t.string :email t.string :content t.string :secret t.boolean :published, default: false t.integer :word_id t.timestamps end end end
require 'google/apis/script_v1' require 'googleauth' require 'googleauth/stores/file_token_store' require 'fileutils' require '/home/bhargav/Github/ruby_astm/adapter' class Google_Lab_Interface < Adapter OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'.freeze APPLICATION_NAME = 'Google Apps Script API Ruby Quickstart'.freez...
class AdminMailer < ActionMailer::Base default from: "no-reply@acfb.org" # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: # # en.admin_mailer.new_agency.subject # def new_agency(agency) @greeting = "Aloha!" @agency = agency mail to: "someone_to_u...
wordList = ["laboratory", "experiment", "Pans Labyrinth", "elaborate"] # using include method # def findLab(word) # if word.include?("lab") # puts word # else # nil # end # end # # using regex # def findLab(word) # if /lab/ =~ word # puts word # else # nil # end # end # using regex with...
require 'rails_helper' describe FantasyLeague do context "validations" do # Associations it { should have_many(:fantasy_teams) } # Validations it { should validate_presence_of(:year) } it { should validate_presence_of(:division) } end describe ".right_joins_fantasy_players" do it "return...
class User < ActiveRecord::Base has_and_belongs_to_many :smart_products has_and_belongs_to_many :detections has_many :mobile_devices, :dependent => :destroy validates_uniqueness_of :email_address end
class AddProjectFilesToResponses < ActiveRecord::Migration[5.2] def change add_column :responses, :project_files_id, :string add_column :responses, :project_files_filename, :string add_column :responses, :project_files_size, :string add_column :responses, :project_files_content_type, :string end end...
# frozen_string_literal: true require 'test_helper' module Vedeu module Repositories class StoreTestClass include Vedeu::Repositories::Store attr_reader :model def initialize(model = nil, storage = {}) @model = model @storage = storage end private def ...
# # Copyright 2013, Seth Vargo <sethvargo@gmail.com> # Copyright 2013, Opscode, 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 # # Unl...
require 'uuid' require 'open3' require 'tempfile' module Hadupils::Extensions # Tools for managing shell commands/output performed by the runners module Runners module Shell def self.command(*command_list) opts = {} begin if RUBY_VERSION < '1.9' Open3.popen3(*comman...
# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module MobileCenterApi module Models # # Model object. # # class CommitDetailsCommit # @return [String] Commit message ...
# require 'Date' module Hotel COST_OF_ROOM = 200 class Reservation attr_reader :id, :check_in, :check_out, :rooms, :total_cost, :date_range, :discount_rate def initialize(id_num, number_of_rooms:1, check_in:, check_out:, discount_rate: 1, block_id:'') @id = id_num @block_id = block_id ...
module RailsAdminSitemap def self.configuration @configuration ||= Configuration.new end def self.config @configuration ||= Configuration.new end def self.configure yield configuration end class Configuration attr_accessor :generator attr_accessor :config_file attr_accessor :outp...
class AddBirthdayToUsers < ActiveRecord::Migration def change add_column :users, :birthday, :date end end
class ApiHelper attr_reader :api_key def initialize() @api_key = 'jellyvision_audition' end def get_possible_results(type) good = [ 'It is certain', 'It is decidedly so', 'Without a doubt', 'Yes - definatley', 'You may rely on it', 'As I see it, yes', 'Most likely', 'Outlook good', 'Yes', 'Signs point...
class CreateAnnotations < ActiveRecord::Migration def change create_table :annotations do |t| t.string :guid, null: false t.string :checksum, null: false t.string :amazon_reference_id, default: nil t.string :book_reference_id, default: nil t.string...
require_relative '../spatial' module PdfExtract module Chunks # TODO Look for obj[:writing_mode] == :vertical or :horizontal Settings.declare :char_slop, { :default => 0.2, :module => self.name, :description => "Maximum allowed space between characters for them to be considered part of th...
module Webex # comment class Configuration %w( site_name webex_id password back_type back_url).each do |name| define_singleton_method(name) { ENV["WEBEX_#{name.upcase}"] } end def self.host_url "https://#{site_name}.webex.com/#{site_name}/" # "https://engsound.webex.com/engsound/" ...
# frozen_string_literal: true # this is comments class Carrig include Validation include TrainCarrige NUMBER_FORMAT = /^[0-9a-zа-я]{3}-?[0-9a-zа-я]{2}$/i.freeze NAME_FORMAT = /^[а-яa-z]+\D/i.freeze attr_reader :number, :amount attr_accessor_with_history :color, :repair_date strong_attr_accessor :produc...
class Track < ActiveRecord::Base validates :name, :roll, :options, :octave, presence: true end
module WebiniusCms module ApplicationHelper def errors_for(model, attribute) if model.errors[attribute].present? content_tag :div, content_tag(:span, model.errors[attribute].first, class: 'control-label'), class: 'field_with_errors' end end def list_nested_pages(pages) pages.ma...
# Calc.rb exercise puts 1 + 2; # Integer addition, yields 3, writes 3 to screen puts ''; # 2.4 Simple Arithmetic # Floats puts 1.0 + 2.0; puts 2.0 * 3.0; puts 5.0 - 8.0; puts 9.0 / 2.0; puts ''; # Integers puts 1+2; puts 2*3; puts 5-8; puts 9/2; # Integer division always rounds down to the nearest whole number ex...