text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe V1::UsersController, type: :routing do
describe 'routing' do
it 'routes to #show' do
expect(get: 'http://api.exemple.com/v1/user').to route_to(
controller: 'v1/users',
action: 'show',
subdomain: 'api',
form... |
class Admin::JobCategoriesController < Admin::ResourceController
before_filter :find_job_category, :except => [:index, :new, :create]
model_class JobCategory
def index
@job_category = JobCategory.all
end
def new
@job_category = JobCategory.new
end
def create
@job_category = JobCategory.ne... |
class Bank
attr_reader :amount
NOT_ENOUGH_MONEY = 'Недостаточно средств!'
def initialize(amount=0)
@amount = amount
end
def to_s
"Баланс: #{@amount}$"
end
def amount_zero?
@amount == 0
end
def debit(amount)
@amount += amount
end
def withdraw(amount)
raise NOT_ENOUGH_MONEY... |
module Omega
class Color < Gosu::Color
# Original Gosu colors (note : CYAN == AQUA)
NONE = Omega::Color.new(0x00_000000)
BLACK = Omega::Color.new(0xff_000000)
GRAY = Omega::Color.new(0xff_808080)
WHITE = Omega::Color.new(0xff_ffffff)
AQUA = Omega::Color.new(0xff_00f... |
FactoryBot.define do
factory :project do
status { 0 }
external_id { nil }
file_path { 'locale/file.json' }
algined_from { 'es' }
language_to { 'en-uk' }
file_format { 'json' }
tag { 'URGENT' }
access_token { 'access_token' }
locale_file { create :locale_file }
end
end
|
#
# Copyright 2011-2013, Dell
# Copyright 2013-2014, SUSE LINUX Products GmbH
#
# 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
#
# Unless requi... |
require 'rails_helper'
RSpec.feature "Documents", type: :feature do
background do
# Fake OAuth login
visit '/auth/github/callback'
# Create a second user
User.create uid: 123,
provider: :test,
username: 'not_you'
# Create a test document which test... |
class Player
attr_accessor :name, :id, :symbol
@@id = 0
@@symbol = ['O','X']
def initialize(name)
if(@@id >= 2)
raise "No way to have more than two players"
return
else
@name = name
@id = @@id
@symbol = @@symbol[self.id]
... |
require 'spec_helper'
require 'socket'
elasticsearch_user = 'elasticsearch'
elasticsearch_group = elasticsearch_user
elasticsearch_log_dir = '/var/log/elasticsearch'
elasticsearch_pid_dir = '/var/run/elasticsearch'
elasticsearch_conf_dir = '/etc/elasticsearch'
elasticsearch_data_dir = '/var/lib/elasticsearch'... |
class ApiController < ApplicationController
include Knock::Authenticable
# before_action :authenticate_user
before_action :set_default_format
private
def set_default_format
request.format = :json
end
end |
require 'rails_helper'
RSpec.describe District, type: :model do
context "relationships" do
it "responds to school_type" do
school_type = SchoolType.create!(type_of_school: "charter")
state = State.create!(st_name: "String", st_abbrev: "ST")
district = District.create!(school_type: school_type, ... |
class CreateApprovalDelegates < ActiveRecord::Migration
def change
create_table :approval_delegates do |t|
t.references :assigner
t.references :assignee
t.timestamps
end
end
end
|
Rails.application.routes.draw do
root 'users#index'
resources :users
delete 'delete_account' => "users#destroy", as: :destroy
resources :sessions, only: [:new, :create]
delete 'logout' => 'sessions#destroy', as: :logout
resources :comics, except: [:index]
end
=begin
Prefix Verb URI Pattern ... |
module ExecuteWithRescue
module Errors
class NoAirbrakeAdapter < RuntimeError
def self.new(msg = nil)
msg ||= <<-ERR_MSG
There is no airbrake adapter available.
Maybe you forgot to use `execute_with_rescue`?
ERR_MSG
super(msg)
end
end
end
end
|
class Tree
attr_accessor :children, :node_name
def initialize(hash={})
top_pair = hash.first
inner_hash = top_pair.slice(1)
@node_name = top_pair.first
@children = inner_hash.map {|h,v| Tree.new({h => v})}
end
def visit_all(&block)
visit(&block)
children... |
class WineVarietiesRenameNameToNameZh < ActiveRecord::Migration
def up
rename_column :wine_varieties, :name, :name_zh
end
def down
rename_column :wine_varieties, :name_zh, :name
end
end |
# frozen_string_literal: true
require_relative 'api'
class TFT < LeagueOfLegends
class League
class << self
def endpoint
'/tft/league/v1'
end
def challenger
File.join(
LeagueOfLegends.base_uri, endpoint,
'/challenger'
)
end
def grandmas... |
module Fog
module TerremarkEcloud
class Compute
class Real
require 'fog/compute/parsers/terremark_ecloud/get_network_extensions'
def get_network_extensions(network_extensions_uri)
request({
:uri => network_extensions_uri,
:idempoten... |
require 'net/https'
require 'set'
require 'uri'
require 'webkit_remote'
require_relative 'remote_controls.rb'
include RemoteControls
# Logs into the DMS site.
#
# This assumes the user is not logged into the site.
#
# @param {WebkitRemote::Client} client
# @param {String} email
# @param {String} password
def dms_log... |
class CreateUserDetailsRequests < ActiveRecord::Migration
def self.up
create_table(:user_details_requests) do |t|
t.references :user, :null => false
t.string :lastname
t.string :firstname
t.integer :status, :null => :false
end
add_index(:user_details_requests, :user... |
class DashboardController < ApplicationController
before_action :authenticate_user!
def show
@periods = Period.where(user_id: current_user.id)
end
end
|
module Api::V1
class FilescanController < ApplicationController
# POST /FileScan
def create
@scan = Scan.new
@scan.tag = params[:tag]
@scan.program = ScansHelper.normalize_program(params[:program_id])
if @scan.save
Filescan.save_scan(@scan.id,params)
... |
# All our component-level widgets will be in this namespace.
module Widgets
module Page
# The beginning of a page-header widget.
class Header < Views::Base
needs :header_text
def content
h1(class: 'page-header-widget') { text header_text }
end
end # class Widgets::Page::Header
... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/card'
require './lib/guess'
require './lib/deck'
require './lib/round'
require 'pry'
class RoundTest < Minitest::Test
def setup
@card_1 = Card.new("3","Hearts")
@card_2 = Card.new("4", "Clubs")
@deck = Deck.new([@card_1, @card_2])
@ro... |
Veto.configure do |c|
c.message.set(:exact_length, ->(exact) { "is not #{exact} characters" })
c.message.set(:format, -> { 'is not valid' })
c.message.set(:inclusion, ->(set) { "is not in set: #{set.inspect}" })
c.message.set(:integer, -> { 'is not a number' })
c.message.set(:length_range, -> { 'is too short ... |
class GroupUser < ApplicationRecord
belongs_to :user
belongs_to :social_group
before_destroy :delete_post
private
def delete_post
ActiveRecord::Base.transaction do
Micropost.post_by_group_user(social_group, user).each(&:destroy!)
end
end
end
|
class ChangeIdCategoryToNewspapers < ActiveRecord::Migration
def change
rename_column :newspapers, :id_category, :id_categories
end
end
|
# frozen_string_literal: true
# frozen_string_literal: true.
require 'net/http'
require 'test_helper'
class RandomQuoteServiceTest < MiniTest::Test
def test_fetches_quote_successfully
api_response = {
_id: '5a91e37bc4240c0004265955',
en: "Young man, in mathematics you don't understand things. You ju... |
# == Schema Information
#
# Table name: plans
#
# id :integer not null, primary key
# plan_type_id :integer
# name :text not null
# price :integer not null
# internet_price :integer
# created_at :datetime not null
# upda... |
require_relative("averages.rb")
class Input
attr_accessor :student_name, :score1, :score2, :score3, :students_and_scores
def user_input
@students_and_scores = {}
counter = 0
while counter < 100
puts "Enter a student name: "
@student_name = gets.chomp
puts "Enter the first test score: ... |
class AddRespondentToIbtrs < ActiveRecord::Migration
def self.up
add_column :ibtrs, :respondent_id, :string
add_column :ibtr_versions, :respondent_id, :string
end
def self.down
remove_column :ibtrs, :respondent_id
remove_column :ibtr_versions, :respondent_id, :string
end
end
|
# frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/base'
require_relative 'core'
require_relative 'relay'
module Graphql
module Generators
class RelayGenerator < Rails::Generators::Base
include Core
include Relay
desc "Add base types and fields for Relay-style n... |
# frozen_string_literal: true
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:mac)
def build_js
sh 'npm run build'
end
APP_NAME = 'Refined GitHub for Safari'
BUILD_DIR = 'build'
def archive_path
"#{BUILD_DIR}/#{APP_NAME}.xcarchive"
end
def app_path
... |
class ContactController < ApplicationController
def index
@contact = Contact.new
end
def send_message
@contact = Contact.new(contact_params)
if @contact.save
flash[:notice] = "Message sent!"
redirect_to :back
else
render 'index'
end
end
private
def contact_params
params... |
# Created by Thomas Boerger on 2011-07-01.
# Copyright (c) 2011. All rights reserved.
require 'rubygems'
require 'rubygems/package_task'
require 'rubygems/specification'
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'rcov/rcovtask'
require 'date'
GEM_TITLE = 'has_preference'
GEM_VERSION = '0.0.2'... |
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = User.from_param!(params[:id])
end
def new
@user = User.new
end
def edit
@user = User.from_param!(params[:id])
can_edit_account!(@user)
end
def create
@user = User.new(para... |
module Multiple
class ThreadsAndQueuesExperiment < BaseExperiment
def run
queues = Array.new(files.length) { Queue.new }
threads = files.collect.with_index do |file, index|
queue = queues[index]
Thread.new do
File.foreach(file) do |line|
queue << line.to_i
... |
require 'spec_helper'
describe AttrSecure::Adapters::ActiveRecord do
let(:described) { Class.new(ActiveRecord::Base) }
subject { described.new }
before do
described.table_name = 'fake_database'
end
describe "valid?" do
it "should be valid" do
expect(described_class.valid?(described)).... |
class AddEmployerNames < ActiveRecord::Migration
def change
add_column :jobs, :employer_first_name, :string
add_column :jobs, :employer_last_name, :string
end
end
|
class FlightGear < Cask
url 'http://ftp.snt.utwente.nl/pub/software/flightgear/ftp/MacOSX/FlightGear-2.12.1.dmg'
homepage 'http://www.flightgear.org/'
version '2.12.1'
sha1 'ac83dd56cd228b77243a2536b63a3396c26a63c6'
link 'FlightGear.app'
end
|
module Braspag
class Transaction
attr_accessor :soap_adapter, :response_handler, :transaction_param_builder
def initialize(soap_adapter = SavonAdapter, response_handler = ResponseHandler.new, transaction_param_builder = TransactionParamBuilder)
@soap_adapter = soap_adapter
@response_handler = res... |
module Admin
# Allow a user to edit and update case study gallery images from within the
# admin interface.
#
# @author Matthew Rayner
# @since 0.1
class CaseStudyGalleryImagesController < Admin::BaseController
def edit
@case_study_gallery_image = CaseStudyGalleryImage.find_by(id: params[:id])
... |
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Add ... |
And(/^I run a query to filter the field "([^"]*)" with value "([^"]*)" in "([a-z_]*)"$/) do |key, val, doc|
value = CommonActions.built_data(val)
@query_result = MongoDBConnection.find_document_by_field(key, value, doc)
end
And(/^I store the "([^"]*)" of query result as "([^"]*)"$/) do |field, key|
Helper.add_da... |
#!/usr/bin/env ruby
###############################################################################
# Porting this from Python to Ruby.
#
# Clay Wells
#
# This script requires ruby-nmap..
#
# https://github.com/sophsec/ruby-nmap
#
#
# Find all HTTPS servers on a subnet.
#
# Enhancements
# ============
# - get subn... |
class AddUsuarioToAgentes < ActiveRecord::Migration
def change
add_reference :agentes, :usuario, index: true
add_foreign_key :agentes, :usuarios
#add_foreign_key(from_table, to_table, options = {})
end
end
|
class AddPatternToGranularities < ActiveRecord::Migration
def change
add_column :granularities, :pattern, :string, :default=>'yyyy - MM - dd'
end
end
|
require 'battlenet'
require 'json'
require './lib/battlebone/realms'
require './lib/battlebone/achievements'
require './lib/battlebone/items'
module BattleBone
class API
include BattleBone::Achievements
include BattleBone::Realms
include BattleBone::Items
attr_reader :client
def initialize(reg... |
#
# errorlog.rb
# TransporterPackager
#
# Created by Mat Clutter on 11/3/11.
# Copyright 2011 darumatou. All rights reserved.
#
class Errorlog
attr_accessor :errors, :dontbelong
def initialize #(klass,t)
@errors = Array.new
@dontbelong = Array.new
#@kl = klass #controller object passed; usually '... |
require 'address_constraint'
class Address < ActiveRecord::Base
belongs_to :property
belongs_to :land_property
validates :street_name, presence: true, length: { maximum: AddressConstraint.street_name_length_max }
validates :landmark, presence: true, length: { maximum: AddressConstraint.landmark_length_max }
end
|
require 'test_helper'
require 'giita/helpers/user_helper'
class Giita::Helpers::UserHelperTest < Test::Unit::TestCase
include ::Giita::Helpers::UserHelper
sub_test_case '#link_to_user' do
test 'with string user name' do
assert do
link_to_user('yuya-takeyama') == %Q{<a href="/users/yuya-takeyama"... |
class Post < ActiveRecord::Base
belongs_to :user
has_many :steps
has_permalink :title
def to_param
permalink
end
=begin
The content of params
{"commit"=>"Done",
"step"=>{"title_1"=>"Test 123 ", "title_2"=>"Test 123 ", "title"=>"", "title_3"=>"Test 321"},
"post"=>{"title"=>"How to kill a mock... |
class Patient < ApplicationRecord
validates :first_name, presence: true,
length: { minimum: 5 }
def self.search(search)
if search.present?
Patient.where('first_name LIKE ?', "%#{search}%")
else
Patient.all
end
end
end
|
class FixCharacterName < ActiveRecord::Migration[5.0]
def change
rename_column :characters, :name, :character_name
end
end
|
class Recipe < ActiveRecord::Base
validates :title, :presence => true
has_and_belongs_to_many :tags
has_many :ratings
end
|
Ignitespeak::Application.routes.draw do
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
resources :proposals do
collection do
get "closed"
get "selected"
end
end
root to: "proposals#new"
end
|
# -*- coding: utf-8 -*-
require 'net/http'
require_relative "base_notifier"
class JenkinsNotifier < BaseNotifier
def rss_body
Net::HTTP.start(@url){|http|
req=Net::HTTP::Get.new(jenkins_config.rss_category)
req.basic_auth(jenkins_config.user,jenkins_config.pass) if jenkins_config.basic_auth
ht... |
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'j8/functional'
require 'pry'
require 'rb-inotify'
def reloadable_dirs
Dir[File.join(__dir__, '..', 'lib', '**', '*.rb')]
.map { |path| File.dirname(path) }
.push(File.join(__dir__, '..', 'lib'))
.to_set
.to_a
end
de... |
class ArticlesController < ApplicationController
before_action :find_headline
before_action :find_article, only: [:show, :upvote]
respond_to :js, :html
def show
# headline association
@article = @headline.articles.find(params[:id])
@next_article = @article.next
respond_to do |format|
format.js { rend... |
#
# Cookbook Name:: dadou-chef-recipes
# Attributes:: postgresql
#
# Copyright 2012 Damien DUPORTAL <damien.duportal@gmail.com>
# https://github.com/dduportal/dadou-chef-recipes
#
# PostgreSQL Attributes
default['dadou']['postgresql'] = {
'version' => {
'major' => '9',
'minor' => '2'
},
'dir' => "/var/lib/pgsq... |
require 'scout_apm/environment'
# Removes actual values from SQL. Used to both obfuscate the SQL and group
# similar queries in the UI.
module ScoutApm
module Utils
class SqlSanitizer
if ScoutApm::Environment.instance.ruby_187?
require 'scout_apm/utils/sql_sanitizer_regex_1_8_7'
else
... |
require 'json'
module BswTech
module JenkinsGem
class GemBuilder
PREFIX = 'jenkins-plugin-proxy'
DEPENDENCY_REMAPS = {
# For some reason, Jenkins seems to reference invalid dependency versions sometimes
'matrix-project' => {
'1.7.1' => '1.12'
}
}
JENKINS_... |
class Book
# getter for title; book.title
attr_reader :title
# constructor
def initialize
end
# setter
def title=(string)
words = string.split(" ").collect do |word|
word.capitalize!
word = is_conjunction(word)
end
words = capitalize_first_word(words)
@title = words.join(" ... |
dmg_package 'Command Line Developer Tools' do
type 'pkg'
dmg_name 'command-line-tools'
volumes_dir 'Command Line Developer Tools'
app 'Command Line Tools (OS X 10.9)'
accept_eula true
action :install
only_if { FueledOsxBuildTools::OsCheck.new.os == '10.9' }
end
|
class AddPlusOneInformationToUsers < ActiveRecord::Migration
def change
add_column :users, :plus_one_first_name, :string
add_column :users, :plust_one_last_name, :string
end
end
|
#!/usr/bin/ruby
class DepthCharge
def run_game
output_title
loop do
puts "----------"
print_instructions
setup_game
puts
game_loop
break unless get_input_another_game
end
puts "OK. HOPE YOU ENJOYED YOURSELF."
end
def output_title
puts "--- DEPTH CHARGE ... |
class RenameEpubUrlToEpub < ActiveRecord::Migration
def up
rename_column :articles, :epub_url, :epub
end
def down
rename_column :articles, :epub, :epub_url
end
end
|
module ProjectsHelper
class << self
include Rails.application.routes.url_helpers
def breadcrumbs_for(opts={})
breadcrumbs = [{text: "Projects", path: projects_path}]
project = opts[:project]
event = opts[:event]
track = opts[:track]
track_version = opts[:track_version]
pa... |
module Quicken
module Plugins
class Echo < Quicken::Plugin
def initialize text
@text = text
end
def call
say @text
end
end
end
end |
class ThermostatSerializer
include FastJsonapi::ObjectSerializer
attributes :household_token, :address
end
|
require "rails_helper"
RSpec.describe UrlValidator do
subject(:validator) { UrlValidator.new(attributes: :url)}
let(:error_array) { [] }
let(:errors) { double "Errors", "[]" => error_array }
let(:model) { double "Model", errors: errors}
["http://www.test.com",
"http://test.com",
"http://test.net",
... |
module OpenProject::Revisions
class ProxiedRepositoryHook < Redmine::Hook::Listener
@@delegates = []
def self.delegate(klass)
@@delegates.push(klass.new)
end
def method_missing(method, *args, &block)
delegates_for(method).each do |delegate|
if delegate.accepts?(method, *args)
... |
require 'spec_helper'
RSpec.describe Commands::Quit do
let(:image) { instance_double("Image") }
let(:input) { double(:command) }
let(:message) { "goodbye!\n" }
subject(:command) { described_class.new(input, image) }
describe "#required_args" do
it "has 0" do
expect(described_class::REQUIRED_ARGS)... |
class Grid
attr_accessor :rings
def initialize(initialState)
@rings = Array.new
if initialState.length
@rings[0] = Array.new
@rings[0].push Cell.new(initialState.shift)
currentRing = 0
currentRingSize = currentRing * 6
currentRingPos = 0
while initialState.length > 0
if currentR... |
class CreateSegments < ActiveRecord::Migration
def change
create_table :segments do |t|
t.string :key
t.integer :group
t.references :carrier
t.string :flight_number
t.references :origin
t.references :destination
t.string :departure_time
t.string :arrival_time
... |
class Work < ApplicationRecord
has_many :votes, dependent: :destroy
validates :category, inclusion: {
in: %w(movie book album),
message: "%{value} is not a valid category"
}
validates :title, presence: true
validates :publication_year, numericality: { only_integer: true }, allow_nil: true
def s... |
require_relative '../../spec/rspec_helper'
require_relative '../../spec/pages/login_page'
require_relative '../../spec/pages/account_page'
describe 'Story#Support_Successful_Account_Logins_TNGVAA-1_spec.rb' do
include DriverUtility
before(:all) do
initializeConfigurations(BASE_URL)
@logInPage = LogInPage.... |
class ReviewsController < ApplicationController
before_action :set_morty, only: [:index, :new]
before_action :set_review, only: [ :edit, :update ]
def new
@review = Review.new
end
def create
@review = Review.new(review_params)
@review.user = current_user
@review.morty = Morty.find(params[:morty_... |
# frozen_string_literal: true
module AvailabilityService
class List
def initialize(fp_id:, from:, to:)
@fp_id = fp_id
@from = from
@to = to
end
def execute
availabilities = Availability.where(fp_id: @fp_id, from: (@from..@to))
availabilities
end
end
end
|
class EventsController < ApplicationController
before_action :authenticate_user!, only: [:new, :create]
def index
end
def show
@event = Event.find(params[:id])
@attendance = Attendance.where(event_id: @event.id)
end
def new
@event = Event.new
end
def create_params
params.permit(:titl... |
module Cdn
def self.table_name_prefix
'cdn_'
end
end
|
class CreateCategorySubcategoryLinkPositions < ActiveRecord::Migration
def change
create_table :category_subcategory_link_positions do |t|
t.references :category, index: true
t.references :subcategory, index: true
t.references :link, index: true
t.integer :position
end
end
end
|
require 'test/unit'
$: << 'Classes/Helpers'
require 'Classes/Helpers/Constants'
require 'Classes/Operations/PathOperation'
require 'Classes/Controllers/AppDelegate'
require 'Classes/Controllers/FuzzyTableViewController'
require 'Classes/Models/FuzzyRecord'
require 'Classes/Helpers/Array+GCD'
class FuzzyRecordTest < ... |
require "spec_helper"
describe TrainingLevelsController do
describe "routing" do
it "routes to #index" do
get("/training_levels").should route_to("training_levels#index")
end
it "routes to #new" do
get("/training_levels/new").should route_to("training_levels#new")
end
it "routes to... |
def play(board)
turn(board) while over?(board) == false
if won?(board) != false
puts "Congratulations #{winner(board)}!"
elsif draw?(board) == true
puts "Cats Game!"
end
end
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{bo... |
Spree::Order.class_eval do
after_save :trigger_slack_notification
def trigger_slack_notification
#if self.state_changed? and self.state == "complete"
if self.state == "complete"
SlackNotificationWorker.perform_async(self.number)
end
end
def user_display_format
if name.present? && email.p... |
class Background < ApplicationRecord
has_many :character_backgrounds, inverse_of: :background
has_many :characters, through: :character_backgrounds, inverse_of: :backgrounds
validates :name, presence: true
def display_name
"#{self.name}"
end
end
|
class Product < ApplicationRecord
belongs_to :category
has_many :pictures, dependent: :destroy
has_many :reviews, dependent: :destroy
has_many :order_details, dependent: :destroy
validates :name, presence: true, length: {maximum: Settings.product.name_max_length}
validates :size, presence: true
validates... |
require 'spec_helper'
describe Fars::BaseModelSerializer do
before :each do
@object = Master.create(id: 1, name: 'Object1', data: '123')
1.upto(2) { |i| Slave.create(id: i, master_id: @object.id, name: "Slave #{i}") }
end
context 'without API version' do
context '#to_json' do
it 'returns all f... |
class FriendshipsController < ApplicationController
def create
if User.find_by(guid: add_friend_params[:id])
friended_user = User.find_by(guid: add_friend_params[:id])
current_user.friendships.create(friended_user: friended_user)
else
flash[notice] = "That is an invalid user to friend!"
... |
class CreateNotifications < ActiveRecord::Migration
def change
create_table :notifications do |t|
t.string :action
t.integer :sender_id
t.integer :receiver_id
t.boolean :unread, default: true
t.belongs_to :notifiable, polymorphic: true
t.timestamps
end
add_index :notif... |
class Api::V1::LikesController < ApplicationController
def index
@likes = Like.all
render json: @likes
end
def create
@like = Like.create(like_params)
if @like.save
render json: @like
else
render json: {error: 'Unable to like this.'}, status... |
# Problem 269: Polynomials with at least one integer root
# http://projecteuler.net/problem=269
# A root or zero of a polynomial P(x) is a solution to the equation P(x) = 0.
# Define Pn as the polynomial whose coefficients are the digits of n.
# For example, P5703(x) = 5x^3 + 7x^2 + 3.
#
# We can see that:Pn(0) is t... |
class AddFKeytoAddress < ActiveRecord::Migration
def change
remove_column :addresses, :users_id
remove_column :addresses, :facilities_id
end
end
|
class ChangeExercise < ActiveRecord::Migration
def change_table
add_column(:exercise, :training_id, :integer)
end
end
|
class Newsletter < NewsPost
RailsAdmin.config do |config|
config.model Newsletter do
navigation_label 'CMS'
list do
field :title
field :file
field :published_at do
strftime_format "%B %d, %Y %I:%M %p"
end
end
edit do
fi... |
# -*- encoding : utf-8 -*-
class Evaluation < ActiveRecord::Base
belongs_to :user
belongs_to :course
after_save :update_course_rating_and_count, if: :rating_changed?
after_destroy :update_course_rating_and_count
enum course_status: [:aborted, :enrolled, :finished]
def update_course_rating_and_count
Co... |
Pod::Spec.new do |s|
s.name = "MaterialMotionRuntime"
s.summary = "Material Motion Runtime for Apple Devices"
s.version = "6.0.1"
s.authors = "The Material Motion Authors"
s.license = "Apache 2.0"
s.homepage = "https://github.com/material-motion/runtime-objc"
s.source ... |
module AppDelegate
module ConnectionCheck
attr_accessor :internetReachable, :hostReachable
attr_accessor :internetActive, :hostActive, :connectionActive
def checkNetworkStatus notice
@internetActive = isReachable?(@internetReachable.currentReachabilityStatus)
@hostActive = isReachable... |
Given(/^a user creates a snippet "([^"]*)"$/) do |snippet_text|
@snippet_text = snippet_text
new_snippet_page = @login_page.click_new_snippet_link
@snippets_page = new_snippet_page.add_snippet(@snippet_text)
end
And(/^the snippet will be|is displayed$/) do
@snippet_location = @snippets_page.snippet_exists?(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.