text stringlengths 10 2.61M |
|---|
class EntryDecorator < BaseDecorator
def owner_name
if member.name.present?
member.name
else
member.email
end
end
def score
challenge.finished_evaluating? ? final_score : I18n.t('entries.not_available')
end
end
|
class Group < ActiveRecord::Base
has_many :assigned_groups
has_many :users, :through => :assigned_groups
#attr_accessible :name,:description
end |
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'csv-safe'
Gem::Specification.new do |spec|
spec.name = 'csv-safe'
spec.version = '3.2.1'
spec.authors = ['Alex Zvorygin']
spec.email = ['grafetu@gmail.com']
spec.summary ... |
# The Template Method Pattern
class Report
def initialize
@title = "Monthly Report"
@text = ["Things are going", "really really well"]
end
def output
puts('<html>')
puts('<head>')
puts("<title>#{@title}</title>")
puts('</head>')
puts('<body>')
@text.each do |text|
puts("<p>... |
class DocumentExportWorker
include Sidekiq::Worker
def perform(document_export_id)
document_export = DocumentExport.find(document_export_id)
document_export.update_attributes(export_jid: jid)
document_export.export
end
end
|
json.array!(@statuses) do |status|
json.extract! status, :id, :keyword
json.url status_url(status, format: :json)
end
|
require 'date'
class GitCommit
def initialize(hash, author, date, message)
@hash = hash
@author = author
@date = date
@message = message
end
attr_reader :hash
attr_reader :author
attr_reader :date
attr_reader :message
def self.parse(text)
matched = /
commit\s+(?<commit_... |
class Genre < ApplicationRecord
has_many :clothes, dependent: :destroy
belongs_to :user
end
|
# This is an internal class intended for use by the helper methods present in the {GoogleVisualization} class.
#
# Converts a Ruby object into a string containing valid javascript for 'string' 'number' 'boolean' 'date' 'datetime' 'timeofday' types
# http://code.google.com/apis/chart/interactive/docs/reference.html#Data... |
class UserAddress < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :prefecture
belongs_to :user, optional: true
# validates :postal_code, presence: true, on: :save_phone_to_session
with_options on: :register do
validates :postal_code, ... |
require_relative 'repository'
module Fitter
module Repositories
class StepRepo < Repository[:steps]
commands update: :by_pk
def by_exercise_type_id(type_id)
steps.where(exercise_type_id: type_id).order(:index)
end
def by_exercise_type_id_and_index(type_id, index: 1)
step... |
class AddHomeNamesToRelationship < ActiveRecord::Migration[5.2]
def change
add_column :relationships, :home_name, :string
end
end
|
class Timeline < ApplicationRecord
belongs_to :project
belongs_to :congressman
validates :body, presence: true
validates :timeline_date, presence: true
scope :recent, -> { order(timeline_date: :desc) }
scope :oldest, -> { order(timeline_date: :asc) }
# mount
mount_uploader :image, ImageUploader
end
|
module Supersaas
class Appointment < BaseModel
attr_accessor :address, :country, :created_by, :created_on, :deleted, :description, :email, :field_1, :field_2, :field_1_r, :field_2_r, :finish, :form_id, :full_name, :id, :mobile, :name, :phone, :price, :res_name, :resource_id, :schedule_id, :schedule_name, :service... |
class CreateRules < ActiveRecord::Migration
def change
create_table :rules_rules do |t|
t.belongs_to :rule_set
t.text :expression
t.timestamps
end
end
end
|
module Asaas
module Entity
autoload :Base, 'asaas/entity/base'
autoload :Account, 'asaas/entity/account'
autoload :BankAccount, 'asaas/entity/bank_account'
autoload :City, 'asaas/entity/city'
autoload :Customer, 'asaas/entity/customer'
autoload :Error, 'asaas/entity/error'
autoload :ErrorI... |
require_relative 'spec_helper'
describe "Eye::Http" do
let(:uri){ URI.parse("http://127.0.0.1:#{PORT}/") }
it "should up and down" do
app = Eye::Http.new(uri.host, uri.port)
expect{ Net::HTTP.get(uri) }.to raise_error(Errno::ECONNREFUSED)
app.start
sleep 0.5
Net::HTTP.get(uri).should == Eye:... |
# Select the odd-indexed numbers from an array and store them in a new array.
array = [0, 1, 2, 3, 5, 6, 7, 10, 11]
new_array = []
index = 0
loop do
break if index == array.size
current = array[index]
new_array << current if current.odd?
index += 1
end
new_array == [1, 3, 5, 7, 11] #=> true
# Select all the ’g... |
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# title :string(255) not null
# url :string(255)
# content :text
# user_id :integer not null
# created_at :datetime
# updated_at :datetime
#
# Read about factories at https://gith... |
Facter.add(:nr_ruby_found) do
confine :kernel => :linux
setcode do
ruby = Facter::Util::Resolution.exec('which ruby 2> /dev/null')
if ruby && !ruby.empty?
version = Facter::Util::Resolution.exec("#{ruby} -e 'puts RUBY_VERSION'")
version.start_with?('1.8.7', '1.9', '2.0')
else
false
... |
#!/usr/bin/ruby
# https://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/33-advanced-arrays/lessons/86-stacks-and-queues
class Queue
attr_reader :store
def initialize
@store = []
end
def dequeue
@store.pop
end
def enqueue(element)
@store.unshift(element)
self
end
def size... |
# encoding: utf-8
require File.expand_path("../spec_helper", __FILE__)
describe "TableRow" do
before :each do
browser.goto(WatirSpec.files + "/tables.html")
end
describe "#exists?" do
it "returns true if the table row exists" do
browser.row(:id, "outer_first").should exist
browser.row(:id, ... |
require 'pivotal-github/command'
require 'pivotal-github/finished_command'
class StoryMerge < FinishedCommand
def parser
OptionParser.new do |opts|
opts.banner = "Usage: git story-merge [branch] [options]"
opts.on("-o", "--override", "override unfinished story warning") do |opt|
self.options... |
# Public API for Programs
#
# When you pass in episodes, it has to be either an Array or a Relation
# This is to prevent accidental loading of hundreds of episodes.
class Program
include Concern::Methods::AbstractModelMethods
class << self
def all
(KpccProgram.all + ExternalProgram.all).map(&:to_program)... |
require 'rails_helper'
RSpec.describe Dog, type: :model do
let(:dog) { create(:dog) }
describe '項目に不備がない場合' do
it '有効である' do
expect(dog).to be_valid
end
end
end
|
class UsersController < ApplicationController
def destroy
@user = User.find(params[:id])
return head(:forbidden) unless current_user.admin?
@user.delete
redirect_to root_path
end
def index
end
def show
@user = User.find_by(id: params[:id])
unless current_user.admin?
unless @user.id ... |
namespace :scraper do
desc "Fetch Wines from the wine API"
task scrape: :environment do
require 'open-uri'
require 'json'
#http://services.wine.com/api/beta2/service.svc/JSON/catalog?filter=product&apikey=b83910c31344dbe67a1b501d8ccd5bf7
# Set API token and URL
apikey = "b83910c31344dbe67a1b501d8ccd5bf7"
p... |
class BuyerProfile < ApplicationRecord
belongs_to :user, dependent: :destroy
# mount_uploader :avatar, PhotoUploader
# after_create :send_welcome_email
# validates :size, :style, presence: true
# ------ Welcome email method
# private
# def send_welcome_email
# UserMailer.welcome_buyer(user).deliver_no... |
class Board
attr_reader :cells, :num_let, :num_num
def initialize(num_let = 4, num_num = 4)
@cells = {}
@num_let = ("A".."J").to_a[0..num_let-1]
@num_num = ("1".."10").to_a[0..num_num-1]
end
def make_cell_keys
@num_let.map do |let|
@num_num.map do |num|
(let + num).to_sym
e... |
require 'spec_helper'
describe 'api/v1/users/show.rabl' do
before do
@now = Time.zone.now
@user_mock = double('user mock', {
'uuid' => 'tree-trunks',
'email' => 'thats-bunk@easy-as-childbirth.com',
'created_at' => @now,
'updated_at' => @now
})
assign(:user, @user_mock)
end
... |
# frozen_string_literal: true
class Headhunters::RegistrationsController < Devise::RegistrationsController
skip_before_action :authenticate!
skip_before_action :current_user
def new
@headhunter = Headhunter.new
@headhunter.build_headhunter_email
authorize @headhunter
end
def create
@headhun... |
class Seller < User
has_many :purchases, :foreign_key => "seller_id"
# attr_accessible :title, :body
attr_accessor :total_costs, :costs, :purchase_prices
def total_cost_of_sales
costs = self.purchases.map(&:cost)
self.total_costs = costs.inject{|sum, cost| sum + cost}.to_f
end
def list_costs
s... |
class Cadastro < SitePrism::Page
set_url '/cadastro'
element :nome, '#nome'
element :email, '#email'
element :senha, '#senha'
element :btn_criar, '.btn'
def preencher_formulario
nome.set 'Maria Clara'
email.set 'mariaclara11@teste.com'
senha.set '123456'
btn_c... |
require 'rake'
require 'rubygems'
require 'active_record'
require 'yaml'
task :default => 'db:migrate'
namespace :db do
desc "Migrate the database. Target specific version with VERSION=x"
task(:migrate => :environment) do
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Migration.verbose = tr... |
Rails.application.routes.draw do
#Home
match("/", { :controller => "home", :action => "landing", :via => "get" })
# Routes for the Borrowingcard resource:
# CREATE
match("/new_borrowingcard_form", { :controller => "borrowingcards", :action => "blank_form", :via => "get" })
match("/insert_borrowingcar... |
require_dependency "hooks"
require_dependency "patches"
Redmine::Plugin.register :redmine_rouge_highlighter do
name "Redmine Rouge-based Syntax Highlighter"
author "Alex Bevilacqua"
description "Supplement CodeRay with Rouge"
url "https://github.com/alexbevi/redmine_rouge_highlighter"
aut... |
module Web::Controllers::Documents
class Search
include Web::Action
'
'
expose :documents, :nodes
expose :active_item
def call(params)
@active_item = 'reader'
search_key = params['search']['search']
cu = current_user(session)
if cu
search_scope = cu.dict2['search_scop... |
class ConfigsCliente < ActiveRecord::Migration[6.1]
def change
remove_column :clientes, :password
end
end
|
# frozen_string_literal: true
class Quiz::Question::TextNormalizer
class << self
def normalize(content:)
new(content: content).normalize
end
end
def initialize(content:)
@content = content.to_s
end
def normalize
normalize_space
normalize_case
strip_whitespace
word_to_number... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
# Update apt and get dependencies
sudo apt-get update
sudo apt-get install -y unzip curl wget vim open-iscsi
# Download Nomad
echo Fetching Nomad...
cd /tmp/
#curl -sSL https://releases.hashicorp.com/nomad/0.4.1/nomad_0.4.1_linux_amd64.zip -o nomad.zip
curl ... |
Gem::Specification.new do |s|
# Release Specific Information
s.version = "1.0.3"
s.date = "2013-05-16"
# Gem Details
s.name = "cssDir2"
s.authors = ["Michael 'Miw0' Worm"]
s.summary = %q{A Compass Extension to copy the generated css file to a different location.}
s.des... |
require 'rails_helper'
feature 'Post management' do
let(:user) { create_user(password: 'garbage', password_confirmation: 'garbage') }
before do
sign_in(user)
end
scenario 'User can create post' do
click_on 'New Post'
expect(current_path).to eq(new_user_post_path(user.id))
expect(page).to have... |
# encoding: UTF-8
module API
module V1
class LearningDynamicsCacheable < API::V1::Base
helpers API::Helpers::V1::LearningDynamicsHelpers
helpers API::Helpers::V1::PresentationsHelpers
helpers API::Helpers::V1::PresentationSlidesHelpers
before do
authenticate_user
end
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe BI::Calculator, type: :model do
describe '#polynomio_to_s' do
context '[3, 2, 1] => 3x^2 + 2x + 1' do
let(:polynomio) { [3, 2, 1] }
let(:str) { '3x^2 + 2x + 1' }
subject { described_class.new.polynomio_to_s(polynomio) }
... |
module Flaggrocrag
Attribution = Struct.new(:name, :email, :time) do
def self.from_blame_hunk(hunk)
sig = hunk[:final_signature]
new sig[:name], sig[:email], sig[:time]
end
end
end
|
require 'oystercard'
RSpec.describe Oystercard do
let(:station){ double :station }
let(:exitstation){ double :station }
describe "#balance" do
it 'tests intial oystercard returns balance of 0' do
expect(subject.balance).to eq 0
end
it "tops up the balance of the card" do
expect(subject... |
class HomeController < ApplicationController
before_action :fetch_current_country_code, only: :index
def locale_redirect
# the redirect is handled by set_locale
end
def index
@signature_count_for_country = Signature.count_for_country_code(@country_code)
@signature_count = Signature.confirmed.count... |
require 'yahoofinance'
require 'json'
# Gets stock data from Yahoo Finance
class Finance
# Looks up symbol in the finance cache. Historical data is current for up to
# a day in the cache and current data for 15 minutes. After that new data
# must be fetched
def self.get_quotes(symbol, is_hist)
symbol.upcas... |
#encoding: utf-8
# 兑奖记录
class CreateAwardRecord < ActiveRecord::Migration
def change
create_table :award_records do |t|
t.references :user
t.references :award
t.string :weixin_name
t.string :name
t.string :mobile
t.timestamps
end
add_index :award_records, :user_id
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate
private
# Authentication
def authenticate
@current_user = User.find_by_auth_token( cookies[:auth_token]) if cookies[:auth_token]
@current_user ||= session[:user_id].present? ? User.f... |
require_relative '../db/sql_runner.rb'
require 'date'
class Transaction
attr_reader :id, :amount, :purchase_date, :merchant_id, :item_id
def initialize(options)
@id = options['id'].to_i if options['id']
@amount = options['amount'].to_i
@purchase_date = options['purchase_date']
@merchant_id = ... |
namespace :deploygate do
desc "Submit an archive to DeployGate"
task :submit do
config = App.config
Rake::Task["build"].invoke
App.info "DeployGate", "Submit #{config.name}.apk to DeployGate"
app_path = "build/#{config.build_mode.to_s.capitalize}-#{config.api_version}/#{config.name}.apk"
messag... |
When(/^I visit the home page$/) do
@home_page = Home.new
@home_page.load
end
Then(/^I see no reviews message$/) do
expect(@home_page).to have_no_reviews
end
Given(/^a review exists$/) do
@review = FactoryGirl.create(:review)
end
Given(/^a tweet review exists$/) do
@tweet_review = FactoryGirl.create(:tweet_... |
##
# La classe qui gère l'affichage et l'interaction avec le menu options qui permet
#d'enlever le son, accéder au classement, aux credits et aux succès
##
# * +win+ La fenetre de l'application
# * +layoutManager+ Le layout principal pour le placement dans la fenetre
class EcranOptions
##
... |
require "pry"
def nyc_pigeon_organizer(data)
# write your code here!
organized_data = {}
data.each do |attribute, values|
values.each do |value, name_array|
#binding.pry
name_array.each do |name|
if organized_data[name]
if organized_data[name][attribute]
organized_da... |
class Vehicle
# attr_reader :make, :year
# attr_writer :year
attr_accessor :make, :year
def initialize(make, car_model, year, color)
@make, @car_model, @year, @color = make, car_model, year, color
end
# def make
# @make
# end
def car_model
@car_model
end
# def year
# @year
# end
def color
@color
... |
# Family Requests are an alternate approach to direct inventory requests. Instead of requesting literal items,
# the Partner indicates who is in the family, and then the organization determines (automatically, through the
# Magic of Technology(TM)) how much inventory should be dispensed to that family, via that Partner... |
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :load_common_values
private
def load_common_values
@common = {
prefs: Pref.scoped.all
}
end
end
|
require 'rails_helper'
feature 'user authenticates before register' do
scenario 'successfully' do
visit root_path
click_on 'Sign up'
fill_in 'Email', with:'pedro@autoseg.com'
fill_in 'Senha', with: '123456'
fill_in 'Repita a senha', with:'123456'
click_on 'Salvar'
expect(page).to have_c... |
# -*- encoding : utf-8 -*-
module DadosSf36Helper
def saude_to_s(saude)
case saude
when 5.0
"Excelente"
when 4.4
"Muito Boa"
when 3.4
"Boa"
when 2.0
"Ruim"
when 1.0
"Muito Ruim"
end
end
def comparacao_saude_to_s(comparacao_saude)
... |
# Subclass the ProgressBarBasic class
# modify the on screen appearance by defining new methods etc. for a second bar
module SW
module LASimporter
class ProgressBarBasicLASDoubleBar < ProgressBarBasicLAS
attr_reader(:value2, :bar2_location, :bar2_width, :bar2_height)
attr_accessor(:label2, :te... |
module Config
module App
SUPPORTED_TYPES = %w(likes groups about friends)
JOB_TIMEOUT = 600 # seconds, 10 minutes
NOLIMIT_JOB_TIMEOUT = 9_000 # seconds, 150 minutes
class << self
def supported_types
SUPPORTED_TYPES.join(', ')
end
def supported_type?(type)
SUPPORTED_... |
class Shop < ApplicationRecord
has_many :business_hours, dependent: :delete_all
has_many :emergencies,class_name:'Emergency'
has_many :friends,class_name:'Friend'
validates :name, presence: true
after_validation :set_slug, only: [:create]
def business_hours_aggregate
if !self.business_h... |
require 'RMagick'
class AlbumBook < ActiveRecord::Base
belongs_to :user
belongs_to :kid, :class_name=>"UserKid"
belongs_to :album_template, :foreign_key=>"template_id"
upload_column :logo, :versions => {:thumb150 => "150x150", :thumb300 => "300x300", :thumb500 => "500x500"}, :store_dir=>proc{|post, file| "a... |
class FruitsController < ApplicationController
def index
if params[:search]
@fruits = Fruit.search params[:search]
else
@fruits = Fruit.all
end
end
def search
redirect_to root_path(search: params[:search])
end
end
|
$stdout.sync = true
require 'yaml'
require 'erb'
require 'singleton'
require 'optparse'
require 'fileutils'
require 'logger'
require 'active_support/core_ext/hash/indifferent_access'
require 'tincan/receiver'
require 'tincan/version'
module Tincan
class Shutdown < Interrupt; end
class CLI
include Singleton
... |
class SchedulesController < ApplicationController
before_action :set_schedule, only: [:show, :edit, :update, :destroy]
#before_action :set_post, only: [:new, :create]
# GET /schedules
# GET /schedules.json
def index
@schedules = Schedule.includes(:polyclinic, :post, :routines).load
.where(polyclinic_id: ... |
## Screenshots are disabled
# require 'pender_redis'
#
# class SaveScreenshotWorker
# include Sidekiq::Worker
#
# def save(url, picture, settings, tab, script = '')
# t = Time.now.to_i.to_s
# tmp = Media.url_hash(url) + '-' + t + '.png'
# path = File.join(Rails.root, 'public', 'screenshots', Media.image... |
require 'chemistry/element'
Chemistry::Element.define "Lanthanum" do
symbol "La"
atomic_number 57
atomic_weight 138.90547
melting_point '1193K'
end
|
class InventoriesController < ApplicationController
before_action :find_by_id, only: [:show, :edit, :update, :destroy]
before_action :authenticate_admin!
def index
@inventories = Item.all
end
def show
end
def new
@inventory = Item.new
render :form, locals: {url: inventories_path, method: 'p... |
# Allow RABL to display the model ID correctly in JSON
module Moped
module BSON
class ObjectId
def to_json(*args)
to_s.to_json
end
end
end
end
|
def valid_number?(number_string) # using a method definition to make sure the user input is valid. That is the user input can be converted to an int and back to a string. We then set that equal to number_string which is essentially our user input, that is invoked in our loops.
number_string.to_i.to_s == number_s... |
class AddAccountTypeToClient < ActiveRecord::Migration
def change
add_column :clients, :account_type, :string
end
end
|
Pod::Spec.new do |s|
s.name = "CalendarIOS7"
s.version = "0.0.6"
s.summary = "Calendar component for iOS apps."
s.requires_arc = true
s.description = <<-DESC
UICollectionViewController and Layout for a perfect iOS Calendar.
DESC
s.homepage = "h... |
require 'rails_helper'
RSpec.describe RecordAddress, type: :model do
describe '購入者の情報保存' do
before do
user = FactoryBot.create(:user)
item = FactoryBot.create(:item)
@record_address = FactoryBot.build(:record_address, user_id: user.id, item_id: item.id)
end
context '購入者情報の保存ができる場合' do
... |
require "uuidtools"
class Runner
def self.generate_waveform(audio)
ActiveRecord::Base.logger = Logger.new(STDOUT)
filename = UUIDTools::UUID.random_create.to_s
ActiveRecord::Base.logger.info(audio.audio)
path = ""
if audio.audio != nil
path = audio.file.path
elsif audio.preview != nil
... |
require 'nogvltest/nogvltest'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: run_threads.rb [options]"
opts.on("-n", "--num-threads NUM_THREADS", "Number of threads") do |v|
options[:num_threads] = v.to_i
end
opts.on("-g", "--with-gvl", "Run loop with GVL") do |v|
opti... |
class Cart < ActiveRecord::Base
belongs_to :customer
has_many :items, :class_name => 'CartItem', :dependent => :delete_all
accepts_nested_attributes_for :items
def items_total_count
items.sum(:quantity)
end
def items_total_price
items.inject(0) { |sum,i| sum + i.price*i.quantity + i.packaging_opti... |
require 'rails_helper'
RSpec.describe AlbumsController, type: :controller do
login_user
let(:user) { current_user }
let(:album) { create(:album, user: user) }
let(:request_exec) { get :edit, params: { user_id: user.id, id: album.id } }
describe "GET #edit" do
before(:each) { request_exec }
include_... |
require 'uri'
module Datamine::Jira
module Util
def summarize_issue issue
url = URI.parse(issue['self'])
{
'key' => issue['key'],
'url' => "#{url.scheme}://#{url.host}/browse/#{issue['key']}",
'summary' => issue['fields']['summary'],
'description' ... |
class BackgroundColorChangerSerializer < ActiveModel::Serializer
attributes :id, :colorHex
end
|
class CreateMovies < ActiveRecord::Migration
def self.up
create_table :movies do |t|
t.integer :phile_id
t.string :name
t.datetime :first_aired_at
t.string :url
t.datetime :seen_at
t.datetime :deleted_at
t.timestamps
end
add_index :movies, :phile_id
en... |
class UserProfile < ApplicationRecord
belongs_to :user, optional: true
belongs_to :family, optional: true
has_many :class_enrollments, dependent: :destroy
normalize_attributes :first_name, :last_name
validates :first_name, :last_name, :date_of_birth, presence: true
delegate :membership, to: :family, all... |
namespace :backup do
task :boot => :environment do
Backup::System.boot!
end
desc "Run Backup Procedure."
task :run => :boot do
puts "Running: #{ENV['trigger']}."
Backup::Setup.new(ENV['trigger'], @backup_procedures).initialize_adapter
end
desc "Finds backup records by trigger"
task :f... |
class Tadpole < ActiveRecord::Base
belongs_to :frog
has_many :ponds, through: :frogs
delegate :pond, :to => :frog
end
|
class Song
attr_accessor :title, :artist
def initialize(title="", artist="")
@title = title
@artist = artist
end
def self.artist
Artist.all.find { |artist| artist == self.artist}
end
end
|
# frozen_string_literal: true
require "graphql/dataloader/null_dataloader"
require "graphql/dataloader/request"
require "graphql/dataloader/request_all"
require "graphql/dataloader/source"
module GraphQL
# This plugin supports Fiber-based concurrency, along with {GraphQL::Dataloader::Source}.
#
# @example Insta... |
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Amendable
describe EditForm do
subject { form }
let!(:component) { create(:opinion_component) }
let!(:amendable) { create(:opinion, component: component) }
let!(:emendation) { create(:opinion, component: component... |
class WishlistsController < ApplicationController
def destroy
@wishlist = current_user.wishlists.find(params[:id])
@wishlist.destroy
redirect_to :back
end
end
|
class PollsController < ApplicationController
before_action :authenticate_user_using_x_auth_token, except: :index
before_action :load_poll, only: :show
before_action :load_options, :load_current_user_response, only: :show
def index
polls = Poll.all
render status: :ok, json: polls
end
def create
... |
#!/usr/bin/env ruby
if $PROGRAM_NAME == __FILE__
require 'webrick'
server = WEBrick::HTTPServer.new Port: 80
server.mount_proc '/authn/users/' do |_req, res|
res.body = '{}'
end
server.mount_proc '/authz/audit' do |req, res|
res.body = 'ok'
body = req.body
File.open('/audits', 'a') { |f| f... |
# 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
#
# a thread representation
#
class Thread
# @return [String] name of the thread
a... |
class User < ApplicationRecord
has_and_belongs_to_many :flights
has_secure_password
validates :email, :uniqueness => true, :presence => true #validations
end
|
require 'rails_helper'
RSpec.describe User do
it { should validate_presence_of :email }
it { should validate_presence_of :username }
it { should have_many :mealbooks }
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UserRole do
it 'preloads correctly' do
admin = create(:role, name: 'admin')
child = create(:role, name: 'child', parent: admin)
users = create_list(:user, 2)
users.each { |u| create(:user_role, user: u, role: child) }
user_roles... |
class Triangle
attr_accessor :side1, :side2, :side3
def initialize(side1, side2, side3)
@side1 = side1
@side2 = side2
@side3 = side3
@check1 = side1+side2
@check2 = side2+side3
@check3 = side1+side3
end
def kind
#check if our triangles are valid
if side1 > 0 && side2 > 0 && sid... |
class Tag < ActiveRecord::Base
has_and_belongs_to_many :questions
validates :name, presence: true
end
|
default_platform(:ios)
platform :ios do
desc 'Export ipa'
lane :export_ipa do
decode_file
keychain_password = SecureRandom.uuid
keychain_name = nil
if !ENV['CUSTOM_KEYCHAIN_NAME'].empty?
keychain_name = ENV['CUSTOM_KEYCHAIN_NAME']
else
keychain_name = 'ios-build.keychain'
end
... |
class LikesController < ApplicationController
def index
@likes = Like.all
render json: @likes
end
def show
@like = Like.find(params[:id])
render json: @like
end
def delete
@like = Like.delete(params[:id])
render json: @like
end
def creat... |
class Task
include ActionView::Helpers::NumberHelper
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
store_in database: 'sribulancer_development', collection: 'tasks'
TITLE_MINIMUM_LENGTH = 8
TITLE_MAXIMUM_LENGTH = 100
DESCRIPTION_MINIMUM_LENGTH = 100
DESCRIPTION_MAXIM... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.