text
stringlengths
10
2.61M
class PollsController < ApplicationController before_action :set_poll, only: [:show, :edit, :update, :destroy] before_action :logged_in_user, only: [:index, :show, :create, :new, :edit, :update] #before_action :logged_in_user # GET /polls # GET /polls.json def index @polls = Poll.paginate(page: params[...
module Antlr4::Runtime class CharStreams DEFAULT_BUFFER_SIZE = 4096 def self.from_string(s, source_name) CodePointCharStream.new(0, s.length, source_name, s.codepoints) end end end
module Paysafe class Configuration API_TEST = 'https://api.test.paysafe.com' API_LIVE = 'https://api.paysafe.com' attr_reader :account_number, :api_base, :api_key, :api_secret, :test_mode, :timeout def initialize(**options) @test_mode = true options.each do |key, value| instanc...
require_relative 'tic_tac_toe' class TicTacToeNode attr_reader :board, :next_mover_mark, :prev_move_pos, :children def initialize(board, next_mover_mark, prev_move_pos = nil) @board = board @next_mover_mark = next_mover_mark @prev_move_pos = prev_move_pos end def losing_node?(evaluator) ...
ActiveAdmin.register PollutionReport do actions :index filter :status, as: :select, collection: PollutionReport.statuses preserve_default_filters! member_action :archive, method: :put do status = PollutionReport.statuses[:archived] resource.update(status: status) redirect_to admin_pollution_report...
class List < Hyperloop::Router::Component render do SECTION(class: 'main') do INPUT(id: "toggle-all", class:"toggle-all", type:"checkbox") LABEL(htmlFor: "toggle-all") { 'Mark all as complete' } UL(class: 'todo-list') do scope = match.params[:scope] scope = :all if scope.blank? ...
require 'spec_helper' describe HomeController do describe 'GET homepage' do render_views let(:slideshow_post) { create :post, post_type: Post::POST_TYPES[:slideshow] } let(:image_post) { create :post, post_type: Post::POST_TYPES[:image] } let(:mobile_post) { create :post, post_type: Post::POS...
Pod::Spec.new do |s| s.name = 'TencentOpenAPI' s.version = '2.3' s.summary = 'Tencent Open API' s.homepage = 'http://wiki.open.qq.com/wiki/IOS_API%E8%B0%83%E7%94%A8%E8%AF%B4%E6%98%8E" s.ios.deployment_target = '3.0' s.source = { :git => "https://github.com/amoblin/easyPods.git", :branch => "master" } s.io...
require "sinatra/gyazo/version" require "sinatra" require 'fileutils' require 'pathname' require 'digest/md5' require 'sdbm' module Sinatra module Gyazo module Helpers def image_path(image_dir, data, ext) hash = Digest::MD5.hexdigest(data + Time.now.to_s).to_s year = Date.today.year ...
require 'mongoid' require 'json' require 'sinatra/reloader' if development? ## TODO : Develop a valid token algorithm VALID_KEY = "KH6R643B72V085P2TRK0" class ExceptionResource < Sinatra::Base set :methodoverride, true # Loading mongodb with yaml configuration Mongoid.load!("mongoid.yml", :development) # Mo...
# frozen_string_literal: true class Api::V1::AccountActivationsController < ApplicationController include ErrorMessageHelper include ResponseHelper include ResponseStatus include ErrorKeys def update user = User.find_by(email: user_params[:email]) if user && !user.activated? && user.authenticated?(...
# 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 rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
# encoding: utf-8 # # © Copyright 2013 Hewlett-Packard Development Company, L.P. # 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 rights #...
class Section < ApplicationRecord attr_accessor :add_field belongs_to :application_form, optional: true belongs_to :recommender_form, optional: true has_many :fields, -> { order(:order) }, dependent: :destroy, autosave: true validates :title, uniqueness: { scope: :application_form_id } accepts_nested_att...
class HashGenerator def initialize(string_to_hash) @string_to_hash = string_to_hash end def hash_md5 Digest::MD5.hexdigest @string_to_hash end def hash_sha1 Digest::SHA1.hexdigest @string_to_hash end end
# encoding: utf-8 require 'cgi' require "open3" require 'fileutils' require 'ap' require 'digest/md5' require 'string_cleaner' include Open3 class CURL AGENT_ALIASES = { 'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', 'Windows IE 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Window...
class GateType < ApplicationRecord belongs_to :material validates_presence_of :gate_price end
class AddColumnToPersonalcharge < ActiveRecord::Migration def self.up add_column :personalcharges, :charge_date, :date end def self.down end end
# Unlucky Days =begin (Understand the Problem) Problem: Write a method that returns the number of Friday the 13ths in the year given by an argument. Inputs: Integer (year) Outputs: Integer (# of Friday the 13ths in given year) Questions: 1. Explicit Rules: 1. You may assume that the year is grea...
require 'spec_helper' describe Spree::User do before(:each) do shipping_category = Spree::ShippingCategory.new shipping_category.save(validate: false) @user = Spree::User.create! email: 'test@example.com', :password => 'spree123' @product1 = Spree::Product.create! name: 'product1', price: 100, shipp...
class Users::RegistrationsController < Devise::RegistrationsController def success @email = params[:email].presence || "you" end protected def after_inactive_sign_up_path_for(resource) flash[:notice] = nil users_registrations_success_path :email => resource.email end end
class DownloadsController < ApplicationController include Sufia::DownloadsControllerBehavior def show if datastream.external? send_file datastream.filename, content_options.merge(disposition: 'attachment') else super end end end
# 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: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
FactoryGirl.define do factory :soat do start_date Date.today end_date Date.today premium_value { Faker::Number.number(5) } fosyga { Faker::Number.number(5) } runt { Faker::Number.number(3) } total_value { Faker::Number.number(5) } pay true association :user association :vehicle e...
# == Schema Information # # Table name: workouts # # id :integer not null, primary key # date :string(255) # duration :integer # activity :string(255) # intensity :integer # user_id :integer # created_at :datetime not null # updated_at :datetime not null # class W...
def begins_with_r(array) array.each do |it| if !it.to_s.start_with?("r") return false end end return true end def contain_a(array) a_array = [] array.each do |thing| if thing.include?("a"||"A") a_array << thing end end a_array end def first_wa(array) first_wa_word = "" a...
module Contactable extend ActiveSupport::Concern included do has_one :contact, as: :contactable, dependent: :destroy has_many :addresses, through: :contact has_many :phones, through: :contact has_many :emails, through: :contact has_many :websites, through: :contact accepts_nested_attribute...
require_relative '../test_case' module RackRabbit class TestSubscriber < TestCase #-------------------------------------------------------------------------- def test_subscribe_lifecycle subscriber = build_subscriber rabbit = subscriber.rabbit assert_equal(false, rabbit.started?) ...
require 'irods4r' module IRODS4r # This module interfaces directly with the IRODS system # module ICommands class ICommandException < IRODS4rException; end # Return the list of files found at 'path'. def self.ls(path, ticket = nil) r = `ils #{"-t #{ticket}" if ticket} #{path}` #raise I...
require "spec_helper" require "linked_list" RSpec.describe LinkedList, "#push" do let(:list) { described_class.new } it "pushs one value" do list.push("foo") expect(list[0]).to eq("foo") end it "pushs two values" do list.push("bar") list.push("qux") expect(list[0]).to eq("bar") expe...
json.array!(@mailings) do |mailing| json.extract! mailing, :id, :first_name, :last_name, :email, :mobile_num, :phone_num, :sms_optIn, :email_optIn json.url mailing_url(mailing, format: :json) end
json.array!(@recording_sessions) do |recording_session| json.extract! recording_session, :id, :start_time, :end_time, :description json.url recording_session_url(recording_session, format: :json) end
class User < ActiveRecord::Base validates :email, :spotify_access_token, :spotify_refresh_token, :user_name, presence: true validates :email, uniqueness: true has_many :slack_tokens, dependent: :destroy def to_param "#{id}-#{user_name}" end def signed_into_slack? slack_tokens.count > 0 end ...
require 'typhoeus' # https://github.com/typhoeus/typhoeus Typhoeus::Hydra.new(max_concurrency: 20) # default limit is 200 Typhoeus::Config.verbose = true # we will get some improvements using a single hydra run to process each request but it would be even faster to have have a pool of hydra requests as ready as poss...
require_relative '../karel.rb' describe Karel do describe '#initialize' do it 'accepts coordinates and direction' do expect{ Karel.new }.to raise_error ArgumentError end end describe '#current_location' do let(:rover) { Karel.new(4, 1,'N') } it 'returns current coordinates and direction' ...
class CreatePlaybacks < ActiveRecord::Migration def self.up create_table :playbacks do |t| t.column :user_id, :integer, :null => false t.column :media_file_id, :integer, :null => false t.column :created_at, :datetime end add_index :playbacks, [:user_id, :media_file_id] end def self....
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Game do it "should have many teams" do should have_many(:teams) end it "should require a number of rounds" do should validate_presence_of(:rounds) end it "should require a number of questions per round" do should ...
class Solution # find the longest sub string out of `s` containing at most `k` distinct characters def self.longest_substring(s: '', k: 0) # loop through starting from index = 0 # and then grow the end pointer we look at until we see at most `k` unique characters, once we do, stop substring = '' #...
class FontMyricam < Formula version "2.006.20150301" sha256 "a90eb9b79885f02ad9e0e752a0b979b699847be7de13dc3b6113658f006d12bd" url "https://github.com/tomokuni/Myrica/archive/refs/tags/#{version}.tar.gz", verified: "github.com/tomokuni/Myrica/" desc "MyricaM" desc "Programming font" homepage "https://myrica...
require 'spec_helper' require 'poms/api/response' module Poms module Api RSpec.describe Response do subject { described_class.new('200', nil, nil) } it 'converts code to integer' do expect(subject.code).to be(200) end it 'converts body to string' do expect(subject.body)....
class Users::PasswordsController < Devise::PasswordsController ssl_required :new, :create layout "bootstrap/application" def new @title = "Reset password :: #{t("site.title")}" super end end
# Our CLI Controller class DailyDeal::CLI def call puts "Today's Daily Deals:" list_deals menu end def list_deals # here doc http://blog.jayfields.com/2006/12/ruby-multiline-strings-here-doc-or.html puts <<-DOC.gsub /^\s*/, '' 1. PCH Digital Massager - $27 - Still available! 2. L...
# # Author:: Jörgen Brandt <joergen.brandt@onlinehome.de> # Cookbook:: chef-cuneiform # Recipe:: cf_worker # # Copyright:: 2015-2018 Jörgen Brandt # # 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 ...
class Blas < Formula desc "Basic Linear Algebra Subprograms" homepage "http://www.netlib.org/blas/" url "http://www.netlib.org/blas/blas.tgz" version "2011-04-19" sha256 "55df2a24966c2928d3d2ab4a20e9856d9914b856cf4742ebd4f7a4507c8e44e8" depends_on "gcc" => :build def install # makefiles do not work ...
require "java" require "json" require "bundler/setup" $:.unshift "uri:classloader:/lib" require "blogs/deploy" java_import "java.util.Map" java_package "uk.org.blogs.deploy" class LambdaHandler java_signature "Object call(Map event)" def call(event) puts "Received #{event.to_string}" return unless actio...
class Message < ActiveRecord::Base validates_presence_of :subject, :email, :body validates_length_of :body, minimum: 15 validates_length_of :subject, minimum: 5 end
Vagrant.configure("2") do |config| config.vm.box = "ubuntu/bionic64" config.vm.hostname = 'salt-test-box' # Give the machine 2048MB of RAM. # This assumes you're using the virtualbox provider, see # https://www.vagrantup.com/docs/providers/ for information on the # other providers. config.vm.provider "vi...
class User < ApplicationRecord before_validation :normalize_fields has_secure_password VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i # rubocop:disable Style/MutableConstant validates :username, :email_address, presence: true, uniqueness: { case_sensitive: false }, length: { maximum: ...
class SetParkingSpotsToFree < ActiveRecord::Migration[5.2] def up reversible do |dir| dir.up do ParkingSpot.where(status: nil).update_all(status: 'free') end end change_column_default :parking_spots, :status, 'free' end end
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def p(obj, field) if obj.class == User && field.to_s == 'name' private_user_name(obj) end if Privacy.visible?(obj, field) obj.send(field) else "Hidden" end end ...
#!/usr/bin/env ruby require 'emoji' require 'trollop' opts = Trollop::options do version "#{Emoji::VERSION} (c) 2014 David Wu" banner <<-EOS Emoji Power EOS opt :random, "Select a Random Emoji" opt :list, "Select from all Emoji" # --random # --recent (default) end menu = Emoji::Menu.new(opts) menu.run...
module TaxCloud class TICGroup attr_accessor :group_id, :description def initialize(attrs = {}) attrs.each do |sym, val| self.send "#{sym}=", val end end end end
require './runtime.rb' class ProgramNode def initialize(statements) @statements = statements end def evaluate(scope_frame) @statements.each { |s| s.evaluate(scope_frame) } end end class ConstantNode def initialize(n) @n = n end def evaluate(scope_frame) @n end end class PrintNode def initialize(st...
=begin #=============================================================================== Title: Message Skip Author: Hime Date: Jul 21, 2013 -------------------------------------------------------------------------------- ** Change log Jul 21, 2013 - Initial release ----------------------------------------------...
class AddCodeIdToDatabrowsers < ActiveRecord::Migration def change add_reference :databrowsers, :code, index: true, foreign_key: true add_reference :dataincludes, :code, index: true, foreign_key: true add_reference :datasubcategories, :code, index: true, foreign_key: true add_reference :datacompatib...
module PrintQuoteDetail extend ActiveSupport::Concern include PrintDocumentStyle def quote_details(quote, pdf) pdf.bounding_box([175.mm, 231.mm], :width => 20.mm) do pdf.text quote.project.ref, customer_style unless quote.project.ref.blank? pdf.text quote.ref, customer_style unless quote.ref...
require 'rails_helper' feature 'User edit customer' do scenario 'successfully' do customer = create(:customer) user = create(:user) login_as(user, scope: :user) visit root_path click_on 'Lista de Clientes' click_on customer.name click_on 'Editar' fill_in 'Nome', with: 'George R R Mar...
# 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: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
class AddFieldsToBlogs < ActiveRecord::Migration def change add_column :blog_posts, :uid, :string, :after => :url add_column :blog_posts, :preview, :text, :after => :body add_column :blog_posts, :published_at, :datetime, :after => :user_id end end
require 'hpricot' ## # The BodyMatcher is the module which makes it all happen. To # enable body matching, just include this module in your TestCase class: # # class Test::Unit::TestCase # include BodyMatcher # # self.use_transactional_fixtures = true # self.use_instantiated_fixtures = false # end #...
require "spec_helper" describe PostsController do describe "routing" do it "routes to #index" do get("/tailgates/1/posts").should route_to("posts#index", tailgate_id:"1") end it "routes to #new" do get("/tailgates/1/posts/new").should route_to("posts#new", tailgate_id:"1") end it "...
# encoding: UTF-8 module CDI module V1 module Posts class PostToSubscribersService < BaseService def initialize post, options={} super options @post = post end def execute if can_execute? users.each { |user| create_subscriber_post(user) } ...
class EvaluationQuestion < ActiveRecord::Base #belongs_to :course belongs_to :course_class has_many :registration_evaluation_answers attr_accessible :heading, :position, :question, :course_id, :answer_type, :course_class_id, :old_id acts_as_list scope: :course HEADINGS = ["Objective", "Instruction"...
# Campaign Model class Campaign < ApplicationRecord has_many :choices has_many :votes, through: :choices validates_presence_of :name end
class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable validates_confirmation_of :password attr_accessor :passwo...
# frozen_string_literal: true require 'json' require 'net/http' POKE_RANGE = (1..151).freeze PARTICIPANTS = 8 def gen_ids # Generate eight ids in the range 1..151, # making sure they are different. last_poke_ids = [] poke_id = 0 Array.new(PARTICIPANTS) do last_poke_ids.push poke_id # generate a ne...
class CreateGames < ActiveRecord::Migration def change create_table :games do |t| t.integer :player1_id t.integer :player2_id t.datetime :gamed_at t.integer :final_points_1 t.integer :final_points_2 t.timestamps null: false end end end
require 'rails_helper' describe Article do it { should have_many :comments } it { should validate_presence_of :content } end
class ApplicationController < ActionController::Base include DeviseTokenAuth::Concerns::SetUserByToken respond_to :json # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :null_session before_action :configure_permitted_parameter...
# frozen_string_literal: true module Tikkie module Api module V1 module Types module PlatformUsage FOR_MYSELF = "PAYMENT_REQUEST_FOR_MYSELF" FOR_OTHERS = "PAYMENT_REQUEST_FOR_OTHERS" end end end end end
class ShopsController < ApplicationController def index @shops = current_user.shops end def new @shop = current_user.shops.new end def create @shop = current_user.shops.create shop_params if @shop.persisted? flash[:success] = t ".success" redirect_to shops_path else fla...
# encoding: utf-8 module Pakman class Runner include LogUtils::Logging def initialize @opts = Opts.new end attr_reader :opts def run( args ) opt=OptionParser.new do |cmd| cmd.banner = "Usage: pakman [options]" cmd.on( '-f', '--fetch URI', 'Fetch Templates' ) do |uri| opts.f...
# Symfony environment set :symfony_env, "prod" # Symfony application path set :app_path, "app" # Symfony web path set :web_path, "web" # Symfony log path set :log_path, fetch(:app_path) + "/logs" # Symfony cache path set :cache_path, fetch(:app_path) + "/cache" # ...
class SolarSystem def initialize(star_name) @star_name = star_name @planets = [] end attr_reader :star_name, :planets def add_planet(planet_info) @planets << planet_info end def check_planet_found(planet) return @planets.map { |plant| plant.name.downcase }.include?(planet) end def l...
require 'spec_helper' describe Topic do let(:topic) {FactoryGirl.create(:topic)} it {(topic.slug).should_not be_nil} it { should belong_to(:user) } it { should validate_presence_of(:title) } it { should validate_presence_of(:content) } end
# frozen_string_literal: true Warden::Manager.after_set_user except: :fetch do |user, auth, opts| password = auth.request.params.fetch(opts[:scope], {}).fetch(:password, nil) password && auth.authenticated?(opts[:scope]) && user.respond_to?(:password_pwned?) && user.password_pwned?(password) end
require 'rails_helper' require 'sidekiq/testing' Sidekiq::Testing.inline! def parse_body(body) JSON.parse(body, symbolize_names: true) end describe "Convert Office Open XML to HTML using OxGarage" do before do Fog.mock! connection = Fog::Storage.new({ provider: "AWS", :aws_access_key_id ...
class OrderMap < ApplicationRecord after_create :create_check_info, :create_doctor_check_info belongs_to :customer_record belongs_to :service has_one :check_info, dependent: :destroy has_one :doctor_check_info, dependent: :destroy class << self def statistic start_date, end_date, station_id sql ...
require('spec_helper') describe Tag do it "will check if the tables are setup right" do new_tag = Tag.create({:name => 'Snack'}) expect(Tag.all).to eq [new_tag] end it "will check to see the tags has a recipe" do new_recipe = Recipe.create({:name => 'Cookies', :ingredients => 'Flour sugar milk', :...
class Run < ActiveRecord::Base belongs_to :user def time_minutes return nil if time_in_seconds.nil? (time_in_seconds / 1.minute) % 1.minute end def time_hours return nil if time_in_seconds.nil? (time_in_seconds / 1.hour) end def time_minutes=(minutes) self.time_in_seconds ||= 0 ...
class TictactoeGamesController < ApplicationController before_action :set_tictactoe_game, only: [:show, :edit, :update, :destroy] def index @tictactoe_games = TictactoeGame.all end def new @tictactoe_game = TictactoeGame.new end def create @tictactoe_game = TictactoeGame.new(tictactoe_game_p...
class BondValue attr_accessor :buy, :sale def initialize(buy, sale) @buy = buy @sale = sale end end
class CreateRecords < ActiveRecord::Migration def change create_table :records do |t| t.integer :user_id t.string :checked_boxes, array: true, default: [] t.timestamps end end end
require 'test_helper' class GclassesControllerTest < ActionController::TestCase setup do @gclass = gclasses(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:gclasses) end test "should get new" do get :new assert_response :success end...
class Copyright include Dragonfly::Configurable include Dragonfly::ImageMagick::Utils def copyright(source_image, notice = "(c)") # opts = defaults.merge(opts) # #TODO proper tempfile name # tempfile =Tempfile.new('caststone') # command = "convert -fill white -pointsize 40 -annotate 0 'Hello Sailor'...
class AddTournamntIdToStakes < ActiveRecord::Migration def change add_column :stakes, :tournament_id_4, :integer end end
class Student < ApplicationRecord validates :name, :student_number, :gpa, presence: true validates :name, uniqueness: true validates :student_number, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10000} belongs_to :school end
module Responders class Setupgame < ApplicationResponder respond_to "scan-data", "text", "link", "picture", "video", "sticker" def can_handle? Game.find(user.game_id).category.nil? end def handle if match_message('Kids') || match_message('Teens') || match_message('College') || match_...
class Student::PreviewImport include ActiveModel::Model attr_accessor :file, :course_id, :headers def initialize(attributes = {}) @file = attributes[:file] @course_id = attributes[:course_id] @headers = attributes[:headers] == "1" end def read nested_array = CSV.read(@file) result = @h...
class FontKatibeh < Formula head "https://github.com/google/fonts/raw/main/ofl/katibeh/Katibeh-Regular.ttf", verified: "github.com/google/fonts/" desc "Katibeh" homepage "https://fonts.google.com/specimen/Katibeh" def install (share/"fonts").install "Katibeh-Regular.ttf" end test do end end
class StaticPagesController < ApplicationController # NOTE: I moved the root logic to the posts controller. # staticpages#home no longer matters # unless the user is not logged in at all (which I'm also going to change) # I'll keep this stuff in tact in case I need to revert later for some reason. def home...
class Projects::TimesheetsController < Projects::ItemsController # Start editing timesheet def edit add_project_breadcrumb add_breadcrumb "My Timesheet", :edit_project_timesheet_path today = Date.today @period_start = today.beginning_of_week @period_end = @period_start + 4 gon.user...
require 'rails_helper' describe 'admin invoice show page (/admin/invoices/:id)' do include ActionView::Helpers::NumberHelper let!(:customer1) { create(:customer) } let!(:customer2) { create(:customer) } let!(:invoice1) { create(:invoice, customer: customer1, status: 2) } let!(:invoice2) { create(:invoice, ...
class DanceClass < ActiveRecord::Base belongs_to :instructor belongs_to :studio validates :name, :instructor_id, :studio_id, :when, :time, :cost, :presence => true validates :name, :uniqueness => true end
# 4. Write a method that counts down to zero using recursion. def count_down(start) if start <= 0 puts start else puts start count_down(start - 1) end end count_down(10) # Time to practice with the LS method. def count_to_zero(number) if number <= 0 puts number else puts number cou...
# frozen_string_literal: true class ActivityChannel < ApplicationCable::Channel def subscribed ActionCable.server.broadcast('activity', { action: 'status_update', id: current_user.id, status: 'online' }) stream_from 'activity' end def unsubscribed ActionCable.server....
class Api::V1::EmployeesController < ApplicationController before_action :set_employee, only: [:show, :update, :destroy] def index json_response(Employee.all.paginate(page: params[:page], per_page: 20)) end def show json_response(@employee) end def create employee = Employee.create!(employee_...
require "test_helper" feature " As a user, I want to sign out when I'm done so that my session is closed. " do scenario "sign out current user" do # Given a current user visit new_user_session_path fill_in "Email", with: users(:eli).email fill_in "Password", with: "password" click_on "Sign ...
class InvoicesController < ApplicationController before_action :set_invoice, only: [:show, :edit, :update, :destroy] before_action :authenticate_user! before_action :set_user def index if current_user.role === "administrator" @producer_invoices = [] @client_invoices = [] Invoice.all.eac...
namespace :reviews do desc 'Syncs reviews with Google Sheet' task sync: :environment do Archiver::TweetArchiver.archive puts 'Start syncing to sheet' SheetSync::Download::SheetReader.download puts 'Finshed syncing sheet successfully' end end