text stringlengths 10 2.61M |
|---|
class AddErrorToWorkflowAccrualKeys < ActiveRecord::Migration[5.2]
def change
add_column :workflow_accrual_keys, :error, :text
end
end
|
module Ecm::Tournaments
class Series < ActiveRecord::Base
# associations
has_many :ecm_tournaments_tournaments, :class_name => Tournament,
:foreign_key => 'ecm_tournaments_series_id'
# attributes
attr_accessible :description, :name
# validations
val... |
# frozen_string_literal: true
require "i18n"
module LocaleSpecHelper
def self.included(base)
base.extend(ExampleGroupMethods)
end
def with_locale(new_locale, &block)
I18n.with_locale(new_locale, &block)
end
module ExampleGroupMethods
def set_locale(new_locale) # rubocop:disable Naming/Accessor... |
=begin
#Location API
#Geolocation, Geocoding and Maps
OpenAPI spec version: 2.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.4
=end
require 'spec_helper'
require 'json'
# Unit tests for unwiredClient::SEARCHApi
# Automatically generated by openapi-generator (https://openapi-genera... |
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: proc{ I18n.t("active_admin.dashboard") } do
div class: "blank_slate_container", id: "dashboard_default_message" do
span class: "blank_slate" do
#span I18n.t("active_admin.da... |
include DataMagic
DataMagic.load("account_summary.yml")
password = data_for(:canadian_entitlements_accounts)['password']
Then(/^the error page is displayed in french with a canadian phone number$/) do
on(LoginErrorPage).hold_for_page_load
puts on(LoginErrorPage).error_message
puts message = data_for(:canadian_... |
class AssetHelper
def self.url(asset_path)
ActionController::Base.helpers.asset_url(asset_path, skip_pipeline: true)
end
end
|
describe do
attr :published, Date.new(2013, 2, 8) # 8 Feb. 2013
attr :title, "Life through the viewfinder"
attr :is_article, true
content file('article/5-life-through-the-viewfinder.md')
end
|
# A group is a collection of participants
# in the parent application, a group has a creator
class Group < ActiveRecord::Base
include ThinkFeelDoDashboard::Concerns::Group
belongs_to :arm
has_many :memberships, dependent: :destroy
has_many :active_memberships,
-> { active },
class_name: ... |
class SubscribeToNewsletterService
def initialize(user)
@user = user
@gibbon = Gibbon::Request.new(api_key: ENV['MAILCHIMP_API_KEY'])
@audience_id = ENV['MAILCHIMP_AUDIENCE_ID']
@member_id = Digest::MD5.hexdigest(user.email)
end
def call
response = @gibbon.lists(@audience_id).members.retrieve... |
require 'blue_hawaii/season'
require 'json'
require 'bigdecimal'
require 'date'
class RentalUnit
attr_reader :name, :rate, :cleaning_fee, :seasons
TAX_RATE = BigDecimal.new "1.0411416"
def initialize(options)
json = options.key?(:data) ? JSON.parse(options[:data]) : options[:json]
@name = json["name"... |
class SubscriptionSerializer < ActiveModel::Serializer
attributes :id, :name, :lesson_count
end
|
class RemoveStoryJsonFromStories < ActiveRecord::Migration
def change
remove_column :stories, :story_JSON, :text
end
end
|
require 'test_helper'
class ApoyosControllerTest < ActionDispatch::IntegrationTest
setup do
@apoyo = apoyos(:one)
end
test "should get index" do
get apoyos_url
assert_response :success
end
test "should get new" do
get new_apoyo_url
assert_response :success
end
test "should create a... |
class StoreSelectionsController < ApplicationController
#rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
before_action :set_store, only: [:select_store]
layout "selection"
def index
@stores = Store.where("open_time < ? and close_time > ? ", Time.now , Time.now)
end
def select... |
class TwilioInbound
include Sidekiq::Worker
def perform(twilio_params)
@text = Text.new(twilio_params)
@citizen = Citizen.find_or_create_by(phone_number: @text.number)
ProcessInboundText.call(text: @text, citizen: @citizen)
TwilioOutbound.perform_async(@citizen.e164_phone, @text.respond_with)
en... |
FactoryBot.define do
factory :blood_pressure do
id { SecureRandom.uuid }
systolic { rand(80..240) }
diastolic { rand(60..140) }
device_created_at { Time.current }
device_updated_at { Time.current }
recorded_at { device_created_at }
association :facility, strategy: :create
association ... |
Dir[File.join(Dir.pwd,'lib','access_control','*.rb')].each {|f| require f}
module AccessControls
def self.access_control(controller)
params = controller.params
access_control_method = params[:action]
begin
access_module = (controller.class.to_s + "Access").constantize
rescue => e
if e.to_... |
require 'spec_helper'
describe RandomPath do
it 'Decodes letters to paths' do
random_path = build(:random_path)
random_path.path_choice = 'AWEFDSNB'
random_path.has_path?(:air).should be_true
random_path.has_path?(:earth).should be_true
random_path.has_path?(:fire).should be_true
random_pat... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_duser!
before_filter :update_sanitized_params, if: :devise_controller?
def update_sanitized_params
devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:email, :password, :password_con... |
require 'twing/utility/callback'
class Twing
module Modules
module Extend
@@callbacks = Callback.new
def callbacks
@@callbacks
end
def on_init(&block)
self.callbacks.add(:init, &block)
end
def after_init(&block)
self.callbacks.add(:after_init, &block... |
class Tag < ActiveRecord::Base
attr_accessible :name
has_and_belongs_to_many :posts
def to_param
"#{id}-#{name.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/,'').parameterize}"
end
end
|
module HerokuCLI
# Maintenance status of app
class Maintenance < Base
# display the current maintenance status of app
def status
heroku('maintenance').strip
end
# take the app out of maintenance mode
def off
heroku 'maintenance:off'
end
# put the app into maintenance mode
... |
# frozen_string_literal: true
#
# Overload the integer class
#
class Integer
def human_duration(type = 'compact')
HumanDuration::Duration.display_type(type)
HumanDuration::Duration.human_duration(self)
end
end
|
class RenameTypeToFtypeOnFacts < ActiveRecord::Migration
def self.up
rename_column :facts, :type, :ftype
end
def self.down
rename_column :facts, :ftype, :type
end
end
|
require 'faraday'
require 'panamax_agent/middleware/response/listify_json'
module PanamaxAgent
module Journal
module Connection
def connection
Faraday.new(connection_options) do |faraday|
faraday.request :json
faraday.response :json
faraday.response :listify_json
... |
# frozen_string_literal: true
require 'application_system_test_case'
class InstructionFeatureTest < ApplicationSystemTestCase
setup { screenshot_section :instruction }
def test_index
visit_with_login '/'
click_menu 'Instruktøroppsett', section: 'Instruksjon'
assert_current_path '/group_instructors'
... |
(1..100).each do |x|
puts "BitMaker" if x % 3 == 0 && x % 5 == 0
puts "Bit" if x % 3 == 0
puts "Maker" if x % 5 == 0
end
|
require "application_system_test_case"
class CompatibilitiesTest < ApplicationSystemTestCase
setup do
@compatibility = compatibilities(:one)
end
test "visiting the index" do
visit compatibilities_url
assert_selector "h1", text: "Compatibilities"
end
test "creating a Compatibility" do
visit ... |
#===============================================================
# create command for execute kubectl to design namespace
#===============================================================
def do_create_namespace(namespace, default_per_namespace_max_pods)
name = namespace['name']
annotations = namespace['annotations'... |
class Event < ApplicationRecord
belongs_to :user
after_create :inform_signatories_new_event_email
before_save :check_send_approved, if: :is_approved_changed?
def check_send_approved
send_approved if self.is_approved
end
def send_approved
EventMailer.delay.event_processed(self.user, self)
end
def infor... |
describe Bullock::Parse::SymbolExpansions do
describe "#expands" do
it "no Productions are given if #produces is never invoked" do
instance = Bullock::Parse::SymbolExpansions.new(:symbol)
expect(instance.productions).to be_empty
end
it "creates a Production with symbol and a single expansion... |
class Bilibili < ActiveRecord::Base
validates :content, :stream_id, presence: true
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
def author_name
if author_id.blank?
return '游客'
else
return author.nickname || author.hack_mobile
end
end
end
|
require 'rails_helper'
describe "find a random item" do
it "can provide a single random item" do
@item1, @item2, @item3 = create_list(:item, 3)
get '/api/v1/items/random'
expect(response).to be_success
item = JSON.parse(response.body)
expect(item["id"]).to eq(@item1.id) | eq(@item2.id... |
require 'osx/cocoa'
require 'pathname'
module Installd
class RealPath
include OSX
def initialize(command)
NSLog("Installd::RealPath: initialize: #{command}")
path = %x[/usr/bin/which #{command}].chomp
NSLog("path = #{path}")
@pathname = Pathname.new(path)
NSLog("realpa... |
module Chopper
def self.chop(needle, haystack)
return -1 if haystack.size == 0 || (haystack.size == 1 && !haystack.include?(needle))
return 0 if haystack.size == 1 && haystack.include?(needle)
half_way = (haystack.size / 2)
haystack1 = haystack[0..half_way-1]
haystack2 = haystack[half_way..-1]
... |
class JassetsController < ApplicationController
before_action :authorize, except: [:index]
before_action :set_jasset, only: [:show, :edit, :update, :destroy]
def index
@resources = Jasset.pluck(:link_name).uniq.sort
@order_by_resource_date = { asc: 'Oldest First', desc: 'Newest First' }
order = para... |
def ordinalize(number)
suffix = { '1' => 'st', '2' => 'nd', '3' => 'rd' }
digits = number.to_s
if suffix.key?(digits[-1]) && digits[-2] != '1'
digits + suffix[digits[-1]]
else
digits + 'th'
end
end
|
class Photo < ActiveRecord::Base
attr_accessible :user_id, :name, :picture, :is_profile
belongs_to :user
mount_uploader :picture, PhotoUploader
end
|
class Pet < ApplicationRecord
belongs_to :user
has_one_attached :image
validates :name, presence: true
validates :age, presence: true
validates :city, presence: true
validates :state, presence: true
def as_json(options={})
{
:id => id,
:name => name,
:age => age,
:status => status,
... |
module Structural
module Model
class Association < Field
def type
options.fetch(:type) { inferred_class }
end
def inferred_class
hierarchy.parent.const_get(inferred_class_name)
end
def inferred_class_name
@inferred_class_name ||= name.to_s.classify
end... |
class Incident < ActiveRecord::Base
include Timezones
def self.current
where("weather IS NOT NULL").where("traffic IS NOT NULL").where("region in (?)", ["slc","seattle","sf","la","nyc"])
end
def to_json
data = JSON.parse(blob)
data['time'] = created_at.in_time_zone(Timezones::lookup region)
data['weather']... |
module Fog
module Compute
class Google
class Mock
def insert_subnetwork(_subnetwork_name, _region_name, _network, _ip_range, _options = {})
# :no-coverage:
Fog::Mock.not_implemented
# :no-coverage:
end
end
class Real
##
# Create a su... |
module SsmlBuilder
class Builder
attr_reader :ssml_content
def initialize
@ssml_content = ""
end
def say(string)
space_precheck
@ssml_content += remove_characters(string)
end
def paragraph(string)
@ssml_content += "<p>" + remove_characters(string) + "</p>"
end
... |
json.array!(@pictures) do |picture|
json.extract! picture, :id, :local_id, :sample_id, :specimen_id, :lab_test_id
json.url picture_url(picture, format: :json)
end
|
module Identity::Sources
class Json < Base
def update(identity, url)
json = identity.set_profile('json', fetch(url))
# i.e. when the json defines a github handle, we'll pull the github profile
Identity::Sources.update_from_source(identity, 'github', json['github']) if json
end
def prof... |
class OrderItem < ApplicationRecord
belongs_to :variation
belongs_to :order
end
|
# require 'services/robotics'
class Api::RobotController < ApplicationController
before_action :robot_params
def orders
if (params.has_key?'commands') && is_request_valid?(params['commands'])
render json: Robotics.new(params['commands']).call
else
head :unprocessable_entity
end
end
private
def r... |
require 'csv'
def banner
puts "Welcome to FOOD HUB!"
end
class String
def capitalize_each
self.split(" ").each{|word| word.capitalize!}.join(" ")
end
def capitalize_each!
replace capitalize_each
end
end
def create_account
puts "Please enter the following: "
print "Full Name: "
name = gets.chomp.... |
require 'autotest'
module Autotest::CucumberMixin
def self.included(receiver)
receiver::ALL_HOOKS << [:run_features, :ran_features]
end
attr_accessor :scenarios_to_run, :feature_results
def initialize
super
reset_features
end
def run
hook :initialize
reset
reset_features
... |
class UserMessageCount
include Mongoid::Document
field :user_id, type: Integer
field :user_name, type: String
field :private_count, type: Integer
field :system_count, type: Integer
field :study_count, type: Integer
field :updated_at, type: DateTime
def self.inc_private_message(user_id)
u... |
require 'spec_helper'
describe SearchConstraint do
describe "#matches?" do
let(:request) { Object.new }
subject { SearchConstraint.matches? request }
it 'returns true when the q query param is present' do
allow(request).to receive(:query_parameters).and_return({ q: ''})
expect(subject).to eq... |
module AcmePluginDropin
class ChallengeController < ApplicationController
def index
if params[:challenge].present? && params[:challenge].length >= 16 && params[:challenge].length <= 256
render plain: Challenge.current_challenge, status: :ok
else
render plain: "Challenge failed", status... |
module ApplicationHelper
def flash_class(level)
case level
when "notice" then "alert alert-info"
when "success" then "alert alert-success"
when "error" then "alert alert-danger"
when "alert" then "alert alert-danger"
end
end
# add tr field
def link_to_add_tr_field(name, f, association, ... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def after_sign_in_path_for(resource)
root_path # change this when we know where the new user should really start... |
describe 'Fixnum' do
describe '#s2h' do
it 'répond' do
expect(12).to respond_to :s2h
end
[
[12, '0:00:12'],
[60, '0:01:00'],
[3600, '1:00:00'],
[125, '0:02:05'],
[4830, '1:20:30'],
[3723, '1:02:03']
].each do |s, h|
it "`#{s}.s2h` retourne « #{h} »" do
... |
require_relative 'character_card'
class SpellCard < CharacterCard
def create_card(xml_file)
path = xml_file["document"]["public"]["character"]["spellsmemorized"]["spell"]
if path.class == Hash
@class_cards << {
"count": 1,
"color": "green",
"title": "#{path["name"]}",
... |
class Student
#Getter
attr_reader :first_name,:last_name
#Contractor
def initialize(first_name,last_name,grade)
@first_name = first_name
@last_name = last_name
@grade = grade
end
#method for output
def to_s
"#{last_name} , #{first_name}"
end
def senior?
grade == 12
end ... |
class Song < ActiveRecord::Base
validates :title, presence: true
validates :released, exclusion: { in: [nil] }
validates :release_year, presence: true, if: :released
validates :title, uniqueness: { scope: :release_year }
validate :released?
def released?
if release_year && release_year > Time.now.year... |
#!/usr/bin/env ruby
# encoding: utf-8
# File: errors.rb
# Created: 19/01/12
#
# (c) Michel Demazure <michel@demazure.com>
module JacintheReports
# top module for errors
module Error
# Configuration or connection errors
ConfigureError = Class.new(::StandardError)
# For re-raising Sequel errors
Seq... |
# == Schema Information
#
# Table name: user_feed_entries
#
# id :integer not null, primary key
# user_id :integer
# feed_entry_id :integer
# visited :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not ... |
class CreateCharactersGames < ActiveRecord::Migration[5.1]
def change
create_table :characters_games do |t|
t.integer :character_id
t.integer :game_id
t.timestamps
end
add_index :characters_games, [:character_id, :game_id]
end
end
|
require 'test_helper'
class RestrictedAccessesTest < ActionDispatch::IntegrationTest
def setup
@user = users(:angelo)
@other = users(:arthur)
end
test "should not be able to access email nor password edit pages" do
get change_passwords_user_path(@user)
assert_not flash.empty?
assert_redirec... |
module Adminpanel
class Product < ActiveRecord::Base
include Adminpanel::Base
include Adminpanel::Facebook
include Adminpanel::Friendly
has_many :categorizations
has_many :categories, through: :categorizations
mount_images :photos
validates_presence_of :name
validates_presence_of :p... |
module Attributable
def attr_reader(attributes=[])
attributes.each do |attr|
self.define_singleton_method(attr) do
# Turn :name into '@name'
instance_var = "@#{attr.to_s}"
self.instance_variable_get(instance_var)
end
end
end
def attr_writer(attributes=[])
attribut... |
require 'rails_helper'
RSpec.describe UserPoint, :type => :model do
describe 'associations' do
it { is_expected.to belong_to(:location) }
end
it 'has a valid factory' do
expect(build :state).to be_valid
end
describe 'allow mass assignment of' do
it { is_expected.to allow_mass_assignment_of(:id)... |
class CausesController < ApplicationController
# GET /headaches_cause
# GET /headaches_cause.json
def index
@cause = Cause.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @cause }
end
end
# GET /cause/1
# GET /cause/1.json
def show
@cause = ... |
json.array!(@requirements) do |requirement|
json.extract! requirement, :id, :summary, :acceptance_criteria, :status
json.url requirement_url(requirement, format: :json)
end
|
require "sinatra"
require "sinatra/reloader" if development?
require "sinatra/content_for"
require "tilt/erubis"
def error_for_list_name(name)
# add and return an array to store multiple errors
if !(1..100).cover? name.size
"List name must be between 1 and 100 characters."
elsif session[:lists].any? { |list|... |
module GemPolish
class CLI::Versioner
def initialize(thor)
@thor = thor
@version = extract_from_version_file
end
def extract_from_version_file
file_contents.match(regexp)
numbers = $1.split('.').map(&:to_i)
Hash[%w{ major minor revision}.zip(numbers)]
end
def to_ver... |
Rails.application.routes.draw do
devise_for :users
resources :tasks
resources :people
resources :departments
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
get 'administrators', to: 'administrators#index'
get 'toggle_admin', to: 'administrators#toggle... |
class AddJoinMailingListToUsers < ActiveRecord::Migration
def change
add_column :users, :join_mailing_list, :boolean
end
end
|
class AddAttachmentIconHomeToContent < ActiveRecord::Migration
def self.up
add_column :contents, :icon_home_file_name, :string
add_column :contents, :icon_home_content_type, :string
add_column :contents, :icon_home_file_size, :integer
add_column :contents, :icon_home_updated_at, :datetime
end
def... |
class Dealer < ActiveRecord::Base
belongs_to :user
has_many :customers
has_many :vehicles
attr_accessible :name
validates :name, :length => { :minimum => 2 }
end
|
class GradesController < ApplicationController
load_and_authorize_resource
helper_method :sort_column, :sort_direction
# GET /grades
# GET /grades.json
def index
@grades = Grade.order(sort_column + " " + sort_direction)
respond_to do |format|
format.html # index.html.erb
format.json { ren... |
require 'formula'
class Ecl < Formula
homepage 'http://ecls.sourceforge.net/'
url 'https://downloads.sourceforge.net/project/ecls/ecls/15.2/ecl-15.2.21.tgz'
sha1 'fcf70c11ddb1602e88972f0c1596037df229f473'
bottle do
sha1 "1f5441b4a7cd4f62be787b771060655ec92b0642" => :yosemite
sha1 "c042f476840561458d01... |
class UsersController < ApplicationController
before_action :require_signin, except: [:new, :create]
before_action :require_right_user, only: [:show, :edit, :update, :destroy]
before_action :require_admin, only: [:show, :edit, :update, :destroy]
def index
@users = User.all
end
def show
@user = Use... |
require File.dirname(__FILE__) + '/../test_helper'
require 'project_configurations_controller'
# Re-raise errors caught by the controller.
class ProjectConfigurationsController; def rescue_action(e) raise e end; end
class ProjectConfigurationsControllerTest < Test::Unit::TestCase
fixtures :project_configurations
... |
#-----------------------------------------------------------------------------#
# ► ABS Prexus 1.2 - New Edition◄
#
# Criado por Prexus
# Traduzido por Ogrim_Dooh
# New Edition(DEMO) por LegendsX
#
#-------------------------------------------------------------------------... |
# From http://gist.github.com/62943
# Author http://github.com/trotter
module RSpec
module Mocks
module ArgumentMatchers
class ArrayIncludingMatcher
# We'll allow an array of arguments to be passed in, so that you can do
# things like obj.should_receive(:blah).with(array_including('a', 'b')... |
class Bitmap
attr_accessor :width
attr_accessor :mask
attr_accessor :flags
def initialize(value, width=1)
self.flags = value
self.width = width
self.mask = (1<<width)-1
end
def get(pos)
r = flags & (mask<<(pos*width))
r >> (pos*width)
end
def set(pos, setting)
r = flags & ~(ma... |
module Zenform
class CombineError < StandardError
attr_reader :keys
def initialize(keys)
@keys = keys
super "Values are not same length. keys: #{keys}"
end
end
class ParseError < StandardError
attr_reader :path, :line_num, :parent_error
def initialize(path, line_num, parent_error)... |
#
# Cookbook Name:: test
# Library:: helper
#
# Copyright (C) 2013-2016 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#... |
class PolymorphicAttachment < ActiveRecord::Base
belongs_to :polymorphic_attachmentable, polymorphic: true, optional: true
mount_uploader :attachment_file, PolymorphicAttachmentUploader
def to_jq_upload
{
"name" => read_attribute(:attachment_file),
"size" => attachment_file.size,
"thumb_ur... |
require 'spec_helper'
describe Opendata::UrlHelper, type: :helper, dbscope: :example do
let(:icon_file_path) { "#{Rails.root}/spec/fixtures/ss/logo.png" }
let(:icon_file) { Fs::UploadedFile.create_from_file(icon_file_path) }
describe ".member_icon" do
context "when menber has icon" do
let(:member) { c... |
require 'helper'
describe 'getting a batch' do
let(:username) { String.generate }
let(:password) { String.generate }
subject { Esendex.new(username, password) }
let(:batch) { Batch.generate }
let(:response_body) { batch.to_xml }
before {
stub_request(:get, "https://#{username}:#{password}@api.esendex... |
require 'test_helper'
class Links::Season::NhlBiosTest < ActiveSupport::TestCase
test "#site_name" do
assert_equal "NHL.com", Links::Season::NhlBios.new.site_name
end
test "#description" do
assert_equal "Bios", Links::Season::NhlBios.new.description
end
test "#url" do
season = seasons(:fourtee... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.integer :age
t.string :gender
t.string :city
t.string :email
t.string :sex_preference
t.string :hair_color
t.string :eyes_color
t.float :height
t.boolean :... |
require 'rails_helper'
describe 'External authentication' do
context 'Twitter' do
let(:response) do
{
}.to_json
end
before(:each) do
stub_request(:post, "https://api.twitter.com/oauth/request_token").
to_return(body: response)
end
it "authentice twitter user" do
... |
class Connection < ActiveRecord::Base
belongs_to :term
belongs_to :related_term, :class_name => "Term"
end
|
class App < ActiveRecord::Base
attr_accessible :category, :description, :name, :url
belongs_to :user
has_many :reviews
has_many :upvotes, :as => :upvotable
extend FriendlyId
friendly_id :description, use: :slugged
def self.findByNameOrId(nameOrId)
app = find_by_name(nameOrId)
if app.nil?
a... |
class Form::User < User
REGISTRABLE_ATTRIBUTES = %i(nickname employee_number group_id)
has_many :answers, class_name: 'Form::Answer'
after_initialize { answers.build unless self.persisted? || answers.present? }
def selectable_group
Group.all
end
end
|
# copied from: http://lucatironi.net/tutorial/2015/08/23/rails_api_authentication_warden/?utm_source=rubyweekly&utm_medium=email
require 'rails_helper'
RSpec.describe AuthenticationToken, type: :model do
describe "db structure" do
it { is_expected.to have_db_column(:user_id).of_type(:integer) }
it { is_expe... |
class Ability
include CanCan::Ability
def initialize(user)
user.role.permissions.each do |permission|
if permission.subject_class == "all"
can permission.action.to_sym, permission.subject_class.to_sym
else
can permission.action.to_sym, permission.subject_class.constantize
end
... |
module Api::V1
class WeekdaySettingsController < ApiController
before_action :set_user
def index
render json: @user.weekday_settings
end
def update_all
if @user.update(weekday_settings_params)
render json: @user.weekday_settings
else
render json: @user.errors
... |
# $LICENSE
# Copyright 2013-2014 Spotify AB. All rights reserved.
#
# The contents of this file are 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-... |
require 'spec_helper'
require 'baby_squeel/relation'
require 'shared_examples/table'
require 'shared_examples/relation'
describe BabySqueel::Relation do
subject(:table) { create_relation Post }
include_examples 'a table'
include_examples 'a relation'
describe '#method_missing' do
it 'raises a NoMethodErr... |
require 'march_madness/seeds'
module MarchMadness
class Engine
attr_reader :bracket_mapping, :qualifier_rank, :bracket_size
def initialize(qualifier_rank)
@qualifier_rank = qualifier_rank
@bracket_size = qualifier_rank.size
@bracket_seed = MarchMadness::SEEDS[@bracket_size]
@bracket_... |
require 'paperclip'
class Photo < ActiveRecord::Base
include Paperclip::Glue
default_scope -> { order('created_at DESC') }
belongs_to :post
belongs_to :article
belongs_to :gallery
belongs_to :building
has_attached_file :photo, :styles => {:small => "185x185!", :medium => "250x250", :large => "800x600"}... |
class AddTypeToToken < ActiveRecord::Migration
def change
add_column :tokens, :type, :int
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.