text stringlengths 10 2.61M |
|---|
require 'spec_helper'
describe 'Show private event', js: true do
let!(:user) { create(:user, :paul) }
let!(:event) do
create(
:event, :tasafoconf,
users: [user], owner: user, to_public: false, start_date: Date.today,
end_date: Date.today + 1.year
)
end
context 'when logged' do
be... |
module SimpleJsonapi::Node::RelationshipData
# Represents a relationship's +data+ object containing a single resource
# linkage object.
#
# @!attribute [r] resource
# @return [Object]
class Singular < Base
attr_reader :resource
# @param resource [Object]
# @param options see {Node::Relationsh... |
class CreatePuzzlesTable < ActiveRecord::Migration[6.0]
def change
create_table :puzzles do |t|
t.string :title
t.string :design
t.integer :number_of_pieces
t.boolean :in_progress
end
end
end |
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
get 'areas/fetch', to: 'areas#index'
get 'areas/search', to: 'areas#search'
end
end
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
puts "How many times should I print the phrase? Enter and number >= 3:"
loop do
answer = gets.chomp.to_i
if answer >= 3
answer.times { puts "Launch School is the Best!" }
break
else
puts "That's not enough times. Enter a number >= 3."
end
end
|
class Temperature
attr_accessor :f, :c
def initialize( options = {} )
@f = options[:f]
@c = options[:c]
end
def to_fahrenheit
if @c == nil
@f
else
( @c.to_i * 9 / 5 + 32.00 ).round(0)
end
end
def to_celsius
if @f == nil
@c
else
( ( @f.to_i - 32 ) * 5 / 9.... |
module Api::V1
class UsersController<ApiController
def index
users = User.order('created_at DESC')
render json: users, status: :ok
end
end
end
|
#!/usr/bin/env ruby
require 'nokogiri'
class Page
attr_reader :affix_tables
def initialize(path)
doc = Nokogiri::HTML(File.open(path))
tables_css = doc.css('//table.wikitable')
#puts("class: #{tables_css.class}, length: #{tables_css.length}")
@affix_tables = Array.new
tables_css.each do |tc... |
# frozen_string_literal: true
class JpxIndustryCode
class Errors
class JpxIndustryCodeError < StandardError; end
class InvalidArgumentError < JpxIndustryCodeError; end
class NotFoundError < JpxIndustryCodeError; end
end
end
|
class CreateMovies < ActiveRecord::Migration[5.2]
def change
create_table :movies do |t|
t.string :video_id, null: false
t.string :title, null: false
t.string :channel_title
t.string :video_image
t.string :video_url, null: false
t.text :video_description
t.date :published... |
class Mms::EproductsController < Mms::MmsBackEndController
def index
page = params[:page] || 1
@eproducts = ::Eproduct.paginate(:per_page => 20, :page => page,:order=>"eproducts.created_at desc")
end
def search
page = params[:page] || 1
@keyword = params[:keyword]
@eproducts = ::Eprodu... |
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "/offers/new.html.erb" do
include OffersHelper
before(:each) do
assigns[:offer] = stub_model(Offer,
:new_record? => true
)
end
it "renders new offer form" do
render
response.should have_tag("form[action=?]... |
class PostPresenter < Presenter
def is_post_presenter?
true
end
end |
class Admin::UsersController < Admin::BaseController
inherit_resources
include StdCrud
actions :all, except: [:show]
protected
def collection
@q = User.search(params[:q])
@users = @q.result(distinct: true).paginate(page: params[:page], per_page: 20)
end
def permitted_params
params.permit( u... |
require 'rails_helper'
RSpec.describe City, type: :model do
subject { FactoryGirl.create(:city) }
it "hasa valid factory" do
expect(subject).to be_valid
end
it { should have_many(:neighbourhoods) }
it { is_expected.to validate_presence_of(:name) }
end
|
class Admin::ProgressAttachmentsController < ApplicationController
before_action :set_progress_attachment
def create
@progress_attachment = ProgressAttachment.new(progress_attachment_params)
respond_to do |format|
if @progress_attachment.save
format.html { redirect_to @progre... |
json.contexts do
json.partial! 'api/v1/contexts/show', collection: @contexts, as: :context
end
|
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
before_filter :set_user
after_filter :reset_user, :set_csrf_cookie_for_ng
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
bef... |
class AddTimesSoldToProduct < ActiveRecord::Migration
def self.up
add_column :products, :times_sold, :integer, :default => 0
add_index :products, :times_sold
end
def self.down
remove_index :products, :times_sold
remove_column :products, :times_sold
end
end
|
#!/usr/bin/env ruby
require 'minitest/autorun'
require './List'
class TestMyList < MiniTest::Unit::TestCase
attr_accessor :list
def setup
@list = List.new()
end
def teardown
end
def test_nil()
assert_nil @list.root
assert_nil @list.tail
assert_nil @list.find('fred')
assert_equal @list.values,[]
en... |
class Comment < ApplicationRecord
validates :body, presence: true
validate :comment_too_long
belongs_to :author,
primary_key: :id,
foreign_key: :author_id,
class_name: :User
belongs_to :post,
primary_key: :id,
foreign_key: :post_id,
class_name: :Post
has_many :likes, as: :likeable
d... |
################################################################################
require('minitest/autorun')
################################################################################
module AllObjects; end
################################################################################
class AllObjects::Visibi... |
require 'spec_helper'
RSpec.describe Fitter::Transactions::ExerciseTypes::DowngradeExerciseType do
let(:exercise_type_repo) { double(Fitter::Repositories::ExerciseTypeRepo) }
let(:step_repo) { double(Fitter::Repositories::StepRepo) }
let(:contract) { Fitter::Contracts::ExerciseTypes::DowngradeExerciseType.new... |
module Payout
RSpec.describe Response do
describe '::handle' do
subject { Response.handle(&request_block) }
class << self
def def_request_block(&block)
let(:request_block) { block }
end
def with_request_returning(code, body = nil)
case code
when ... |
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "640"
end
config.vm.provision "shell", inline: <<-SHELL
apt-get purge -y snapd lxcfs lxd ed ftp ufw accountsservice policykit-1
apt-get autoremove -y
apt-... |
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
it 'is not valid when password and password confirmation fields inputs do not match' do
user = User.create(
first_name: 'Meli',
last_name: 'Yetenekli',
email: 'meliyete@yahoo.com',
pas... |
class AddTitleNameEnToConcerts < ActiveRecord::Migration
def change
add_column :concerts, :title_name_en, :string
end
end
|
require_relative("../db/sql_runner.rb")
class Seller
attr_reader :id
attr_accessor :name
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
end
def save()
sql = "INSERT INTO sellers (name)
VALUES ($1)
RETURNING *;"
values = [@name]
res... |
# require_with_metadata: true
# frozen_string_literal: true
require 'capybara/cuprite'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'rack'
require 'rack/test'
Dir[SPEC_ROOT.join('support/web/*.rb').to_s].each(&method(:require))
Capybara.app = Rack::Builder.parse_file(SPEC_ROOT.join('../config... |
class CreateOutputs < ActiveRecord::Migration
def change
create_table :outputs do |t|
t.text :input_type
t.text :output
end
end
end
|
# encoding: UTF-8
module CDI
module V1
module GameQuestionOptions
class UpdateService < BaseUpdateService
include V1::ServiceConcerns::GameQuestionOptionsParams
record_type ::GameQuestionOption
def record_params
params = game_question_option_params
params.dele... |
module Internal
class Pager
require 'audible'; include Audible
def initialize(source)
@source = source
@page_number = 1
@result = []
end
def read(opts={})
limit = opts[:limit] || 50
begin
next_page
end while more?(limit)
take limit
end
def... |
# encoding: utf-8
class EventInviteesController < ApplicationController
include Helper::EventsControllerHelper
before_filter :authenticate_user!
before_filter :get_user
before_filter :get_event
before_filter :check_owner
before_filter :get_follow_item
before_filter :get_join_item
def new
@title =... |
class Micropost < ApplicationRecord
#Валидация длинны сообщения максимум 140. поле content из таблицы базы данных
validates :content, length: { maximum: 140 }, presence: true
belongs_to :user
end
|
class AddRecommandToAlbumBooks < ActiveRecord::Migration
def self.up
add_column :album_books, :recommand, :boolean, :default=>false
end
def self.down
end
end
|
class Lapso < ActiveRecord::Base
self.primary_key = :id_lapso
has_many :lapso_cursos, :class_name => 'LapsoCurso', :foreign_key => :id_lapso
end
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Buffers
describe Clear do
let(:described) { Vedeu::Buffers::Clear }
let(:instance) { described.new(attributes) }
let(:attributes) {
{
height: height,
name: _name,
width: width... |
require 'test_helper'
module Vedeu
module Renderers
describe Escape do
let(:described) { Vedeu::Renderers::Escape }
let(:instance) { described.new }
describe '#clear' do
let(:expected) { '[[:empty]]' }
subject { instance.clear }
it { subject.must_equal(expected) }... |
module Astrails
module Safe
class Archive < Source
def command
"tar -cf - #{@config[:options]} #{tar_exclude_files} #{tar_files}"
end
def extension; '.tar'; end
protected
def tar_exclude_files
[*@config[:exclude]].compact.map{|x| "--exclude=#{x}"} * " "
end
... |
FactoryGirl.define do
factory :workout do
user
activity
workout_on Date.today
minutes_elapsed 10
units_completed 5
unit_of_measure "mi"
end
end
|
class Vote < ActiveRecord::Base
belongs_to :user
belongs_to :review
validates :user, presence: true
validates :review, presence: true
validates :value, presence: true, inclusion: { in: [1, 0, -1] }
end
|
FactoryGirl.define do
factory :match do
association :home_team, :factory => :team
association :away_team, :factory => :team
weather { generate :string }
beginning { Time.current - rand(200).minutes - 100.minutes }
end
end
|
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_m... |
class AddIndex < ActiveRecord::Migration[5.2]
def change
add_index :subs, :post_id
end
end
|
module RobotApp::Models
class Playground
def initialize(dimension_extensions_list)
dimension_extensions_list.find do |dim|
raise "Min coordinate bigger than max: #{invalid}" if dim.first > dim.last
end
@extension = dimension_extensions_list.dup
end
def extension; @extension.dup... |
class RenameNewColumn < ActiveRecord::Migration[5.0]
def change
rename_column :comments, :new, :new_reply
end
end
|
class Router
attr_accessor :x, :y, :facing
@@x_range = (0..4)
@@y_range = (0..4)
@@route_directions = {
north: { x: 0 , y: 1 },
south: { x: 0 , y: -1 },
west: { x: -1 , y: 0 },
east: { x: 1 , y: 0 }
}
def initialize(x, y, facing)
@x = x
@y = y
@facing = ... |
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :project
belongs_to :role
validates :user_id, presence: true
validate :user_id_uniqueness_to_project, on: :create
def user_id_uniqueness_to_project
if user_id && Membership.where(project_id: project_id, user_id: user_id).count > 0
... |
# frozen_string_literal: true
RSpec.describe 'Users' do
resource 'Admin users' do
let!(:user1) { create(:user) }
let!(:user2) { create(:user) }
route '/api/v1/admin/users', 'Admin Users endpoint' do
get 'All users' do
parameter :page
parameter :sort
parameter :filter
... |
module FreeImage
#DLL_API const char *DLL_CALLCONV FreeImage_GetVersion(void);
attach_function('FreeImage_GetVersion', [], :string)
#DLL_API const char *DLL_CALLCONV FreeImage_GetCopyrightMessage(void);
attach_function('FreeImage_GetCopyrightMessage', [], :string)
#DLL_API BOOL DLL_CALLCONV FreeImage_IsLitt... |
class AddArmIdToAppointment < ActiveRecord::Migration
def change
add_column :appointments, :arm_id, :integer
add_index :appointments, :arm_id
end
end
|
Pod::Spec.new do |spec|
spec.name = 'MariusKit'
spec.version = '1.0.0'
spec.description = 'Prima prova framework MariusKit'
spec.summary = 'Prova'
spec.platform = 'ios', '12.2'
spec.license = 'MIT'
spec.source_files = 'MariusKit'
spec.homepage = 'https://github.com/Ju... |
module Example
extend ActiveSupport::Concern
class_methods do
def foo; puts 'foo'; end
private
def bar; puts 'bar'; end
end
end
|
require 'rails_helper'
module BaritoBlueprint
RSpec.describe Processor do
before(:each) do
@infrastructure = create(:infrastructure)
@instances = [
{
'name' => 'd-trac-consul-01',
'type' => 'consul',
'seq' => 1,
},
{
'name'... |
# Given the below usage of the Person class, code the class definition.
class Person
attr_accessor :name
def initialize(n)
@name = n
end
end
bob = Person.new('bob')
puts bob.name # => 'bob'
bob.name = 'Robert'
puts bob.name # => 'Robert'
|
class ClubsController < ApplicationController
def index
@clubs = Club.all
@player_count = Player.count
end
def new
@club = Club.new
end
def show
@club = Club.find_by(slug: club_name)
end
def create
@club = Club.new(club_params)
if @club.save
redirect_to clubs_path
el... |
class FormItem < ApplicationRecord
include MissionBased, FormVersionable, Replication::Replicable, TreeTraverseable
DISPLAY_IF_OPTIONS = %i(always all_met any_met)
acts_as_paranoid
acts_as_list column: :rank, scope: [:form_id, :ancestry, deleted_at: nil]
# These associations are really only applicable to Q... |
class ImportMonthlyAdsController < ServiceBaseController
def confirm
csv_file = params[:monthly_ad_csv]
data_type = params[:data_type]
if csv_file.blank? || data_type.blank?
if csv_file.blank?
flash[:alert] = 'CSVファイルを選択してください'
else
flash[:alert] = '目標か実績を選択してください'
end
... |
class CreateUzers < ActiveRecord::Migration[5.0]
def change
create_table :uzers do |t|
t.string :fio
t.string :phone
t.string :calltime
t.string :preferday
t.string :prefercar
t.string :preferservice
t.string :credittime
t.string :preferbank
t.string :firstmon... |
class CreateGroupMemberships < ActiveRecord::Migration
def self.up
create_table :group_memberships do |t|
t.column :user_id, :integer, :null => false
t.column :group_id, :integer, :null => false
t.column :added_at, :datetime
end
end
def self.down
drop_table :group_memberships
end
end
|
class Recipe < ApplicationRecord
has_many :portfolios, dependent: :destroy
has_many :users, through: :portfolios
has_many :recipe_ingredients, dependent: :destroy
has_many :ingredients, through: :recipe_ingredients
validates :name, uniqueness: true
validates :ingredients, presence: true
vali... |
# -*- encoding: utf-8 -*-
require './spec/helper'
describe Message do
describe "method" do
before :all do
@obj = Message.new(:info, "text")
end
subject { @obj }
it { should respond_to :get_command }
it { should respond_to :proceed }
it { should respond_to :title= }
it { should re... |
require 'rubygems'
require 'tempfile'
require 'tmpdir'
require 'minitest/autorun'
require 'rugged'
require 'pp'
module Rugged
class TestCase < MiniTest::Spec
TEST_DIR = File.dirname(File.expand_path(__FILE__))
private
def temp_repo(repo)
dir = Dir.mktmpdir 'dir'
repo_dir = File.join(TEST_D... |
module S3DirectUpload
module UploadHelper
def s3_uploader_form(options = {}, &block)
uploader = S3Uploader.new(options)
content_tag(:div, uploader.wrapper_options) do
uploader.fields.map do |name, value|
hidden_field_tag(name, value)
end.join.html_safe + capture(&block)
... |
class Podcast < ActiveRecord::Base
has_many :category_podcast_associations
has_many :categories, through: :category_podcast_associations
has_many :episodes
mount_uploader :image, ImageUploader
def episode(number)
episodes.where(:number => number).first
end
end
|
# store infos in mysql
require 'mysql'
# mysql config info
MYSQL_HOST = 'localhost'
MYSQL_USER = 'root'
MYSQL_PASSWORD = ''
MYSQL_DATABASE_NAME = 'to_do_list'
def database_connection
# get or create the 'to_do_list' databse
begin
@database_connection ||=
Mysql.new(MYSQL_HOST, MYSQ... |
class AddNameToCategories < ActiveRecord::Migration
def self.up
add_column(:categories, :name, :string, :default => false, :null => false)
end
def self.down
remove_column(:categories, :name)
end
end
|
Rails.application.routes.draw do
devise_for :users
get 'welcome/index'
root 'welcome#index'
resources :order_items
resource :cart, only: [:show]
resources :products do
resources :reviews
end
end
|
require_relative '../spec_helper'
describe 'frog::database' do
context 'using mysql' do
cached(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |node|
node.set['frog']['db']['dbms'] = 'mysql'
end.converge(described_recipe)
end
it 'requires the mysql dat... |
class Picker::CanceledPickupSerializer < PickupSerializer
attributes :id, :address, :city, :pincode, :lat, :lon, :subscription,
:start_time, :end_time, :category_ids, :total, :status, :reason
belongs_to :user, serializer: UserCommonSerializer
belongs_to :customer
has_many :line_items
def status
curr... |
# 問8 sizeのデフォルト値をショートと設定する
def price(item:, size: "ショート")
case item
when "コーヒー"
price = 300
when "カフェラテ"
price = 400
end
case size
when "ショート"
price
when "トール"
price += 50
when "ベンティ"
price += 100
end
end
puts price(item: "コーヒー")
puts price(item: "カフェラテ", size: "トール") |
class DevelopmentResultsController < ApplicationController
include MyUtility
before_action :set_development_result, only: [:show, :edit, :update, :destroy]
# GET /development_results
def index
placeholder_set
param_set
@count = DevelopmentResult.notnil().includes(:p_name, :place, :parameter_control... |
class ActivitiesCarouselAnswer < Answer
validates :description, :title, :url, :photo, :subtitle, presence: true
def to_carousel_item
{
title: title,
image_url: photo,
subtitle: subtitle,
buttons:[
{
type: "postback",
title: "See Details",
payload: in... |
require 'test_helper'
require 'gds_api/test_helpers/publishing_api'
class PublishingApiScheduleWorkerTest < ActiveSupport::TestCase
include GdsApi::TestHelpers::PublishingApi
test "#perform publishes a publish intent and a coming_soon content item for a new edition" do
stub_default_publishing_api_put_intent
... |
require "application_system_test_case"
class FrontiersTest < ApplicationSystemTestCase
setup do
@frontier = frontiers(:one)
end
test "visiting the index" do
visit frontiers_url
assert_selector "h1", text: "Frontiers"
end
test "creating a Frontier" do
visit frontiers_url
click_on "New Fr... |
# Write a method that takes a single String argument and returns a new string that contains the original value of the argument with the first character of every word capitalized and all other letters lowercase.
# You may assume that words are any sequence of non-blank characters.
# def word_cap(str)
# ret_str = st... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root 'welcome#index'
get '/auth' => "auth#index"
delete '/logout' => "auth#destroy"
resources :activities, only: [:index]
end
|
class Answer < ApplicationRecord
validates :description, presence: true
belongs_to :question
has_many :user_answers
has_many :users, through: :user_answers
end
|
require "json"
module Bundle
class TapDumper
attr_reader :taps
def initialize
if Bundle.brew_installed?
@taps = begin
JSON.load(`brew tap-info --json=v1 --installed`) || []
rescue
[]
end
else
raise "Unable to list installed taps. Homebrew is no... |
module Stepable
def steps
if self.is_a?(King)
[[0,1], [0,-1], [1,1], [1,0], [1,-1], [-1,0], [-1,1], [-1,-1]]
elsif self.is_a?(Knight)
[[1,-2], [2,-1], [2,1], [1,2], [-1,-2], [-2,-1], [-2,1], [-1,2]]
else
if self.color == :red
[[1, 0], [2, 0]]
else
[[-1, 0], [-2, 0]]... |
#
# Cookbook Name:: hdfsdu
# Recipe:: build
#
# Copyright 2017, Bloomberg Finance L.P.
#
# 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
#
# Unles... |
FactoryBot.define do
factory :user, :class => 'User' do
email 'test@test.com'
password '12345678'
password_confirmation '12345678'
trait :admin do
admin true
end
trait :wrong_user do
email 'qvu@colgate.edu'
password '12345678'
password_confirmation '12345678'
end
... |
class ChangePhotoDrawingToBlob < ActiveRecord::Migration[6.0]
def change
add_column :refinery_caststone_photos, :blob, :binary, if_not_exists: true
add_column :refinery_caststone_photos, :drawing_width, :integer, if_not_exists: true
add_column :refinery_caststone_photos, :drawing_height, :integer, if_not_... |
FactoryGirl.define do
factory :document do
user
sequence(:name){ |n| "Document#{n}" }
sequence(:description){ |n| "Interesting Document #{n} " * 50 }
document{ Rack::Test::UploadedFile.new("#{Rails.root}/app/assets/images/rails.png", "image/png") }
end
end
|
class OrdersMailer < ActionMailer::Base
default from: "CreativeQ <no-reply@nqueue.io>"
def order_awaiting_initial_approval (order, emails)
@order = order
if emails.any?
mail(to: emails, subject: "[CreativeQ] Awaiting Initial Approval: #{@order.name}")
end
end
def order_awaiting_advisor_approval (order, ... |
require 'spec_helper'
describe Api::V1::ItaOfficeLocationsController, type: :controller do
describe '#search' do
context 'with valid parameters' do
before do
expect(ItaOfficeLocation).to receive(:search_for).and_return(double('search'))
end
it 'responds correctly with full params' do
... |
module ViolentRuby
# Unix Password Cracker provides a friendly interface to
# crack unix passwords. Because all hackers totes do this.
# @author Kent 'picat' Gruber
#
# @example Basic Usage
# config = { file: "/etc/passwd", dictionary: "dictionary.txt" }
#
# upc = ViolentRuby::UnixPasswordCracker.ne... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# Available to all the controllers but now views by default
protect_from_forgery with: :exception
#Helper is the current user logged in?
helper_method ... |
module Workers
class SyncAllWithEmailMarketingService < Base
def perform
User.where("id IN (SELECT DISTINCT user_id FROM authentications) and id IN (SELECT DISTINCT user_id FROM demands WHERE state = 'canceled')").all.each_with_index do |user, index|
Workers::SyncWithEmailMarketingService.perform_in... |
class User < ActiveRecord::Base
attr_accessible :username, :email, :password, :password_confirmation, :authentications_attributes
authenticates_with_sorcery! do |config|
config.authentications_class = Authentication
end
has_many :authentications, :dependent => :destroy
accepts_nested_attributes_for :aut... |
module IQ::Processor::Config
@default_storage_dir = File.join('public', 'assets')
@tempfile_path = File.join(RAILS_ROOT, 'tmp', 'uploads')
@adapters = {}
class << self
attr_accessor :default_storage_dir, :tempfile_path
attr_reader :adapters, :default_adapter
end
# Used to s... |
# frozen_string_literal: true
FactoryGirl.define do
factory :user_group do
name { SecureRandom.hex }
end
end
|
Rails.application.routes.draw do
devise_for :users, controllers: {
registrations: 'users/registrations',
sessions: 'users/sessions',
confirmations: 'users/confirmations',
omniauth_callbacks: 'omniauth_callbacks'
}
resources :dashboard
get '/hosting-dashboard', to: 'dashboard#dashboard'
root 's... |
require_relative "piece"
require_relative "slidingpiece"
class Rook < Piece
include SlidingPiece
# def initialize(name, symbol, position, color)
# super(name, symbol, position, color)
# end
protected
def move_dirs
possible_directions = [] # [1,1]
SlidingPiece.VERTICAL.each {|k,v| possible_dire... |
class ImageAttachment < ApplicationRecord
mount_uploader :avatar, AvatarUploader
belongs_to :image
end
|
require 'descriptive_statistics/safe'
module XMLMunger
class StateError < StandardError; end
class ListHeuristics
def initialize(list)
raise ArgumentError, "Argument must be an array" unless list.is_a?(Array)
@list = list
end
def empty?
@empty ||= @list.count.zero?
end
def ... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.id
can [:update, :create_nested_resource], Profile, user_id: user.id
can [:create, :update, :destroy, :set_avatar, :remove_avatar], Photo, profile: { user_id: user.id }
can [:create, :update, :destroy, :u... |
#
# PlatoDevice::TSL2591 class
#
module PlatoDevice
class TSL2591 < Plato::Sensor
include Plato
I2CADDR = 0x29
# registers
COMMAND = 0xa0 # Command bit
R_ENABLE = 0x00 # Enable
R_CTRL = 0x01 # Control
R_DEV_ID = 0x12 # Device ID
R_DEV_STS = 0x13 # Device Stat... |
module Webex
module User
# comment
class Activation
include Webex
include Webex::User
attr_accessor :webex_id, :partner_id, :back_url
def initialize(attributes = {})
attributes.each { |k, v| send("#{k}=", v) }
env_attributes!
option_required! :webex_id, :partne... |
Rails.application.routes.draw do
get "/api/v1/courses", to: 'api_v1#index'
options "/api/v1/courses", to: 'api_v1#options'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.