text stringlengths 10 2.61M |
|---|
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
record.errors[attribute] << (options[:message] || "is not an email")
end
end
end
class User < ActiveRecord::Base
attr_accessible :email, :firstname... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
describe 'get#new' do
it 'renders our new user template' do
get :new
expect(response).to render_template(:new)
end
end
describe 'users#create' do
let (:valid_params) { {user: { user... |
class HopManifestsController < ApplicationController
def index
@recipe = Recipe.find(params[:recipe_id])
@manifests = @recipe.hop_manifests
render json: @manifests
end
def show
@manifest = HopManifest.find(params[:id])
render json: @manifest
end
def create
@hop_man = HopManifest.ne... |
require 'test_helper'
class Api::InterventionsControllerTest < ActionController::TestCase
test "should create a new intervention" do
assert_difference('Intervention.count') do
json = { "parliament_member_id" => "1",
"words_json" => [{"count"=>2, "literal"=>"levanta", "lemma"=>"levantar",
... |
require 'base64'
require 'openssl'
require 'securerandom'
class AcquireApi
def initialize(params)
default_params = {
TERMINAL: 'CIS0ET14',
MERCHANT: 'EPB3000E30001PB',
MERCH: 'lllooch',
MERCH_URL: 'http://www.lllooch.ru',
TIMESTAMP: Time.now.strftime('%Y%m%d%H%M%S'),
NONCE: '5... |
class ForgeCLI::App < Thor
desc 'new', 'Create a new Forge app'
def new(app, modules = '')
modules = modules.split(',')
ForgeCLI::ApplicationCreator.create!(app, modules)
end
desc 'install', 'Install modules into the working Forge app'
def install(modules)
app = Dir.pwd
modules = modules.spli... |
class CreateJoinTableInterventionsTags < ActiveRecord::Migration[5.2]
def change
create_join_table :interventions, :tags do |t|
t.index [:intervention_id, :tag_id]
t.index [:tag_id, :intervention_id]
end
end
end
|
class Venue < ApplicationRecord
mount_uploader :photo, PhotoUploader
belongs_to :category
belongs_to :user
has_many :bookings, dependent: :destroy
has_many :reviews, through: :bookings
validates :address, presence: true
validates :description, presence: true
validates :email, presence: true
validates ... |
# frozen_string_literal: true
require 'impraise/worker/requirements'
module Impraise
module Worker
class Watch
def initialize
@config = Impraise::Worker::Config.new
@dns = Impraise::Worker::DNS
disque_host, disque_port = @dns.disco('disque')
@queue = Disque.new("#{disque_ho... |
=begin
Write a method that takes one argument, a positive integer, and returns a string of alternating
1s and 0s, always starting with 1. The length of the string should match the given integer.
Understanding the problem
==========================
Input: positive integer
Output: string of 1s and 0s
Rules:
1. Must ... |
require 'bundler/setup'
require 'csv'
require 'active_support/core_ext/integer/inflections'
require 'active_support/time'
require 'active_model'
require 'fog'
require 'multi_xml'
require 'nokogiri'
require 'pupa'
require 'redis-store'
require 'hiredis'
class Pupa::Membership
attr_reader :person, :post
dump :pers... |
require "rack"
app = lambda do |env|
data = []
data << "RUBY_VERSION #{RUBY_VERSION}"
data << "RUBY_PLATFORM: #{RUBY_PLATFORM}"
data << "RUBY_DESCRIPTION: #{RUBY_DESCRIPTION}"
data << "PID: #{Process.pid}"
data << "ENV:"
ENV.each {|k,v| data << " #{k}: #{v}" }
req = Rack::Request.new(env)
status ... |
Vagrant.configure("2") do |config|
config.vm.define "web" do |web|
web.vm.box = "suse/sles11sp3"
web.vm.network "private_network", ip: "10.99.99.2"
web.vm.provision "shell", path: "provision.sh"
web.vm.hostname = "web"
end
config.vm.define "mssql" do |mssql|
mssql.vm.box = "ferventcoder/win20... |
class EventController < ApplicationController
include ApplicationHelper
before_filter :requires_authentication
def delete
event = Event.find_by_id(params[:id])
event.destroy
respond_to do |format|
format.html { redirect_to :controller => "surfer", :action => current_user.screen_name }
format.js... |
def reformat_languages(languages_hash)
new_hash = {}
languages_hash.each do | style, data |
data.each do | language, lang_data|
lang_sym = language.to_sym
if new_hash[lang_sym].nil?
lang_data[:style] = [style]
new_hash[lang_sym] = lang_data
else
new_hash[lang_sym][:sty... |
class Tag < ActiveRecord::Base
belongs_to :course
has_many :tag_assignments, dependent: :destroy
has_many :assignments, through: :tag_assignments, foreign_key: :course_id #not sure i made the right merge-conflict choice lol #TODO TESTING
end
|
require 'verse'
require 'song'
describe Verse do
it "has lyrics when bottles are at least 3" do
expected_lyrics = [
"3 bottles of beer on the wall, 3 bottles of beer",
"Take one down and pass it around",
"2 bottles of beer on the wall",
].join("\n")
verse = Verse.new(3)
expect(verse... |
require 'csv'
class Rider
attr_reader :id, :name, :phone
def initialize(id, name, phone)
@id = id
@name = name
@phone = phone
end
def self.all
all_riders = []
#
csv_data = CSV.read("support/riders.csv")
csv_data.shift
csv_data.each do |line|
all_r... |
class Parrot
attr_accessor :name, :known_words, :sound
def initialize(name:, known_words:)
@name = name
@known_words = known_words
@sound = "Squawk!"
end
end
|
require './spec_helper'
describe Baseline do
describe 'when invoke get method of Baseline' do
before do
ADMIN_OPERATIONS_FILE = File.expand_path('../data/admin_options.txt', File.dirname(__FILE__))
STUDENT_OPERATIONS_FILE = File.expand_path('../data/student_options.txt', File.dirname(__FILE__))
... |
Given("I click on the twitter subscription workshop link") do
sign_in_page.click_monthly_january_workshop
end
Then("I should be taken to the correct page") do
expect(current_url).to eq("http://www.codebar.io/meetings/monthly-jan-2018")
end
|
class TreeTile
attr_accessor :children, :parent, :color, :pos
def initialize(pos, color)
@parent = nil
@children = []
@color = color
@pos = pos
end
def change_color(new_color)
self.color = new_color
end
def parent=(node=nil)
if node == n... |
Position = Struct.new(:x, :y) do
def to_s
"(#{x},#{y})"
end
def xy
[x, y]
end
def south
Position.new(x, y + 1)
end
def north
Position.new(x, y - 1)
end
end
class Grid
def initialize(width, height)
@items = (0...height).map do |y|
(0...width).map do |x|
yield Posit... |
def measure(n = 1)
res = 0
n.times do
start_t = Time.now
yield
end_t = Time.now
res += end_t - start_t
end
res /n
end
|
class Admin::FacilityGroupsController < AdminController
before_action :set_facility_group, only: [:show, :edit, :update, :destroy]
before_action :set_organizations, only: [:new, :edit, :update, :create]
before_action :set_protocols, only: [:new, :edit, :update, :create]
before_action :set_available_states, only... |
json.array!(@reporte_estado_cuenta) do |reporte_estado_cuentum|
json.extract! reporte_estado_cuentum, :id
json.url reporte_estado_cuentum_url(reporte_estado_cuentum, format: :json)
end
|
class User < ActiveRecord::Base
has_many :workouts
has_many :exercises, through: :workouts
def professor_name
"Dr. #{name}"
end
end |
require 'rails_helper'
describe EadIndexer::Indexer do
let(:indexer) { EadIndexer::Indexer.new('./spec/support/fixtures') }
let(:message) { "Deleting file tamwag/TAM.075-ead.xml EADID='tam_075', Deleting file tamwag/WAG.221-ead.xml EADID='wag_221'" }
before do
allow_any_instance_of(EadIndexer::Indexer).to ... |
class AddWorkableToWorkflows < ActiveRecord::Migration[6.0]
def change
add_reference :workflows, :workable, polymorphic: true, null: false
end
end
|
module ApplicationHelper
def bootstrap_class_for(flash_type)
case flash_type
when :success
"alert-success" # Green
when :error
"alert-danger" # Red
when :alert
"alert-warning" # Yellow
when :notice
"alert-info" # Blue
else
flash_type.to_s
... |
# == Schema Information
#
# Table name: projects
#
# id :integer not null, primary key
# title :string(255)
# extended_description :text
# funding_goal :float
# funding_duration :integer
# category :string(255)
# tags :string(255)
... |
class CreateIncludePeripherals < ActiveRecord::Migration
def self.up
create_table :include_peripherals do |t|
t.integer :game_id, :null => false
t.integer :peripheral_id, :null => false
t.integer :quantity, :null => false, :default => 1
t.timestamps
end
end
def self.down
drop... |
# frozen_string_literal: true
module MoreValidations
def valid_stay?(input)
case input.downcase
when 's', 'stay'
true
end
end
def valid_hit?(input)
case input.downcase
when 'h', 'hit'
true
end
end
end
|
require 'yt/collections/resources'
require 'yt/models/ownership'
module Yt
module Collections
# Provides methods to interact with a the ownership of a YouTube resource.
#
# Resources with ownerships are: {Yt::Models::Asset assets}.
class Ownerships < Resources
private
def attributes_for_n... |
module Registration
module Cell
# @!method self.call(model, options = {})
# @option options [Reform::Form] form
class New < Abroaders::Cell::Base
include Abroaders::LogoHelper
option :form
def title
'Sign Up'
end
private
def errors
cell(Abroaders::... |
require 'rails_helper'
describe GoalsController do
category = Category.create(
name: 'Career'
)
let(:valid_attributes) {
{
user_id: 0,
category_id: category.id,
content: 'Test content',
by_when: DateTime.now,
is_private: false
}
}
let(:invalid_attributes) {
ski... |
require File.expand_path(File.join(File.dirname(__FILE__), "page_objects", "requires"))
describe "Sidebar Shopping cart" do
context "contact us page" do
before(:all) do
@selenium = Selenium::WebDriver.for(:firefox)
end
after(:all) do
@selenium.quit
end
it "should hav... |
# encoding: utf-8
require 'digest'
class User < ActiveRecord::Base
attr_accessor :password, :update_password_checkbox
has_many :user_levels, :dependent => :destroy
belongs_to :input_by, :class_name => "User"
accepts_nested_attributes_for :user_levels, :reject_if => lambda { |a| a[:position].blank? }, :allow_d... |
require 'rails_helper'
RSpec.feature "User signs up" do
def sign_up(email, password, password_confirm=password)
visit "/"
click_link "Sign up"
expect(page).to have_current_path("/users/sign_up")
fill_in "Email", with: email
fill_in "Password", with: password
fill_in "Password confirmation",... |
require "rails_helper"
feature "User editing gifts in a catalog" do
scenario "updates gifts with new data", :js do
catalog = create(:catalog)
create(:gift, catalog: catalog, price: 50)
login_as catalog.user
visit catalog_path(catalog)
expect(page).to have_content("$50")
click_on "Edit Gift... |
# frozen_string_literal: true
RSpec.describe 'MeiliSearch::Client - Stats' do
before(:all) do
@client = MeiliSearch::Client.new($URL, $MASTER_KEY)
end
it 'gets version' do
response = @client.version
expect(response).to be_a(Hash)
expect(response).to have_key('commitSha')
expect(response).to ... |
class GameRecordsController < ApplicationController
before_action :set_game_record, only: [:show, :edit, :update, :destroy]
# GET /game_records
# GET /game_records.json
def index
@game_records = GameRecord.all
end
# GET /game_records/1
# GET /game_records/1.json
def show
@related_question_scor... |
# frozen_string_literal: true
class Admin::Api::ApplicationPlansController < Admin::Api::ServiceBaseController
representer ApplicationPlan
wrap_parameters ApplicationPlan, include: ApplicationPlan.attribute_names | %w[state_event]
before_action :deny_on_premises_for_master
before_action :authorize_manage_plan... |
ReviewController.class_eval do
before_filter :set_hidden_fields, :only => %w(new edit)
before_filter :track_email, :only => :create
before_filter :product_or_merchant, :only => :new
before_filter :set_merchant_params, :only => %w(new edit)
private
# we need to pass the ref param in order to call a... |
class CreateEntries < ActiveRecord::Migration
def self.up
create_table :entries do |t|
t.string "permalink", :limit => 2083
t.string "title"
t.text "body"
t.datetime "published_at"
t.timestamps
end
end
def self.down
drop_table :entries
end
end
|
# frozen_string_literal: true
require 'rdkafka'
require 'ruby-progressbar'
require_relative 'config'
class RdkafkaSetup
def initialize
config = { "bootstrap.servers": 'localhost:9092' }
@producer = Rdkafka::Config.new(config).producer
end
def publish(topic, iterations)
progress_bar = ProgressBar.cr... |
class HomeController < ApplicationController
before_filter :authenticate_user!, :only => [:dashboard]
def index
if user_signed_in?
redirect_to dashboard_path
end
end
def dashboard
@user = current_user
@appointments = @user.appointments
end
end
|
class DropUnnecessaryFulltextTables < ActiveRecord::Migration
def self.up
triggers = [
"fulltext_product_answers_insert", "fulltext_product_answers_update",
"fulltext_product_answers_delete", "fulltext_products_insert",
"fulltext_products_update", "fulltext_products_delete",
... |
class LeaveWordsController < ApplicationController
before_action :must_be_admin!, except: [:create]
layout false
def create
lw = LeaveWord.new params.require(:leave_word).permit :content
if lw.save
flash[:notice] = t 'messages.success'
else
flash[:alert] = lw.errors.full_messages
en... |
require 'rails_helper'
RSpec.describe "shelter index page" do
it "can see each shelter name" do
shelter_1 = Shelter.create(name: "Happy Puppies", address: "55 Street St", city: "Danger Mountain", state: "UT", zip: "80304")
shelter_2 = Shelter.create(name: "Cutie Kitties", address: "666 Avenue Ln.", city: "D... |
# frozen_string_literal: true
class AttendancesController < ApplicationController
skip_before_action :verify_authenticity_token, only: %i[announce review]
USER_ACTIONS = %i[announce plan practice_details review].freeze
before_action :authenticate_user, only: USER_ACTIONS
before_action :instructor_required, ex... |
class UpdatePayloadRequestsTable < ActiveRecord::Migration
def change
remove_column :payload_requests, :url
remove_column :payload_requests, :referred_by
remove_column :payload_requests, :request_type
remove_column :payload_requests, :event_name
remove_column :payload_requests, :user_agent
rem... |
class UserSession
attr_writer :user_id, :name, :facebook_user, :email
attr_reader :user_id, :name, :facebook_user, :email
def initialize(user, facebook_user=nil)
@user_id = user.id
@name = user.full_name
@facebook_user = facebook_user
@email = user.email
end
end |
class EventCategoryMappingsController < ApplicationController
before_action :set_event_category_mapping, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
@event_category_mappings = EventCategoryMapping.all
respond_with(@event_category_mappings)
end
def show
respond_with(@event... |
require 'spec_helper'
describe UsersController do
before (:each) do
@admin = Admin.create!({
:email => 'admin@admin.com',
:password => 'admin123',
:password_confirmation => 'admin123'
})
sign_in @admin
end
def valid_attributes
{ "name" => "aakash",
"email" => "a... |
# Implementation of {Metasploit::Model::Module::Author} to allow testing of {Metasploit::Model::Module::Author}
# using an in-memory ActiveModel and use of factories.
class Dummy::Module::Author < Metasploit::Model::Base
include Metasploit::Model::Module::Author
#
# Associations
#
# @!attribute [rw] author
... |
require 'test_helper'
class MilksControllerTest < ActionController::TestCase
setup do
@milk = milks(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:milks)
end
test "should get new" do
get :new
assert_response :success
end
test "s... |
class SneakersController < ApplicationController
before_action :set_sneaker, only: [:show, :edit, :update, :destroy]
def index
@sneakers = Sneaker.all
end
def show
# set_sneaker
# render :show
end
def new
@sneaker = Sneaker.new
end
def create
@sneaker = Sneaker.create(check_param... |
module TenaciousG #:nodoc:
# This is a specialized interface for marshaling/unmarshalling reading/
# writing files in one step. It's pretty permissive with locations and
# file names, enforcing the graph naming convention location/name.graph.
class FileInterface
class << self
# Usage: read... |
require 'test_helper'
class DocentesControllerTest < ActionController::TestCase
setup do
@docente = docentes(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:docentes)
end
test "should get new" do
get :new
assert_response :success
en... |
class Note < ActiveRecord::Base
validates :title, :description, presence: true
# Remember to create a migration!
end
|
#!/usr/bin/env ruby
class Dimension
def initialize(hyperspace)
@hyperspace = hyperspace
end
def round
expand_hyperspace
next_hyperspace = Array.new(w_length) { Array.new(z_length) { Array.new(y_length) { Array.new(x_length) } } }
(0...x_length).each do |x|
(0...y_length).each do |y|
... |
# frozen_string_literal: true
# @param bot [Discordrb::Bot]
# @param prefix [Regexp]
# @yield [event, user_ids]
# @yieldparam event [Discordrb::Events::MessageEventHandler]
# @yieldparam user_ids [Array]
def command(bot, prefix)
bot.message(start_with: prefix) do |event|
user_ids = parse_user_ids(event.content)
... |
class AddHospitalRecordField < ActiveRecord::Migration[5.2]
def change
add_column :candidates, :hospital_record, :string
end
end |
class City < ApplicationRecord
has_many :pois
has_many_attached :photos
end
|
class Shift
attr_reader :key, :date
#key = rand.to_s[2..6] can't use because I can't get stub working
def initialize(key = "12345", date = DateTime.now.strftime('%d%m%y').to_s)
@key = key
@date = date
end
def paired_keys
paired = []
@key.split(//).each_cons(2) do |single|
paired << sin... |
require 'sinatra'
if !production?
require 'sinatra/reloader'
require 'dotenv/load'
require 'byebug'
end
require 'uri'
require 'json'
require 'redis-activesupport'
require 'rack/attack'
Rack::Attack.cache.store = ActiveSupport::Cache.lookup_store :redis_store
if ENV['UDL_THROTTLE_LIMIT'].present? && ENV['UDL_TH... |
module GitAnalysis
# this object analyzes a repository given the owner and the repo name
class Repository
attr_reader :id
attr_reader :name
attr_reader :owner
attr_reader :language
def initialize(id, name, owner, language)
@id = id
@name = name
@owner = owner
@language =... |
require 'rails_helper'
RSpec.describe RegisteredApplicationsController, type: :controller do
let(:user) { User.create!(name: "john snow", email: "johnsnow@gmail.com", password: "winteriscoming") }
let(:registered_application) { RegisteredApplication.create!(name: "YapBox", url: "www.yapbox.com", user: user) }
l... |
require 'rails_helper'
describe 'leagues/index' do
let(:format) { create(:format) }
let(:league1) { create(:league, format: format, status: :running) }
let(:league2) { create(:league, format: format, status: :hidden) }
let(:games) { [format.game] }
it 'displays all leagues' do
assign(:games, games)
... |
require 'test_helper'
require 'ostruct'
class << App
def sso_enabled?() true end
end
Login.send :include, Authentication::Login::SSO
User.send :include, Authentication::User::SSO
UserSessionsController.send :include, Authentication::UserSessionsController::SSO
class UserSessionsControllerTest < ActionCo... |
module Castronaut
class AuthenticationResult
attr_reader :username, :error_message
def initialize(username, error_message=nil)
@username = username
@error_message = error_message
Castronaut.logger.info("#{self.class} - #{@error_message} for #{@username}") if @error_message && ... |
name "CFT Plugin Test"
rs_ca_ver 20161221
short_description "CFT Test"
long_description ""
import "plugins/rs_aws_cft"
resource "stack", type: "rs_aws_cft.stack" do
stack_name join(["cft-", last(split(@@deployment.href, "/"))])
template_body ""
description "CFT Test"
end
operation "launch" do
description "L... |
#---
# Excerpted from "Rails 4 Test Prescriptions",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit ... |
# frozen_string_literal: true
require_relative 'display'
# creates random solution
class Solution
include Display
def initialize
@solution_arr = create_random_solution
end
def create_random_solution
solution_arr = []
(1..4).each do |_i|
solution_arr.push(rand(1..6).to_s)
end
soluti... |
class FixColumnName < ActiveRecord::Migration[5.2]
def up
rename_column :servers, :override, :auto_update
change_column :servers, :auto_update, :boolean, :default => true
rename_column :users, :override, :auto_update
change_column :users, :auto_update, :boolean, :default => true
add_column :protocols,... |
require 'test/unit'
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
require 'hudson-remote-api.rb'
class TestHudsonJob < Test::Unit::TestCase
def setup
Hudson[:url] = "http://localhost:8080"
end
def test_list
assert Hudson::Job.list
end
def test_list_active
assert Hudson::Job.list_act... |
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# no... |
class UserPresenter < ApplicationPresenter
attributes_for :index, %w(email admin sign_in_count last_sign_in_at)
attributes_for :form, %w(email created_at)
attributes_for :show, %w(email created_at)
#def body
# handle_none post.body do
# current_page?(posts_path) ? snippet(render_markdown(post.body), ... |
# Letter Counter (Part 1)
# Write a method that takes a string with one or more space separated words
# and returns a hash that shows the number of words of different sizes.
# Words consist of any string of characters that do not include a space.
# Create empty hash
# itterate through the word_length array
# - if wo... |
class CreateBracketGroups < ActiveRecord::Migration[5.0]
def up
create_table :bracket_groups do |t|
t.string :name
t.references :event, index: true, null: false
t.timestamps
end
rename_column :brackets, :event_id, :bracket_group_id
add_foreign_key :brackets, :bracket_groups
end
... |
require File.dirname(__FILE__) + '/spec_helper'
class ChildModel
def parent
"parent"
end
def parent_id
15
end
def tags
["tag1", "tag2"]
end
def tag_ids
[1, 2]
end
end
describe "A Drop" do
context "which has associations" do
context "when belongs to an item" do
before(:al... |
#!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.
require_relative '../../lib/async/rest'
require_relative '../../lib/async/rest/wrapper/url_encoded'
require 'nokogiri'
Async.logger.debug!
module XKCD
module Wrapper
# This defines how... |
Rails.application.routes.draw do
namespace :slack do
resources :events, only: [:create]
resources :commands, only: [:create]
resources :actions, only: [:create]
end
end
|
require 'json'
require 'fileutils'
require 'net/http'
require 'rubyfish'
require 'mnemonicker/major_system'
require 'mnemonicker/word_list'
module Mnemonicker
class CLI
def self.run(*args)
cmd = args.shift
cmd ||= 'help'
cmd = cmd[0].upcase + cmd[1..-1]
handler = Commands.const_get(cmd)... |
require "toastmasters/models/meeting"
module Toastmasters
module Mediators
class Meetings
def self.all(params = {})
Models::Meeting.reverse_order(:date)
end
def self.find(id)
Models::Meeting[id] or raise Toastmasters::Error::ResourceNotFound
end
def self.create(att... |
require './env.rb' if File.exists?('env.rb')
require './tuchuang'
# I'm leaning more towards not mounting the sprockets rack application and just relying on the precompiler with guard.
# If you want to mount the Sprockets Rack Application, uncomment the following lines:
map "/assets" do
run Tuchuang.sprockets
end
m... |
# -*- coding: utf-8 -*-
module Mushikago
module Mitsubachi
class HttpPushRequest < Mushikago::Http::PostRequest
def path; '/1/mitsubachi/http/push' end
request_parameter :url
request_parameter :project_name
request_parameter :script_name
request_parameter :file_name
request_par... |
class AddCounterToUserSet < ActiveRecord::Migration[6.0]
def change
add_column :user_sets, :answer_counter, :integer
end
end
|
class UsersController < ApplicationController
def index
@users = User.all
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
redirect_to(:action => 'index')
else
render('new')
end
end
def show
@user = User.find(params[:id])... |
class User < ActiveRecord::Base
self.primary_key = :usr_id
scope :primary_svie_members, -> { where.not(svie_primary_membership: nil) }
alias_attribute :id, :usr_id
alias_attribute :email, :usr_email
alias_attribute :neptun, :usr_neptun
alias_attribute :firstname, :usr_firstname
alias_attribute :lastname,... |
class ModuloRolsController < ApplicationController
before_action :set_modulo_rol, only: [:show, :edit, :update, :destroy]
respond_to :html, :xml, :json
def index
@modulo_rols = ModuloRol.all
respond_with(@modulo_rols)
end
def show
respond_with(@modulo_rol)
end
def new
@modulo_rol = Modu... |
require File.dirname(__FILE__) + '/test_helper'
class ExchangeRateTest < Test::Unit::TestCase
def test_supported_covertion
setup_net_http
er=ExchangeRate.new("my-api-key")
amt = er.convert("USD","INR","300")
assert_not_nil amt
end
def test_unsupported_covertion
er=ExchangeRate.new("my-api-key... |
require 'securerandom'
require 'app/models/user'
class AuthToken < ActiveRecord::Base
belongs_to :user
before_create :generate_token
def to_s
self.token
end
def to_json(options = {})
{ auth_token: self.to_s }.to_json
end
private
def generate_token
begin
self.token = SecureR... |
class RenameHumanIdToPlayerId < ActiveRecord::Migration
def self.up
rename_column(:matches, :human_id, :player_id)
end
def self.down
rename_column(:matches, :player_id, :human_id)
end
end
|
class Cart < ApplicationRecord
has_many :cart_items
belongs_to :user
def self.add_product(user_id, product_id, quantity)
response = {}
begin
user = User.find(user_id)
raise "Please Login. User not Found" unless user.present?
cart_item = CartItem.where(cart_id: user.cart_id, product_id: product_id).firs... |
RSpec.describe 'Navigation and Nested Elements' do
it 'begins with a valid doctype' do
expect(parsed_html.children.first).to be_html5_dtd
end
it 'has a top-level <html> tag to enclose the document' do
expect(parsed_html.child.name).to eq('html')
expect(html_file_contents).to include('</html>')
end... |
class Utils
def self.isNilOrEmpty(value)
return !value || value.empty?
end
end
class EventConfig
attr_accessor :eventId
attr_accessor :layoutName
attr_accessor :culture
attr_accessor :queueDomain
attr_accessor :extendCookieValidity
attr_accessor :cookieValidityMinute
attr_accessor :cookieDomain
attr_acces... |
class AddThumbToCourse < ActiveRecord::Migration
def change
add_column :courses, :thumb, :string
end
end
|
class ConfirmationsController < Devise::ConfirmationsController
private
def user_confirmation_path
posts_path
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.