text
stringlengths
10
2.61M
class Account::SettingsController < ApplicationController def show @user = current_user.decorate end end
class SimsBigaLicensePolicy < ApplicationPolicy def index? user.admin? || user.sims? || user.sims_empenho_nivel_1? || user.sims_empenho_nivel_2? end def cnh_vencidas? user.admin? || user.sims? || user.sims_empenho_nivel_1? || user.sims_empenho_nivel_2? end def new? user.admin? || user.sims? ||...
require 'formula' class Pssh <Formula url 'http://parallel-ssh.googlecode.com/files/pssh-2.1.1.tar.gz' homepage 'http://code.google.com/p/parallel-ssh/' md5 '4b355966da91850ac530f035f7404cd5' depends_on 'python' depends_on 'setuptools' => :python def install system "python", "setup.py", "install" ...
class ChallengesController < ApplicationController skip_before_action :require_login, {only: [:index, :consistency, :truth, :appathons, :join, :show]} before_action :require_login_or_guest, only: [] def new if !@context.logged_in? || !@context.user.can_administer_site? redirect_to challenges_path ...
require_relative 'lib/yaz0/version' Gem::Specification.new do |spec| spec.name = "yaz0" spec.version = Yaz0::VERSION spec.authors = ["Nax"] spec.email = ["max@bacoux.com"] spec.summary = "Compress and decompress Yaz0 data." spec.homepage = "https://github.com/Nax/ru...
require 'spec_helper' require 'yaml' RSpec.describe Piebits::Configuration do it "loads a basic config" do yaml_content = IO.read(File.join(__dir__, "../fixtures/config-with-oclint.yml")) expect(yaml_content).to be_truthy config_hash = YAML.safe_load(yaml_content) expect(config_hash).to_not be_nil...
DUMP_PATH = "/tmp/remit_prod_db.dump" GIT_REMOTE = "heroku" # Must specify explicitly since I have more than one. namespace :dev do desc "Reset development database from a production dump" task :db => [ :dump_db, :download_db, :import_db, :"db:migrate" ] do puts "Done!" end task :dump_db do system("h...
FactoryGirl.define do factory :user do email "testuser@example.com" password "foobar" username "testuser" first_name "Test" last_name "User" admin true end end
module Rcss class Dsl def self.evaluate(string, instance=nil) instance ||= Dsl.new instance.instance_eval(string) instance.finalize instance end def initialize @stack = []# hashes @r = {}# root hash @gs = {}# globals end def _(as) raise "nee...
require 'test_helper' class HelperTest < Test::Unit::TestCase def test_should_configure_with_default_options assert_equal default_options, Deadpool::Helper.configure({ config_path: config_dir }) end def default_options { pid_file: '/var/run/deadpool.pid', log_level: 'INFO', system_che...
class RegisteredApplicationsController < ApplicationController def show @registered_application = RegisteredApplication.find(params[:id]) @events = @registered_application.events.group_by(&:name) end def new @user = current_user @registered_application = RegisteredApplication.new end def cr...
# -*- coding: utf-8 -*- class HomeworkStudentUpload < ActiveRecord::Base # --- 模型关联 belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id' belongs_to :homework_student_upload_requirement, :class_name => 'HomeworkRequirement', :foreign_key => '...
require 'spec_helper' describe PaymentsController do before(:each) do sign_in FG.create(:user) @event = FG.create(:event) paymentor = FG.create(:user) item = FG.create(:item, user: paymentor, event: @event) part1 = FG.create(:participant, user: FG.create(:user), event: @event) part2 = FG.crea...
module Rmega module Nodes class Root < Node include Expandable include Traversable def download(path) children.each do |node| node.download(path) end end end end end
# for ruby-1.6.8 module DRb class DRbServer module InvokeMethod16Mixin def block_yield(x) if x.class == Array block_value = @block.__drb_yield(*x) else block_value = @block.__drb_yield(x) end end def rescue_local_jump(err) case err.message when /^retry/ # retry from proc-closure ...
class RentLogController < ApplicationController def index @rents = RentLog.all end end
class RemoveFieldsFromArticle < ActiveRecord::Migration[5.0] def change remove_column :articles, :Category, :string remove_column :articles, :Author, :string remove_column :articles, :Views, :int end end
#Dado el siguiente código: class Student attr_accessor :name, :nota def initialize(name) @name = name @nota end end nombres = %w(Alicia Javier Camila Francisco Pablo Josefina) p "1. Iterar los nombres para crear un nuevo arreglo de estudiantes." estudiante = nombres.map { |e| Student.new(e) } p estudiante p...
require 'pstore' require_relative '../helpers/mode_router' module Rainbow module Services class ModeService def initialize(store) @store = store @current = nil @router = ModeRouter.new ENV['MODE_PUB_HOST'] end def all modes = [] @store.transaction(true...
# -*- encoding: utf-8 -*- require File.expand_path('../lib/nordea/file_transfer/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Edgars Beigarts"] gem.email = ["edgars.beigarts@makit.lv"] gem.summary = "Ruby client for Nordea FileTransfer Web Services" gem.description =...
feature "Bid Newspaper - Create" do context 'Visitor' do scenario "Access invalid" do bid_newspaper = create :bid_newspaper visit edit_bid_newspaper_path bid_newspaper expect(current_path).to eq new_session_path end end context 'Admin' do let(:us...
require 'test_helper' class DataDefinitionsControllerTest < ActionDispatch::IntegrationTest setup do @data_definition = data_definitions(:one) end test "should get index" do get data_definitions_url assert_response :success end test "should get new" do get new_data_definition_url assert...
module Ripley class Tracker include Singleton def self.make_class_method(method_name) define_singleton_method(method_name){ instance.send(method_name) } end # public interface def callers binding.callers.map{ |binding| Ripley::Binding.new(binding) } end def states_by_caller...
class CreateReports < ActiveRecord::Migration def change create_table :reports do |t| t.string :name t.date :date_from t.date :date_to end end end
require 'colorize' class CaveCombat attr_reader :board, :movable_pieces def initialize(input_file: 'inputs/15.txt') @board = Board.new(input_file) @movable_pieces = @board.movable_pieces @rounds = 0 end def run until game_over? move_pieces attack @rounds += 1 end put...
ShopifyApp.configure do |config| config.api_key = Rails.configuration.shopify_app_key config.secret = Rails.configuration.shopify_app_secret config.scope = "read_products, write_products, read_customers, read_orders" config.embedded_app = true end
class UsersController < ApplicationController def new @user = User.new end def create @user = User.new(params[:user]) @user.role = "reader" if @user.save puts "Signup successfull" flash[:notice] = "Signup was successfull" redirect_to @user else puts "Signup Unsuccessfull" fl...
describe UserMailer, type: :mailer do describe 'invite_email' do let(:mail) { UserMailer.invite('test@example.com', 'token') } it 'renders the headers' do expect(mail.subject).to eq("You have been invited to zernie's blog") expect(mail.to).to eq(['test@example.com']) expect(mail.from).to eq...
class Item < ApplicationRecord belongs_to :merchant validates_presence_of :name, :address, :city, :state, :zip end
class BotoesPage < SitePrism::Page #esse comando esta setando a url que sera utilizada na automação set_url 'https://automacaocombatista.herokuapp.com/treinamento/home' #Esse lista de elemento abaixo e o que sera utilizado na automação element :elemento, :xpath, '/html/body/div[2]/div[1]/ul/li[2]/a' ...
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 module TwitterCldr module Formatters module Rbnf RuleGroup = Struct.new(:rule_sets, :name) do def rule_set_for(rule_set_name) rule_sets.find do |rule_set| rule_set.name == rule_set_n...
require 'pry' require 'colorize' task default: %w[usage] desc 'Print the usage of the Rakefile' task :usage do puts 'If this is a new dotfile installation, please note:'.yellow puts ' * You will need to install the dependencies'.yellow puts ' * For example: sourcing .bashrc, loading janus, etc...'.yellow pu...
class CircularBuffer class BufferEmptyException < StandardError; end class BufferFullException < StandardError; end def initialize(size) @buffer = Array.new(size) @start_index = 0 @end_index = 0 @size = size end def read fail BufferEmptyException if @buffer.all?(&:nil?) show = @buffe...
class AddEpisodeCount < ActiveRecord::Migration def change add_column :podcasts, :episode_count, :integer, :default => 0 Podcast.reset_column_information Podcast.all.each do |p| Podcast.update_counters p.id, :episode_count => p.episodes.length end remove_column :podcasts, :episode_count ...
=begin I have an array stock_prices_yesterday where: The indices are the time in minutes past trade opening time, which was 9:30am local time. The values are the price in dollars of Apple stock at that time. For example, the stock cost $500 at 10:30am, so stock_prices_yesterday[60] = 500. Write an efficient algorithm...
=begin The code from this file was copied from Blather: Copyright (c) 2011 Jeff Smick Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the right...
require 'sinatra' # Base class for VCITY Web Viewer class VCityApp < Sinatra::Base set :views, File.expand_path('../../views', __FILE__) set :public_folder, File.dirname(__FILE__) + '/../public' get '/' do erb :index end get '/map' do send_file(ENV['MAP_FILE']) end get '/output' do send_f...
class Genre < ApplicationRecord extend FriendlyId friendly_id :name, use: :slugged has_many :anime_genres has_many :animes, through: :anime_genres end
require 'test_helper' class Movie::ScenaristsControllerTest < ActionDispatch::IntegrationTest setup do @movie_scenarist = movie_scenarists(:one) end test "should get index" do get movie_scenarists_url assert_response :success end test "should get new" do get new_movie_scenarist_url asse...
# 12 11 10 9 8 7 # [13] [6] # 0 1 2 3 4 5 # 6 13 are non store cups #0-5 my 0 1 2 -------67 skip 13 side is 2 #7-12 is the other one skip 6 side is 1 require "byebug" class Board attr_accessor :cups def initialize(name1, name2) @name1 = name1 @name2 = name2 @cups = ...
class ListsChannel < ApplicationCable::Channel def subscribed stream_from "lists_#{params['list_id']}_channel" end end
module Hypgen module Worker class Runner include Hypgen::Auditable def initialize(id, profile_mappings, rabbitmq_location, start_time, end_time, deadline, options = {}) @id = id @profile_mappings = profile_mappings @rabbitmq_location = rabbitmq_location ...
class FontNotoSansMono < Formula head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansMono-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/" desc "Noto Sans Mono" homepage "https://www.google.com/get/noto/#sans-mono" def install (share/"fonts").install "NotoSansMono-Black.ttf" ...
class User < ApplicationRecord #has_secure_password acts_as_token_authenticatable # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, ...
module Ripley module Interceptor def raise(__exception_or_message) Ripley.handle_exception(__exception_or_message) super end Ripley.ignore_file __FILE__ end end
require 'spec_helper' describe "Activity Feed pages" do let (:admin_user) {FactoryGirl.create(:admin)} let (:friend_requester) {FactoryGirl.create(:user)} let (:friend_accepter) {FactoryGirl.create(:user)} let (:game) {FactoryGirl.create(:game)} subject { page } describe "index" do before do ...
require "spec_helper" describe FanzoTipsController do describe "routing" do it "routes to #index" do get("/fanzo_tips").should route_to("fanzo_tips#index") end it "routes to #new" do get("/fanzo_tips/new").should route_to("fanzo_tips#new") end it "routes to #show" do get("/fa...
Sequel.migration do up do create_table(:users) do primary_key :id String :email, null: false String :password_hash, null: false DateTime :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP DateTime :updated_at, null: false, default: Sequel::CURRENT_TIMESTAMP end cre...
class Employee < ActiveRecord::Base belongs_to :store validates :first_name, :last_name, :store_id, presence: true validates :hourly_rate, numericality: { only_integer: true, greater_than: 39, less_than: 200 } before_save :generate_password private def generate_password # generate random st...
Gem::Specification.new do |s| s.name = 'makumba_import' s.version = '0.5.2' s.date = '2014-01-08' s.summary = "Makumba database integration with Rails applications" s.description = "Generate models matching your Makumba MDDs" s.authors = ["Marius Andra"] s.email = 'marius.andra@gmail.com' s.homepage = '...
require 'spec_helper' describe 'glance::backend::vsphere' do let :facts do { :osfamily => 'Debian' } end let :params do { :vcenter_host => '10.0.0.1', :vcenter_user => 'root', :vcenter_password => '123456', :vcenter_datacenter => 'Datacenter', :vcent...
module RubyLie class Algebra attr_reader :cartan attr_reader :alg attr_reader :rank attr_reader :alpha_to_ortho_matrix def initialize(alg, rank) @alg = alg @rank = rank @cartan = get_cartan @alpha_to_ortho_matrix = get_alpha_to_ortho_matrix @extended_cartan = get_...
# write a method that takes two strings as arguments # determines the longest of the two strings # and then returns the result of concatenating the shorter string # the longer string # and the shorter string once again # assume the strings are of different lengths # Examples: # # short_long_short('abc', 'defgh') == ...
class BeersController < ApplicationController before_action :find_beer, only: [:show, :edit, :update, :destroy, :votes] before_action :authenticate_user!, except: [:index, :show] def index @beers = Beer.paginate(:page => params[:page], :per_page => 2).find_with_reputation(:votes, :all, order: "votes desc"...
class CreateIdeas < ActiveRecord::Migration def change create_table :ideas do |t| t.string :description t.string :title t.string :possible_places, array: true, default:[] t.integer :max_assistance t.integer :min_assistance t.date :possible_dates, array: true, default:[] t...
class CreateProfiles < ActiveRecord::Migration # Created by using bundle exec rails generaate migration "" / Stores information or table def change create_table :profiles do |t| t.integer :user_id # physically ties the two db tables together. (Profile/user) t.string :first_name # basic t.string...
class FontOpenDyslexicNerdFont < Formula version "2.3.3" sha256 "0b8a768e95414e8d2fc7b0550226e65a84848705aad000516cf12e731ffbf5be" url "https://github.com/ryanoasis/nerd-fonts/releases/download/v#{version}/OpenDyslexic.zip" desc "OpenDyslexic Nerd Font families (OpenDyslexic)" desc "Developer targeted fonts w...
require 'json' require 'aws-sdk-dynamodb' require 'aws-sdk-sqs' TABLE_NAME = 'asahi_abstraction_status' SQS_URL = ENV['SQS_QUEUE_URL'] def lambda_handler(event:, context:) dynamodb = Aws::DynamoDB::Client.new(region: 'ap-northeast-1') sqs = Aws::SQS::Client.new(region: 'ap-northeast-1') url = event[...
# frozen_string_literal: true require 'rails_helper' describe 'As a user on dashboard path' do before :each do @user = create(:user) @user.update(html_url: 'https://github.com/cjbrambo') @user.token = Token.new(github_token: ENV['GITHUB_API_KEY']) @user2 = create(:user) @user2.update(html_url: '...
require 'spec_helper' describe Tournament do describe 'synchronization' do let!(:remote_attrs) do [ build(:remote_tournament, tour_id: '1', eman: 'tour-1'), build(:remote_tournament, tour_id: '2', eman: 'tour-1'), build(:remote_tournament, tour_id: '3', eman: 'tour-2') ] e...
class Suggestion < ActiveRecord::Base belongs_to :title belongs_to :by, :class_name => 'User', :foreign_key => :by_id belongs_to :to, :class_name => 'User', :foreign_key => :to_id validates :title_id, :presence => true, :uniqueness => {:scope => :to_id} validates :by_id, :presence => true validates :to_id, ...
require 'gosu' require_relative 'ennemy' TILE_SIZE = 64 GRASS = 0 WALL = 1 class Room attr_accessor :width, :height, :x, :y def initialize(minSize, maxSize) prng = Random.new @width = prng.rand(minSize..maxSize) @height = prng.rand(minSize..maxSize) end def get_random_point prng = Random.new ...
class Micropost < ActiveRecord::Base validates :content, length: {maximum: 14, minimum:1 } belongs_to :user end
# Author: Hiroshi Ichikawa <http://gimite.net/> # The license of this source is "New BSD Licence" require "google_drive/session" module GoogleDrive # Authenticates with given +mail+ and +password+, and returns GoogleDrive::Session # if succeeds. Raises GoogleDrive::AuthenticationError if fails. # Google...
# RubyGems - Source source "https://rubygems.org" # Ruby - Version ruby "2.1.5" # Middleman Core gem "middleman-core", "3.3.5" # Middleman Livereload - Auto-refresh on change gem "middleman-livereload", "3.3.4" # Middleman S3 Sync - Allows sync between middleman build and Amazon S3 gem "middleman-s3_sync", "3.0.31"...
class CreateFixedDeposits < ActiveRecord::Migration def change create_table :fixed_deposits do |t| t.integer :company_id t.float :rate_of_interest t.integer :tenure t.timestamps end end end
# class Person # def initialize(name, age, location, salary) # @name = name # @age = age # @location = location # @salary = salary # end # def get_name # @name # end # end # bob = Person.new('bob', 28, "Corvallis", 39000) # joe = Person.new('joe', 25, "Richardson", 44000) # puts bob.inspe...
class PushServices::FriendshipNotifier def initialize(current_user) @current_user = current_user end def notify_request_to(user) notifier.push( message: request_message, tag: user.airship_tag, extra_data: { event_type: PushServices::Notifier::EVENT_TYPES[:friend_requested] ...
class AddExtraToTeachers < ActiveRecord::Migration def change # 部门 add_column :teachers, :department, :string # 电话 add_column :teachers, :tel, :string # 性别 add_column :teachers, :gender, :string # 民族 add_column :teachers, :nation, :string # 政治面貌 add_column :teachers, :polit...
class Client < ActiveRecord::Base belongs_to:user validates :company,:presence => true validates :address_1,:presence => true validates :phone_1,:presence => true,:numericality=>true,:length => { :is => 10, :message => " Only 10 number allowed. " } validates :city,:presence => true validates :state,:presence => ...
class CreateMptypes < ActiveRecord::Migration def change create_table :mptypes do |t| t.string :mptype t.timestamps end end end
# -*- encoding : utf-8 -*- require 'spec_helper' describe UserSessionsController do describe :destroy do it "should clear the member id" do session[:member_id] = 1337 post :destroy session[:member_id].should be_nil end it "should clear the applicant id" do session[:applicant_id] ...
class CreateLobbies < ActiveRecord::Migration def self.up create_table :lobbies do |t| t.string :name t.string :description t.integer :min_slots t.integer :max_slots t.integer :has_password t.string :password t.integer :ship_id t.integer :created_by_user_id t....
ENV = :prod # ENV = :dev def path_to_file(filename) if ENV == :prod "https://raw.githubusercontent.com/firstdraft/grades_utilities/master/#{filename}" else File.join(File.expand_path(File.dirname(__FILE__)), "files", filename) end end def path_to_blob(filename) "https://raw.githubusercontent.com/first...
# Source: http://www.secg.org/collateral/sec2_final.pdf module ECDSA class Group Secp192r1 = new( name: 'secp192r1', p: 0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFE_FFFFFFFF_FFFFFFFF, a: 0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFE_FFFFFFFF_FFFFFFFC, b: 0x64210519_E59C80E7_0FA7E9AB_72243049_FEB8DEEC_C1...
class Item < ApplicationRecord has_one_attached :image belongs_to :user has_one :treasurer extend ActiveHash::Associations::ActiveRecordExtensions belongs_to_active_hash :genre belongs_to_active_hash :status belongs_to_active_hash :delivery_fee belongs_to_active_hash :shipment_source belongs_to_activ...
require File.dirname(__FILE__) + '/../../test_helper' class Jobs::CleanDatabaseWithBlastTest < ActiveSupport::TestCase should "require params" do job = Jobs::CleanDatabaseWithBlast.new("Extract Database FAIL", { }) assert_raise RuntimeError do job.perform end end context "Clean a Database File...
namespace :accountable do desc "Explaining what the task does" task :update_balances => :environment do DetailAccount.all.each do |a| a.balance_at(Date.today).save end end end
s file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # web site for more information on licensing and terms of use. # http://metasploit.com/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = ExcellentRankin...
require_relative '../../../../spec_helper' describe 'icinga::host', :type => :define do let(:title) { 'bruce-forsyth' } let(:facts) {{ :ipaddress => '10.10.10.10', :fqdn_short => 'fakehost-1.management', }} it { is_expected.to contain_file('/etc/icinga/conf.d/icinga_host_bruce-forsyth.cfg') } it {...
module SmartLinc module Insteon # insteon device commands INSTEON_COMMANDS = { :on => 11, :fast_on => 12, :off => 13, :fast_off => 14 } # insteon dim levels INSTEON_LEVELS = [{ 0 => '00'}, {10 => '19'}, {25 => '40'}, {50 => '7F'}, {75 => 'BF'}, {90 => 'E6'}, {1...
class DropColumnFacaacontecerIdFromUsers < ActiveRecord::Migration def change remove_column :users, :facaacontecer_id, :integer end end
class AddOrderToBios < ActiveRecord::Migration def change add_column :bios, :bio_order, :integer add_index :bios, :bio_order end end
require 'test_helper' class AccessSystemsControllerTest < ActionDispatch::IntegrationTest setup do log_in @access_system = FactoryBot.create(:access_system, name: 'IDEALS', service_owner: 'owner@example.com', application_manager: 'manager@example.com') end test 'access systems index' do get access_...
class CustomersController < ApplicationController before_action :find_customer, only: %i[show edit update addcontact destroy] def index @customers = Customer.all end def new @customer = Customer.new end def create @customer = Customer.new(customer_params) if @customer.save redir...
class CreateBeers < ActiveRecord::Migration def change create_table :beers do |t| t.string :name t.integer :brewery_id t.string :style t.float :abv t.float :ibu t.float :srm t.integer :acidic, default: 0 t.integer :clean, default: 0 t.integer :creamy, default:...
class PhotosController < ApplicationController before_action :logged_in_user, except: :show before_action :set_album def new @photo = Photo.new end def create @photo = Photo.new(photo_params) @photo.albums << @album if @photo.save redirect_to album_photo_path(@album, @photo) else ...
require 'drb/drb' module RSpec module Distributed class RemoteQueue class << self def drb_object @object ||= begin DRb.start_service DRbObject.new_with_uri(Distributed.drb_uri) end end def queue Enumerator.new do |enum| ...
class Book attr_reader :title def title=(statement) splitfirst=statement.split splitfirst.each do |i| i.capitalize! unless exception?(i) end splitfirst[0].capitalize! @title=splitfirst.join(" ") end def exception?(word) exceptions = ["the","a","an","and","of","in"] if exceptions.include?(word) ...
#!/usr/bin/env ruby require_relative 'ERSEarthquake' class ERS def method_missing(sym, *args) "-" end end
# frozen_string_literal: true # Advent of Code 2020 # # Robert Haines # # Public Domain require 'aoc2020' module AOC2020 class ConwayCubes < Day ADJ27 = [-1, 0, 1].product([-1, 0, 1], [-1, 0, 1]).freeze ADJ26 = (ADJ27 - [[0, 0, 0]]).freeze ADJ81 = [-1, 0, 1].product([-1, 0, 1], [-1, 0, 1], [-1, 0, 1])....
class AddStationToOrderMaps < ActiveRecord::Migration[5.0] def change add_reference :order_maps, :station, foreign_key: true end end
class Cart attr_accessor :items delegate :clear, :size, :empty?, to: :@items delegate :to_json, to: :@items def initialize(items = []) @items = items end def apply(item) if item.kind_of?(Array) item.each { |it| apply(it) } return end if item[:op] == '+' items << item[:p...
class ContactMailer < ActionMailer::Base default to: 'mark@sharkwebdev.com' def contact_email(first_name, last_name, email, phone, message) @first_name = first_name @last_name = last_name @email = email @phone = phone @message = message mail(from: 'postmaste...
class Api::V1::Invoices::TransactionsController < ApplicationController def index render json: Transaction.where(transaction_params) end private def transaction_params params.permit(:invoice_id) end end
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def production? Rails.env == 'production' end def tagcloud(count, page = 0) tag_counts = Hash.new(0) posts = Post.where(user_id: session[:user_id]).order("created_at DESC").paginate(:page =...
# frozen_string_literal: true class Locality < Zone validates :slug, :code, :type, :name, :parent_zone, presence: true validates :parent_zone, format: %r{\A[a-z\-]+/[a-z\-]+/[a-z\-]+/[a-z0-9\-]+\z} validates :code, format: %r{\A[a-z\-]+/[a-z\-]+/[a-z\-]+/[a-z0-9\-]+/[a-z0-9\-]+\z} alias_attribute :parent, :ci...
class Entry < ActiveRecord::Base validates :physical, presence: true validates :emotional, presence: true validates :career, presence: true validates :relationships, presence: true end
class RemoveColumnsFromUsers < ActiveRecord::Migration[5.1] def change remove_column :users, :checkin, :date remove_column :users, :checkout, :date end end
class MoviesController < ApplicationController before_action :signed_in_user, only: [:edit, :update, :new, :create] before_action :admin_user, only: :destroy def index @movies = Movie.paginate(page: params[:page], :per_page => 10) end def show @movie = Movie.find(params[:id]) if signed_in? ...