text stringlengths 10 2.61M |
|---|
class Comment < ActiveRecord::Base
belongs_to :post
belongs_to :member
belongs_to :workgroup_category
scope :last_published, where(['workgroup_category_id IS NULL']).order('created_at DESC').limit(3)
def is_editable_by(user)
if self.member_id == user.member.id || user.role == 'admin'
return true
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Get the number of web nodes to start up, defaults to 3
web_nodes = ENV['WEB_NODES_NUMBER'].to_i || 3
Vagrant.configure(2) do |config|
config.vm.box = "precise32"
config.vm.box_url = "https://files.hashicorp.com/precise32.box"
config.vm.provider :virtualbox do |vb|
... |
require 'rails_helper'
RSpec.describe Ticket, type: :model do
let(:excavator) { create(:excavator) }
let(:date_times) { create(:date_times) }
let(:digsite_info) { create(:digsite_info) }
let(:ticket) { create(:ticket, excavator: excavator, date_times: date_times, digsite_info: digsite_info) }
it { is_expecte... |
class Photo < ActiveRecord::Base
belongs_to :user
has_many :orders
has_attached_file :pic,
styles: { medium: "400x400>",
compact: "300x300>",
thumb: "200x200>" }
has_and_belongs_to_many :tags
has_many :likes
has_many :users, :throu... |
class ChecklistsController < ApplicationController
before_action :authenticate_user!
before_action :set_checklist, only: [:edit, :update, :show]
def index
@checklists = Checklist.for_user(current_user)
end
def new
@checklist = Checklist.new
@checklist.check_items << CheckItem.new
end
def ed... |
class UserLike < ActiveRecord::Base
belongs_to :user
belongs_to :to_user, :foreign_key => :to_user_id, :class_name => 'User'
scope :to_user_id_is, ->user_id{where(to_user_id: user_id)}
end
|
class CLI
def start
puts "Welcome to TV Maze! What is your name?"
input = get_input
greeting(input)
end
def get_input
gets.strip
end
def greeting(name = "User")
puts "Awesome! Nice to meet you #{name}"
puts "If you would like to see a list of shows en... |
require 'spec_helper'
describe PostsHelper do
let(:post) { double :post }
describe '#destroy_post_link' do
it 'should return destroy post link if user has ability' do
allow(helper).to receive(:can?).with(:destroy, post).and_return true
allow(helper).to receive(:post_path).with(post).and_return 'pa... |
class SubscriptionsController < ApplicationController
before_action :authenticate_user!
before_action :find_subscription, except: %w[index new create]
def index
end
def new
@subscription = Subscription.new
end
def create
if params["Month"]
plan = "PZ month"
elsif pa... |
class TutorSeeSummaryController < ApplicationController
before_action :authenticate_tutor!
before_action :check_profile
def index
@users = User.includes(:summaries).where(tutor_id: current_tutor.id)
end
def show
@summary = Summary.find(params[:id])
#現在指導中でない学生の報告は読めないようにする
count = 0
curr... |
class UserBook < ApplicationRecord
belongs_to :book
belongs_to :user
validates :have_read, inclusion: { in: [ true, false ] }
end
|
class Store < ApplicationRecord
validates :name, presence: true
has_many :store_product_relations,dependent: :delete_all
has_many :products,through: :store_product_relations
def self.search(name)
return self.where('name like ?',"%#{name}%")
end
end
|
class Disciplina < ApplicationRecord
validates :Nome, :presence => true, :length => {:minimum => 3}
validates :Sigla, presence: true, :length => {:is => 2}, uniqueness: {message: 'is already used by one student. It must be unique.'}
end
|
class Admin::CommentsController < Admin::ApplicationController
before_action :set_activity, :set_paper
before_action :set_comment, only: :destroy
def create
@comment = current_user.comments.new(comment_params)
@comment.paper = @paper
if @comment.save
@activity.notify("new_comment", @comment)
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
protect_from_forgery with: :null_session, :if => Proc.new {|c| c.request.format == 'application/json'}
before_action :authenticate_user_from_token! , :if => Proc.new {|c| c.request.format == 'application/json'}
before_act... |
require 'rails_helper'
RSpec.describe "invoice items relationships" do
before(:each) do
@invoice = create(:invoice)
@item = create(:item)
@invoice_item = create(:invoice_item, item_id: @item.id)
@invoice_item_1 = create(:invoice_item)
end
it "can load the associated item" do
get "/api/v1/in... |
class StaticController < ApplicationController
def home
@title ="Home"
end
def about
@title ="About Us"
end
def customer_by_state
#will have 2 columns, This will parse the Customer table and return the states of customers in the customer table and count customer
#by their state attribute
... |
# frozen_string_literal: true
# Loan table
class CreateLoans < ActiveRecord::Migration[5.2]
def change
create_table :loans do |t|
t.string :loan_type
t.integer :amount
t.integer :months
t.float :rate
t.datetime :time_of_issue
t.datetime :end_of_loan
t.references :client... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Zlib compression' do
require_zlib_compression
before do
authorized_client['test'].drop
end
context 'when client has zlib compressor option enabled' do
it 'compresses the message to the server' do
# Double check th... |
class Rating < ActiveRecord::Base
attr_accessible :value
belongs_to :photo
belongs_to :user
end
|
class ChangeTvaInProducts < ActiveRecord::Migration
def change
rename_column :products, :tva, :tva_cents
end
end
|
# frozen_string_literal: true
class WechatUtils
def self.encrypt(data, iv, session_key)
cipher = OpenSSL::Cipher.new('AES-128-CBC')
cipher.encrypt
cipher.key = Base64.decode64(session_key)
cipher.iv = Base64.decode64(iv)
Base64.encode64(cipher.update(data.to_json) + cipher.final)
end
def sel... |
module Rack::Cache
autoload :Key, 'rack/cache/key'
class ProxyKey < Key
# Generate a normalized cache key for the request.
def generate
parts = []
parts << @request.scheme << "://"
parts << @request.env["HTTP_X_FORWARDED_HOST"]
parts << @request.script_name
parts << ... |
class Place < ActiveRecord::Base
belongs_to :user
has_many :reviews, dependent: :destroy
validates_presence_of :name, :phone, :website, :user_id, :address
geocoded_by :address
after_validation :geocode
end
|
class Store < ApplicationRecord
has_many :employee
has_many :message
belongs_to :store_auth
end
|
require 'test_helper'
class ContenuVentesControllerTest < ActionDispatch::IntegrationTest
setup do
@contenu_vente = contenu_ventes(:one)
end
test "should get index" do
get contenu_ventes_url
assert_response :success
end
test "should get new" do
get new_contenu_vente_url
assert_response ... |
class CreateAvatarVideos < ActiveRecord::Migration
def change
create_table :avatar_videos do |t|
t.column :user_id, 'CHAR(8)', null: false
t.string :video, null: false # For carrierwave
t.string :uuid, null: false
t.timestamps
t.index :user_id
end
end
end
|
class CreateThisOrThats < ActiveRecord::Migration
def change
create_table :this_or_thats do |t|
t.string :image1
t.string :image2
t.text :description
t.string :comment
t.boolean :is_private
t.integer :user_id
t.string :pants_brand
t.string :shirt_brand
t.strin... |
class Pg < Thor
include Thor::Actions
desc "init", "Create a postgresql db cluster. Sets user from config as super user."
method_option :config, :aliases => '-c', :desc => "Location of a rails database.yml file.", :default => './config/database.yml'
method_option :environment, :aliases => '-e', :desc => "Envi... |
class Player < ApplicationRecord
serialize :hand, Array
belongs_to :game
end
|
class Post < ActiveRecord::Base
has_many :comments, dependent: :destroy
validates :title, :body, presence: true
validate :title, uniqueness: true, length: { minimum: 10 }
validate :body, length: { minimum: 20 }
end
|
require 'pg'
module TwitterCli
class Timeline
#used for creating timeline of an user
attr_reader :user
def initialize(connection, user)
@conn = connection
@user = user
end
def process
#need to rename process
user_result = @conn.exec('select name from users where name = $1'... |
class CreateStates < ActiveRecord::Migration
def self.up
create_table :states do |t|
t.column :name, :string
t.column :abbreviation, :string
end
states_file = open(RAILS_ROOT + "/db/migrate/states.txt")
for line in states_file.readlines
id, name, abbreviation = line.split("\t")
... |
class IssueInvitationObserver < ActiveRecord::Observer
observe :issue
include Rails.application.routes.url_helpers
include EasyIcalHelper
def self.default_url_options
{ :host => Setting.host_name, :protocol => Setting.protocol }
end
def after_create(issue)
create_and_send_invitation(issue) if iss... |
Given /^I have a camp with all fields required$/ do
visit '/camps/new'
within("form") do
fill_in "Name", :with => (@name = Factory(:camp).name)
fill_in "Location", :with => Factory(:camp).location
fill_in "PayPal URL", :with => Factory(:camp).payment_url
fill_in "Cost", :with => Factory(:camp).co... |
require 'test_helper'
class FeedSchedulerJobTest < ActiveSupport::TestCase
def setup
@daily_feed = Factory :feed_definition, :feed_queue_class => 'ReviewSummaryFeedJob'
@weekly_feed = Factory :feed_definition, :feed_queue_class => 'ReviewSummaryFeedJob', :interval => 'weekly', :start_date => 1.week.a... |
def echo(message)
message
end
def shout(message)
message.upcase
end
def repeat(message, number=2)
result = message
(number-1).times { result = "#{result} #{message}" }
result
# Fred's partial solution... [].inject(message) { |result, message| "#{result} #{message}" }.
end
def start_of_word(word, number_... |
Rails.application.routes.draw do
root 'public#index'
get 'work', to: 'public#work', as: :work
get 'about', to: 'public#about', as: :about
get 'resources', to: 'public#resources', as: :resources
get 'contact', to: 'public#contact', as: :contact
get '/people/mona', to: 'people#mona', as: :mona
resources :p... |
class AnnoncesController < ApplicationController
before_action :authenticate_user!, only: %w(mine destroy modify contact signaler show)
protected
def annonce_params
params.require(:annonce).permit(:picture,:title,:description,:category_id,:user_id,:price,:uploads_attributes => [:picture])
end
public
de... |
Given(/^I logged into the Single account and navigate to Transactions and details page to submit a dispute$/) do
visit(LoginPage)
on(LoginPage) do |page|
login_data = page.data_for(:dispute_single_disputable_ods) #dispute_single_DNR_charge
username = login_data['username']
password = login_data['pass... |
require_relative 'pantograph_exception'
module PantographCore
class Interface
class PantographError < PantographException
attr_reader :show_github_issues
attr_reader :error_info
def initialize(show_github_issues: false, error_info: nil)
@show_github_issues = show_github_issues
... |
require_relative './path.rb'
require 'yaml'
module VulnTemplates
private
class DataLoaderClass
attr_reader :templates, :index, :reverse_index, :required_params
def initialize(include_files, exclude_files=nil)
@index = {}
current_file = nil
templates = {}
reverse_index ... |
module PPC
module API
class Baidu
class Bulk < Baidu
Service = 'BulkJob'
def self.get_all_object( auth,params = {})
plan_ids = params[:plan_ids]
unless plan_ids.nil?
plan_ids = plan_ids.class == Array ? plan_ids : [plan_ids]
end
... |
# == Schema Information
#
# Table name: sessions
#
# id :integer not null, primary key
# user_id :integer not null
# session_token :string(255) not null
# created_at :datetime
# updated_at :datetime
#
class Session < ActiveRecord::Base
validates_presence_of :user, ... |
require "net/http"
require "sham_rack/registry"
require "sham_rack/http"
class << Net::HTTP
alias :new_without_sham_rack :new
def new(address, port = nil, *proxy_args)
port ||= Net::HTTP.default_port
rack_app = ShamRack.application_for(address, port)
http_object = new_without_sham_rack(address, p... |
class Ethereum::DexController < NetworkController
before_action :set_exchange, :breadcrumb
layout 'tabs'
private
def set_exchange
@exchange = params[:exchange]
end
def breadcrumb
@breadcrumbs << {name: @exchange} << {name: t("tabs.#{controller_name}.#{action_name}.name")}
end
end
|
Theresashultz::Application.routes.draw do
resources :cats
root to: 'home#index'
end
|
# frozen_string_literal: true
RSpec.describe Dry::Types::Builder, "#default" do
context "with a nominal type" do
subject(:type) { Dry::Types["nominal.string"].default("foo") }
it_behaves_like Dry::Types::Nominal
it "returns default value when no value is passed" do
expect(type[]).to eql("foo")
... |
class ChangeAllowCreateSongsToPreferencesTable < ActiveRecord::Migration[5.2]
def change
change_column :preferences, :allow_create_songs, :boolean
end
end
|
#item3 = Armor.new("Item 4 (Armor)", { defense: 200 }, price: 200, sell_value: 100)
#p item3
require_relative "item"
class Armor < Item
attr_reader :defense
attr_accessor :equipped
def initialize(name, item_args)
super(name, item_args)
@equipped = false
@defense = item_args[:defense] || 0
end
end
|
class Line
COLORS = {
:black => "[30m",
:red => "[31m",
:green => "[32m",
:yellow => "[33m",
:blue => "[34m",
:magenta => "[35m",
:cyan => "[36m",
:light_gray => "[37m",
:dark_gray => "[90m",
:light_red => "[91m",
:light_green => "[92m",
:light_yellow => "[93m",
:li... |
#!/usr/bin/env ruby
#
### Simple socket server listening on <PORT> that writes <MB> megabytes and then sleeps for <SECONDS>
#
# Sends the connecting client data and logs how long it took => get speed.
#
#USE: tcp_server <read/write> <HOST> <PORT> <MB> <SEC>
#USE: tcp_server read 127.0.0.1 30000 1024 60
#USE: tcp_server... |
require 'test_helper'
describe 'Organization' do
describe 'relations' do
it 'should belong_to team' do
organization = create :organization
team = Team.first
Organization.count.must_equal 1
Team.count.must_equal 1
team.organizations.must_equal [organization]
organization.team.... |
# number of cars
cars = 100
# space available in the car
space_in_a_car = 4.0
# drivers
drivers = 30
# passengers
passengers = 90
# returns number of empty cars
cars_not_driven = cars - drivers
# cars_driven and drivers are the same number
cars_driven = drivers
# returns capacity
carpool_capacity = cars_driven * space_... |
class AddIndexesToCloudCostSchemes < ActiveRecord::Migration
def change
change_table :cloud_cost_schemes do |t|
t.index :cloud_id
t.index :cloud_resource_type_id
t.index :cloud_cost_structure_id
end
end
end
|
#!/usr/bin/env ruby
require 'thor'
class MyCLI < Thor
desc 'db_migrate [VERSION]', 'Migrate to VERSION or latest'
def db_migrate(version = nil)
require 'logger'
require 'sequel'
Sequel.extension :migration
db = Sequel.connect(adapter: 'postgres', host: 'db', database: ENV['POSTGRES_DB'], user: ENV[... |
#!/usr/bin/env ruby
require_relative '../etc/git-helper/git_helper'
# Wrapper for removing one or several branches from a remote
#
# Usage :
# $ git-branch-remove-remote branch (origin)
# $ git-branch-remove-remote branch1 branch2 (origin)
# $ git-branch-remove-remote branch upstream
# $ git-branch-remove-remote upstre... |
#==============================================================================
# +++ MOG - Extra Pattern (v1.0) +++
#==============================================================================
# By Moghunter
# https://atelierrgss.wordpress.com/
#============================================================... |
require ("minitest/autorun")
require_relative("../turn_log")
class TestTurnLog < MiniTest::Test
def setup
@turn_log1=TurnLog.new({player: "Val",roll: 7, modifier: -7})
@turn_log2=TurnLog.new({player: "Val",roll: 2, modifier: 4})
@turn_log3=TurnLog.new({player: "Val",roll: 1, modifier: 0})
end
... |
xml.instruct!
xml.tag!("error-response") do
xml.code response.status
xml.message ERROR_CODES[response.status]
end
|
module RelationsExtension::PageExtension
def self.included(base)
base.class_eval do
has_and_belongs_to_many :related_pages,
:class_name => 'Page',
:join_table => 'related_pages',
:foreign_key => 'page_id',
... |
class Doctor < ActiveRecord::Base
has_many :interns, dependent: :destroy
has_many :appointments, dependent: :destroy
has_many :patients, through: :appointments
validates :first_name, :last_name, presence: true, length: { minimum: 3 }
validates :first_name, uniqueness: { scope: :last_name }
end |
class Api::V1::OmniauthCallbacksController < Devise::OmniauthCallbacksController
include IpCoordinates
def facebook
auth('Facebook')
end
def google_oauth2
auth('Google')
end
private
def auth(kind)
last_coordinates = ip_coordinates(request)
user = User.auth(request.env["omniauth.auth"], las... |
#!/usr/bin/env ruby
# Fetch information about VPS on all nodes
#
# Run from confctl cluster configuration directory
require 'fileutils'
require 'json'
self_root = File.realpath(File.dirname(__FILE__))
if ARGV.length != 1
warn "Usage: #{$0} <output directory>"
exit(false)
end
output = File.absolute_path(ARGV[0])
... |
# frozen_string_literal: true
require "spec_helper"
require_relative "../../../lib/chapter_4/lax"
RSpec.describe "Exercise 1" do
it "works like enumerator" do
res = 1.upto(Float::INFINITY).
lax.
map { |x| x*x }.
map { |x| x+1 }.
select { |x| x%2 == 0}.
take(5).
to_a
expe... |
# frozen_string_literal: true
class InformationPage < ApplicationRecord
module Status
PROMOTED = 'PROMOTED'
PUBLIC = 'PUBLIC'
MEMBERS = 'MEMBERS'
HIDDEN = 'HIDDEN'
end
STATUSES = Status.constants.map { |s| Status.const_get(s) }
acts_as_tree
acts_as_list scope: :parent_id
has_many :front_p... |
require 'spec_helper'
ssl_dir = '/srv/http/default/ssl'
subject_command = "openssl x509 -noout -subject -in"
fingerprint_command = "openssl x509 -noout -fingerprint -in"
key_path = File.join(ssl_dir, 'keys', 'default.key')
cert_path = File.join(ssl_dir, 'certs', 'default.pem')
describe file('/etc/nginx/sites/default.... |
class App::IosDecorator < Draper::Decorator
decorates App::Ios
delegate_all
def type
'iOS'
# helpers.fa_icon('apple', text: 'iOS')
end
end
|
class Course < ApplicationRecord
# has_ancestry
has_many :notes
has_many :readings
has_many :class_materials
has_one_attached :picture
validates :name, presence: true
end
|
class Api::AuthorsController < ApplicationController
def index
@authors = Author.includes(:books)
render json: @authors, adapter: :json
end
def show
@author = Author.find(params[:id])
render json: @author, adapter: :json
end
end
|
#!/usr/bin/env ruby
# encoding: utf-8
# File: model.rb
# Created: 20/01/12
#
# (c) Michel Demazure <michel@demazure.com>
require_relative 'instance_methods.rb'
require_relative 'tiers_instance_methods.rb'
require_relative 'client_instance_methods.rb'
# reopening Symbol
class Symbol
# @return [String] CamelName ass... |
module IshManager
module ApplicationHelper
def pretty_date input
return input.strftime("%Y-%m-%d")
end
def pp_errors errors
return errors
end
def user_path user
if user.class == 'String'
"/users/#{user}"
elsif user.class == User
"/users/#{user.id}"
... |
require_relative('../db/sql_runner')
require_relative('./customer')
class Film
attr_accessor :title, :price, :tickets_sold
attr_reader :id
def initialize(options)
@title = options['title']
@price = options['price']
@id = options['id'].to_i
@tickets_sold = 0
end
def save()
sql = "INSERT ... |
feature 'Using a daily diary' do
scenario 'Adding a new diary entry' do
visit '/diary'
click_button "Add Entry"
expect(page).to have_content "Please enter a title and your diary entry"
expect(page).to have_css("input", :count => 3)
end
scenario 'Displaying added diary entry' do
visit '/diary... |
class UsersController < ApplicationController
def index
all_users = User.all #.order(:created_at)
all_users.each do |user|
user.vote_count = user.vote_counter
user.save
end
@users = all_users.order(:created_at)
# raise
end
def show
@user = User.find_by(id: params[:id])
i... |
require 'spec_helper'
shared_examples_for Pacer::Core::Graph::ElementRoute do
describe '#properties' do
subject { r.properties }
its(:count) { should == r.count }
its(:element_type) { should == :hash }
specify 'should all be hashes' do
props = subject.each
elements = r.each
elements... |
module Clickatell
class Query
include HTTParty
STATUS = {0 => "nil", 1 => "Message unknown", 2 => "Message queued", 3 => "Delivered to gateway", 4 => "Received by recipient", 5 => "Error with message", 6 => "User cancelled message delivery", 7 => "Error delivering message", 8 => "OK", 9 => "Routing error... |
# =======
# SHA-256
# =======
# -----
# Utils - Handy functions for converting integers and strings to binary
# -----
# Convert integer to binary string (32 bits)
def bits(x, n = 32)
if x >= 0
return "%0#{n}b" % x
else
# Note: Ruby NOT function returns a negative number, and .to_s(2) displays this mathemat... |
require 'spec_helper'
describe LocationSetting do
it { should belong_to (:user) }
it { should validate_presence_of(:name) }
it { should validate_presence_of(:notification_frequency) }
it { should validate_presence_of(:notification_method) }
it { should validate_presence_of(:pace_min) }
it { should valida... |
module PipelineService
module V2
module API
class Publish
def initialize(model)
@model = model
@noun = Noun.new(model)
@payload = Payload.new(
object: @noun
)
end
def call
payload = @payload.call
PipelineService... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "centos/7"
config.vm.box_check_update = false
# Create a forwarded port mapping which allows acce... |
class SubscriptionFetcher
attr_reader :subscriptions
def initialize(subscriptions, options = {})
@subscriptions = fetch(subscriptions)
end
private
def fetch(ids)
ids.map do |id|
begin
parse_subscription(Braintree::Subscription.find(id))
rescue Braintree::ServerError,
... |
require 'yaml'
require 'require_relative'
require_relative '../logging'
require_relative '../datasource/datasource_arcgis_cache'
require_relative '../datasource/util'
class RMapServiceManager
@port = 9494
@host = "127.0.0.1"
@services = {}
@port_entities = {}
class << self; attr_accessor :port, :host, :ser... |
require 'person'
describe Person do
let(:noob) { Person.new }
let(:bike) { double :bike }
let(:jockey) { Person.new(bike) }
let(:station) {double :station, release: :bike, dock: true}
it 'should not have a bike to begin with' do
expect(noob).not_to have_bike
end
it 'should be able to take a bike' do
noo... |
# OperationDetail model
class OperationDetail < ActiveRecord::Base
belongs_to :operation
belongs_to :account
validates :amount, presence: true, numericality: { greater_than: 0 }
validates :account_id, presence: true
validates :operation_id, presence: true
def asset?
account.category == 'assets'
end
... |
require 'ostruct'
# require 'pry'
# constraints:
# 1. no song should have a sound played on it more than once
# 2. no person should have to play a sound more than once
# 3. people should wait as long as possible to play their own instrument
class Instrument
attr_accessor :name, :person
@@all = []
def initiali... |
class AddStudentIdToStudentUsers < ActiveRecord::Migration
def change
add_column :student_users, :student_id, :integer
end
end
|
CarrierWave.configure do |config|
config.root = Rails.root.join('tmp')
config.cache_dir = 'carrierwave'
if Rails.env.test? or Rails.env.production?
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV['AWS_KEY_ID'], ... |
require 'spec_helper'
describe 'Blog' do
it 'articles are created with form' do
login
visit new_article_path
title = 'hook audience here'
body = 'wow them'
fill_in 'Title', with: title
fill_in 'Body', with: body
click_button 'Save'
article = Article.first
article.should_not be_n... |
class User < ActiveRecord::Base
include BCrypt
# Remember to create a migration!
# Remember to create a migration!
# ej. User.authenticate('fernando@codea.mx', 'qwerty')
has_many :questions
validates :email, format: { with: /\w*[@][a-z]*[.][a-z]*/i, message: "Invalid email" }
validates :passwor... |
class ProfileAnswersController < ProfileBaseController
ssl_required :edit, :edit_special, :update if App.secure?
layout 'bare'
cache_sweeper :profile_sweeper, :only => [:update]
SPECIAL_QUESTION_IDS = [9]
def edit
questions = Question.active.filter_question_type('fun fact')
setup_at_q_a... |
feature 'UsersController' do
describe 'user services' do
context 'by_iuvare_id' do
let!(:user){ create(:user, iuvare_id: "12066412") }
it 'should get user' do
visit("#{by_iuvare_id_users_path}.json?iuvare_id=12066412")
response = JSON.parse(page.body)
expect(response['success... |
class User < ApplicationRecord
has_many :goals
validates :name, :email, :salary, presence: true
end
|
# service.rb
module Service
def url(host, port, base_url='')
"http://#{host}:#{port}#{base_url}"
end
end
|
class ChangePointsToRatingInVotes < ActiveRecord::Migration
def change
rename_column :votes, :amount, :rating
end
end
|
# Problem 2
# Create a class called Animal.
# Add an instance method to Animal called sound that returns a string indicating the sound an animal makes.
# Add an instance method to Animal called speak that prints the string The animal says: followed by the string returned by the sound method.
# Now create two subcla... |
class Event < ApplicationRecord
has_one_attached :photo
end
|
# Copyright (c) 2006, 2007 Ruffdogs Software, Inc.
# Authors: Adam Lebsack <adam@holonyx.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# This program ... |
require 'sidekiq'
Sidekiq.configure_client do |config|
redis_config = { url: ENV.fetch("REDIS_URL") }
redis_config.merge!(namespace: ENV["REDIS_NAMESPACE"]) if ENV["REDIS_NAMESPACE"]
config.redis = redis_config
end
require 'sidekiq/web'
run Sidekiq::Web
|
require 'rails_helper'
RSpec.describe 'As a visitor', type: :feature do
describe 'from the hospital show page' do
it "I see the hospital's name, number of doctors, and universities" do
hospital1 = Hospital.create!(name: 'Grey Sloan Memorial Hospital')
hospital2 = Hospital.create!(name: 'Pacific North... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.