text stringlengths 10 2.61M |
|---|
class TeamController < ApplicationController
get '/teams' do
redirect_if_not_logged_in
@teams = Team.all
erb :'teams/teams'
end
get '/teams/new' do
redirect_if_not_logged_in
erb :'teams/create_team'
end
post '/teams' do
redirect_if_not_logged_in
if params[:team_name] == "" || pa... |
class SessionsController < ApplicationController
# メニューのサインインから呼ばれる(routes.rb)
def new
end
# /sessionsへのPOSTリクエストはcreateアクションに送られます
# createアクションでフォーム送信を受け取り、Sessions.newを使用して新しいセッションオブジェクトを作成し、セッションを保存
def create
user = User.find_by(email: params[:email].downcase)
# パスワードと一致することを確認(has_secure_passw... |
class Phone < ApplicationRecord
before_create :generate_phone_number
# belongs_to :user
def generate_phone_number(phone_number)
self.phone_number = Random.new.rand(1111111111..9999999999)
generate_phone_number if Phone.exists?(phone_number: self.phone_number)
end
end
|
class FixDateColumns < ActiveRecord::Migration
def change
rename_column :menus, :startDate, :start_date
rename_column :menus, :endDate, :end_date
end
end
|
# frozen_string_literal: true
# Copyright (c) 2018-2020 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to us... |
require "json"
require_relative "inventory_item.rb"
class CartItem
attr_reader :inventoryItem
attr_accessor :isBundled
def initialize(inventoryItem)
@inventoryItem = inventoryItem
@isBundled = false
end
end |
class Application
def call(env)
resp = Rack::Response.new
req = Rack::Request.new(env)
if req.path == "/toys" && req.get?
getToys
elsif req.path == "/toys" && req.post?
post_toy(req.body.read)
elsif req.path.match(/toys/) && req.patch?
path_toy(req.path)
elsif req.path.match... |
class AddAvatarColumnToPrizes < ActiveRecord::Migration[5.0]
def up
add_attachment :prizes, :avatar
end
def down
remove_attachment :prizes, :avatar
end
end
|
#
# Класс Station (Станция).
#
class Station
attr_reader :trains
@@stations = []
def initialize(name)
@name = name
@trains = []
@@stations << self
end
def self.all
@@stations
end
def add_train(train)
@trains << train
end
def trains_by_type(type)
@trains.select {|train| ty... |
FactoryGirl.define do
factory :user do
flock_name { Faker::Lorem.word.capitalize + [' Farm', ' Ranch'].sample }
name { Faker::Name.name }
password 'supersecret'
password_confirmation 'supersecret'
address1 { Faker::Address.street_address }
city { Faker::Address.city }
state { Faker::Addres... |
class AddAndRenameColumnsAndTablesSeedBagsCropsFarmers < ActiveRecord::Migration[5.0]
def change
add_column :crops, :ripe, :integer
rename_column :seed_bags, :seed_name, :crop_name
rename_column :seed_bags, :price, :buy_price
add_column :seed_bags, :sell_price, :integer
add_column :farmers, :day... |
# frozen-string-literal: true
require File.join(File.dirname(__FILE__), 'helper')
class MP4FileWriteTest < Test::Unit::TestCase
SAMPLE_FILE = 'test/data/mp4.m4a'
OUTPUT_FILE = 'test/data/output.m4a'
PICTURE_FILE = 'test/data/globe_east_540.jpg'
def reloaded(&block)
TagLib::MP4::File.open(OUTPUT_FILE, fal... |
require 'faraday'
require 'faraday_middleware'
class Kitsu::Client
URL = 'https://kitsu.io/api/edge'.freeze
def self.connect
Faraday.new(url: URL) do |faraday|
faraday.response :json, content_type: /\bjson$/
faraday.adapter Faraday.default_adapter
faraday.headers['Accept'] = 'application/vnd... |
require "rails_helper"
RSpec.feature "User can edit a specific playlist" do
scenario "user is able to change a given playlist" do
playlist = create(:playlist_with_songs)
first, second, third = playlist.songs
new_song = create(:song, title: "My new Test song")
visit playlist_path(playlist)
click... |
require_relative '../../lib/tic_tac_toe_rz/tictactoeruby.core/players/player_type.rb'
require_relative '../../lib/tic_tac_toe_rz/tictactoeruby.core/players/player_movement_manager.rb'
require_relative '../../lib/tic_tac_toe_rz/tictactoeruby.core/gameplay/match_type.rb'
require_relative '../../lib/tic_tac_toe_rz/tictact... |
Todo::Application.routes.draw do
resources :comments
resources :todo_items
root to: 'application#index'
end
|
class Comment < ActiveRecord::Base
belongs_to :post, :foreign_key => "post_id"
belongs_to :user, :foreign_key => "user_id"
validates :content, :presence => true
end
|
class CreateCodePastes < ActiveRecord::Migration[5.0]
def change
create_table :code_pastes do |t|
t.string :token
t.references :user, foreign_key: true
t.string :title
t.string :description
t.text :content
t.boolean :private
t.timestamps
end
add_index :code_paste... |
class JWZThreading
module VERSION
unless defined? MAJOR
MAJOR = 0
MINOR = 3
TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
SUMMARY = "jwz_threading version #{STRING}"
end
end
end |
# frozen_string_literal: true
require 'jiji/test/test_configuration'
describe Jiji::Db::Migrator do
include_context 'use container'
include_context 'use data_builder'
let(:migrator) { container.lookup(:migrator) }
it 'データ移行ができる' do
migrator1 = double('migrator1')
allow(migrator1).to receive(:id).at_... |
class RemoveTrancsationFromSearch < ActiveRecord::Migration[5.0]
def change
remove_column :searches, :transaction, :string
end
end
|
module Neovim
# Object representing the `nvim` executable.
class Executable
VERSION_PATTERN = /\ANVIM v?(.+)$/
class Error < RuntimeError; end
# Load the current executable from the +NVIM_EXECUTABLE+ environment
# variable.
#
# @param env [Hash]
# @return [Executable]
def self.from... |
class Landing < ActiveRecord::Base
belongs_to :business
has_many :user_landings, dependent: :destroy
has_many :users, through: :user_landings
has_many :comments, as: :commentable, dependent: :destroy
validates_presence_of :name, :price, :path
scope :recent, -> { where("updated_at > ?",1.month.ago) }
sc... |
class CarsController < ApplicationController
before_action :set_car, only: [:show, :edit, :update, :destroy]
def index
@cars = Car.all
end
def show; end
def new
@car = Car.new
end
def create
@car = Car.new(car_params)
if @car.save
redirect_to ... |
class Standing < ActiveRecord::Base
belongs_to :player
belongs_to :tournament
validates :points, :presence => true, :numericality => { :only_integer => true }
end
|
class Responder < ActiveRecord::Base
self.inheritance_column = nil
EXCLUDED_JSON_ATTRIBUTES = [:id, :created_at, :updated_at]
RESPONDER_TYPES = %w(Fire Medical Police)
validates :type, presence: true
validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :capacity, presence: tru... |
class AddLocalityIdToSurveys < ActiveRecord::Migration
def change
add_reference :surveys, :locality, index: true
add_foreign_key :surveys, :localities
end
end
|
require 'test_helper'
class UsersLoginTest < ActionDispatch::IntegrationTest
def setup
@user = users(:tomas)
@old_domain = AppConfig.get "ad_domain"
@old_server = AppConfig.get "ad_controller"
@old_base = AppConfig.get "ad_ldap_base"
#put test data
AppConfig.set "ad_domain", "test_domain"
... |
module Importer
# Import a csv file with one work per row. The first row of the csv should be a
# header row. The model for each row can either be specified in a column called
# 'type' or globally by passing the model attribute
class CSVImporter
# @param [String] CSV contents
# @param [Aws::S3::Bucket] ... |
require 'rails_helper'
describe FetchAnime do
context 'without filters' do
let!(:anime) { create(:anime) }
let(:command) { described_class.run }
it 'should be valid' do
expect(command).to be_valid
end
it 'contain result' do
expect(command.result).to match_array(anime)
end
end
... |
class ProposalsController < InheritedResources::Base
before_action :set_current_user, :set_locale
before_action :set_proposal, only: [:edit, :update, :destroy]
def index
@proposals = Proposal.all
end
def edit
end
def update
if @proposal.update(proposal_params)
redirect_to "/trips/proposal/#{... |
class InvoiceSchedule < ActiveRecord::Base
belongs_to :estimate
has_many :invoice_milestones, :dependent => :destroy
accepts_nested_attributes_for :invoice_milestones, :allow_destroy => true
validate :total_must_equal_one_hundred_percent
def total_must_equal_one_hundred_percent
if total_percent != 100
erro... |
# app "controller" that has an "index" action.
#
# The "controller" coordinates the interaction between the "user", the "views", and the "model".
# It is responsible for routing external requests to internal "actions", it manages caching,
# and "helper" modules as well as sessions.
#
# "Controller" class inherits from ... |
module Fog
class Compute
def self.new(attributes)
attributes = attributes.dup # prevent delete from having side effects
case provider = attributes.delete(:provider)
when 'AWS'
require 'fog/aws'
Fog::AWS::Compute.new(attributes)
when 'Bluebox'
require 'fog/bluebox'
... |
class RawProduct < ActiveRecord::Base
def self.from_hash(hash)
if hash[:barcode]
self.find_or_create_by(barcode: hash[:barcode])
else
self.find_or_create_by(source: hash[:source], name: hash[:name])
end.tap do |raw_product|
raw_product.update!(hash)
end
end
end
|
require 'transaction'
describe Transaction do
let(:transaction) { Transaction.new(0, 0, 10) }
it "has an initial amount of zero" do
expect(subject.amount).to eq(0)
end
it "has a date" do
allow(subject).to receive(:date) { "30/07/2017" }
expect(subject.date).to eq "30/07/2017"
end
it 'keeps t... |
class Person
attr_reader :name,:age, :year_born
def initialize(name, age)
@name=name
@age=age
@year_born = (Time.now - age * 31556926).year
end
def days_alive
@age * 365
end
end |
class AddIndexToDeviceTokenInCars < ActiveRecord::Migration
def change
add_index :cars, :device_token
end
end
|
# p037retangulo.rb
# O construtor do Retangulo aceita argumento em ambas
# das seguintes formas:
# Retangulo.new([x_superior, y_esquerda], tamanho, largura)
# Retangulo.new([x_superior, y_esquerda], [x_inferior, y_direita])
# Sobrecarga de método no ruby
class Retangulo
def initialize(*args)
if args.size < 2 ... |
module PrintTo
def print_to(stream, *lines)
lines.each { |line| stream.puts '# ' + line }
stream.flush
end
end
|
class CreateMessages < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.integer :sent_user_id, :null => false
t.integer :received_user_id, :null => false
t.text :message, :null => false
t.integer :sequence
t.timestamps
end
end
def self.down
drop_table... |
#!/usr/bin/env ruby
=begin
Name: CloudControllers::Ec2::Snapshots
Description: Assist the firstrun-create-ebs-from-snapshot-and-mount.sh
Author: Michael Mell
Date: October 17, 2010
License: MIT
Modified by : Leo Shin
Date: June 4, 2012
=end
require 'time'
ENV['PATH'] = "#{ENV['PATH']}"
module CloudCo... |
# frozen_string_literal: true
module Vedeu
module Buffers
# Provides a non-existent Vedeu::Buffers::Buffer that acts like
# the real thing, but does nothing.
#
# @api private
#
class Null < Vedeu::Null::Generic
end # Null
end # Buffers
end # Vedeu
|
require "singleton"
require_relative "slideable"
require_relative "stepable"
class Piece
attr_reader :symbol, :color, :board
attr_accessor :pos
def initialize(color = :red, pos, board)
@moves = []
@symbol = :P
@color = color
@pos = pos
@board = board
end
def to_s
symbol.to_s
end
... |
require 'matrix'
class NeuralNet
attr_accessor :weights, :previous_values, :shape
def initialize(shape, weights)
@weights = weights
@shape = shape
end
def calculate(inputs)
@previous_values = inputs
shape.each_with_index do |nodes_in_level, level|
calculate_level(nodes_in_level, level)
... |
require_relative 'board'
require_relative 'human_player'
require_relative 'cursor'
require './computer_player'
class Game
attr_accessor :current_player
attr_reader :player1, :player2
def initialize(player1, player2, computer)
@board = Board.new
display = Display.new(@board)
@player1 = HumanPlayer.... |
class Visit < ActiveRecord::Base
belongs_to :visit
belongs_to :user
def to_s
user.name
end
end
|
json.array!(@provinsis) do |provinsi|
json.extract! provinsi, :id, :id, :name, :is_active
json.url provinsi_url(provinsi, format: :json)
end
|
require 'rails_helper'
RSpec.describe SitesController, type: :controller do
let(:user) { create(:user) }
let(:hub) { create(:hub) }
let(:participant) { create(:participant, hub_id: hub.id) }
let(:participant2) { create(:participant, hub_id: hub.id) }
let(:site) { create(:site, participant_id: participant.id)... |
#!/usr/bin/env ruby
###############################################################################
#
# Cider-CI Taks management for Rspec tests.
#
# Authors: Thomas Schank <DrTom@schank.ch>
#
###############################################################################
#############################################... |
class AddIdAlunoBoleto < ActiveRecord::Migration
def self.up
add_column :boletos, :aluno_id, :integer, :null => false
end
def self.down
remove_column :boletos, :aluno_id
end
end
|
Given /^I am on posts page$/ do
visit "/posts"
end
When /^I log in as "([^\"]*)" with "([^\"]*)"$/ do |username, password|
if page.driver.respond_to?(:basic_auth)
page.driver.basic_auth(username, password)
elsif page.driver.respond_to?(:basic_authorize)
page.driver.basic_authorize(username, password)
elsif pa... |
FactoryGirl.define do
sequence(:email) do |n|
"person#{n}@example.com"
end
factory :user, class: Brewery::AuthCore::User do
email
password { SecureRandom.hex(6) }
password_confirmation { password }
before(:create) do |user|
user.class.maintain_sessions... |
class TagItskill < ApplicationRecord
# n:m 相关工作流
has_many :projectworkflowitskill_relationships
has_many :project_workflows, through: :projectworkflowitskill_relationships, source: :project_workflow
# n:m 相关管理工作流
has_many :managementworkflowitskill_relationships
has_many :management_workflows, through: :m... |
# == Schema Information
#
# Table name: visita_tecnicas
#
# id :integer not null, primary key
# observacion :text
# porc_cumplimiento :float
# tipo_proyeccion :integer
# created_at :datetime
# updated_at :datetime
#
# Clase que representa una visita tecnica
class Vis... |
require 'spec_helper'
describe EntriesController do
it 'can GET index' do
get :index
expect(response.status).to be 200
end
it 'can show an entry' do
entry = Entry.create :title => 'title', :content => 'content'
get :show, :id => entry.id
expect(response.status).to be 200
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
before_action :restrict_access
def restrict_access
authenticate_or_request_with_http_token do |api_key,option|
Api.find_by(api_key: api_key)
end
end
end
|
require 'rails_helper'
RSpec.describe Route, type: :model do
# pending 'add some examples to (or delete) #{__FILE__}'
it 'user should can be found by bus_id' do
firstroute = Route.create!(
start_end: '怀柔城区-雁栖湖校区',
drive_data: '2016-01-19',
drive_time: '10:30',
ticket_num: '50',... |
class PodcastFinder::Episode
attr_accessor :date, :title, :description, :download_link, :length, :podcast
@@all = []
def initialize(episode_hash)
episode_hash.each {|key, value| self.send("#{key}=", value)}
self.format_date
self.save
end
def format_date
date_string = @date.to_s
@date =... |
require_relative "../config/environment.rb"
require 'active_support/inflector'
require 'pry'
class InteractiveRecord
def self.table_name
self.to_s.downcase.pluralize
end
def self.column_names
#DB[:conn].results_as_hash=true
sql="PRAGMA table_info('#{table_name}')"
table_info=DB[:co... |
require("minitest/autorun")
require("minitest/rg")
require_relative("../Fish")
require_relative("../Bear")
require_relative("../River")
class TesFish < MiniTest::Test
def setup
@fish = Fish.new("Salmon")
end
def test_get_fish_name()
assert_equal("Salmon", @fish.get_fish_name())
end
end
|
class Book < ActiveRecord::Base
belongs_to :user
validates :title, presence: true
validates :author, presence: true
end
|
control "M-5.14" do
title "5.14 Ensure 'on-failure' container restart policy is set to '5'
(Scored)"
desc "
Using the --restart flag in docker run command you can specify a restart
policy for how a
container should or should not be restarted on exit. You should choose the
on-failure
restart policy and ... |
class FoodProductsController < GroupBase
before_action :set_food_product, only: [:show, :edit, :update, :destroy]
before_action :set_groups # 各アクションの実行前に実行
load_and_authorize_resource # for cancancan
# GET /food_products
# GET /food_products.json
def index
@food_products = FoodProduct.where(group_id: @... |
require "#{File.expand_path(File.dirname(__FILE__))}/../spec_helper"
describe 'Schema Validation' do
before do
@full = CWC::XMLGeneratorV2.new.full_doc
@full_xml = @full.to_xml
@mandatory = CWC::XMLGeneratorV2.new.mandatory_doc
@mandatory_xml = @mandatory.to_xml
end
it "must fail with bad clo... |
class Inertia < Formula
desc "Simple, self-hosted continuous deployment"
homepage "https://github.com/ubclaunchpad/inertia"
bottle :unneeded
# Stable
version "{{ .Version }}"
sha256 "{{ index .Sha256 "darwin.amd64" }}"
url "https://github.com/ubclaunchpad/inertia/releases/download/#{version}/inertia.#{ve... |
class AddRarityDraftAndResultsToBeerMeSearches < ActiveRecord::Migration
def change
add_column :beer_me_searches, :rarity, :boolean
add_column :beer_me_searches, :draft, :boolean
add_column :beer_me_searches, :available_beer, :string
end
end
|
#
# XcodeInstaller::Install (Command Class)
#
# First, this command will look for the expected version of the Xcode installation .dmg file in the download (current) dir.
# If not found, the download will be initiated, afterwards the expected file will be verified.
# Installation will continue once the expected .dmg fil... |
class PostsController < ApplicationController
def tweet
client = TwitterFeed.user_client(@current_user)
client.update(params[:tweet])
redirect_to root_path, notice: "Your tweet is a SUCCESS!"
end
# Write in logic for re-favoriting error.
def favorite
client = TwitterFeed.user_client(@current_us... |
require 'spec_helper'
require 'models/shared/legacy_node_url_helper'
require 'models/shared/shared_examples_for_authorable'
describe CuratedCollection do
it_should_behave_like Authorable
it_should_behave_like 'a legacy node url' do
let(:model){ FactoryGirl.create(:curated_collection) }
end
it{ should v... |
class BoardsController < ApplicationController
def index
@boards = Board.all
end
def show
@board = Board.friendly.find(params[:id])
@new_topic = Topic.new
@topics = @board.topics.with_replies.with_comment_replies.page(params[:page])
render "topics/index"
end
end
|
class Message < ApplicationRecord
belongs_to :message_group
belongs_to :user
validates :detail, :recipient_id, presence: true
def user_name
"#{user.first_name} #{user.last_name}"
end
end
|
require_relative 'month'
class Year
def initialize(year)
@year = year
end
def leap?
bool = false
if @year % 4 == 0
bool = true
if @year % 100 == 0
bool = false unless (@year % 400 == 0)
end
end
bool
end
def to_s
months = []
12.times do |i|
months ... |
class Domain < ActiveRecord::Base
MIN_INDEXED_THRESHOLD = 0
include Checkable
belongs_to :project
validates :url, url: { allow_blank: true }, presence: true, uniqueness: true
validates :project_id, presence: true
after_save :send_notification
def self.check_job_class
CheckHostJob
end
def hos... |
class Follow < ApplicationRecord
belongs_to :user
belongs_to :comic
validates :user_id, uniqueness: { scope: :comic_id }
end
|
module WatchersTextInput
class Hooks < Redmine::Hook::ViewListener
# This just renders the partial in
# app/views/hooks/my_plugin/_view_issues_form_details_bottom.rhtml
# The contents of the context hash is made available as local variables to the partial.
#
# Additional context fields
# :is... |
class Player < ApplicationRecord
validates_presence_of :first_name, :last_name, :height, :weight, :birthday,
:graduation_year, :position
belongs_to :team, optional: true
has_many :assessments
end
|
class PollyController < ApplicationController
def slash
begin
if params[:token] == ENV['POLLY_VERIFICATION_TOKEN'] || Rails.env.development?
query = params[:text].strip
if query == ''
response = { text: "Just type whatever you want and I'll read it back to you.", response_type: 'ep... |
module Concerns::TokenAuthenticable
extend ActiveSupport::Concern
included do
before_save :ensure_authentication_token!
end
module ClassMethods
def reset_authentication_token!
self.authentication_token = generate_authentication_token
self.save
end
end
def reset_pass
raw, enc =... |
include_recipe "chimpstation_base::user_owns_usr_local"
unless File.exists?("/Applications/TextMate.app")
execute "download text mate to temp dir" do
command "curl -o /tmp/textmate.zip http://dl.macromates.com/TextMate_1.5.10_r1623.zip"
user $ws_user
end
execute "extract text mate to /Applications" do
... |
#auto_discover_spec.rb
require 'test_constants'
describe Sword2Ruby::AutoDiscover do
it "Testing AutoDiscover on Service html" do
autodiscover = Sword2Ruby::AutoDiscover.new(TEST_AUTODISCOVER_SERVICE_HTML_URI)
#Test that the service_document_uri was found
autodiscover.service_document_uri.should_no... |
# frozen_string_literal: true
require 'sodor/line_code'
require 'sodor/stations_builder'
module Sodor
class Stations
extend Forwardable
attr_reader :distances
def_delegators(:@stations, :[]=, :[], :values, :keys)
def initialize(stations = {})
@stations = stations
@distances = {}
e... |
class MicropostsController < ApplicationController
before_filter :authenticate_user!, only: [:create, :destroy]
def index
end
def create
image = Image.find(params[:image_id])
@micropost = image.microposts.build(params[:micropost]
.merge(:user_id => current_user... |
module MediaFacebookEngagementMetrics
extend ActiveSupport::Concern
included do
Media.declare_metrics('facebook')
end
def get_metrics_from_facebook
key_id = self.key ? self.key.id : nil
self.class.get_metrics_from_facebook_in_background(self.url, key_id)
end
module ClassMethods
def get_me... |
class FormulationsController < ApplicationController
skip_before_action :verify_authenticity_token, only: [:update_positions, :update_locale]
before_action :set_owner
before_action :set_agent
before_action :check_user_rights
before_action :set_interpretation
before_action :set_formulation, except: [:create,... |
# encoding: UTF-8
class Window_choice
attr_reader :x, :y, :texts
attr_accessor :button, :index, :active
#--------------------------------------------------------------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------... |
#!/usr/bin/ruby
# coding: utf-8
# commander.rb
# Small dialog window that allows persons not familiar
# with this computer to do some emergency tasks like
# muting the sound or cutting off the network, in cases when
# i'm not around and the computer is obstructive to others.
class Commander
def initialize
... |
# encoding:utf-8
require 'oj'
require 'elasticsearch'
require 'typhoeus'
require 'typhoeus/adapters/faraday'
# helper methods
require 'elasticsearch_rasi/util'
require 'elasticsearch_rasi/query'
require 'elasticsearch_rasi/request'
require 'elasticsearch_rasi/common'
# alias query methods
require 'elasticsearch_rasi/... |
#!/usr/bin/env ruby
class Student
def initialize(name, gender, major, exam_score)
@name = name
@gender = gender
@major = major
@exam_score = exam_score
end
def increaseScore(amount)
exam_score += amount
end
def decreaseScore(amount)
exam_score -= amount
end
def display
puts... |
require "net/http"
require "lib/feed_me/lib/feed_me"
require "#{RAILS_ROOT}/vendor/plugins/calendar_helper/lib/calendar_helper.rb"
class User < ActiveRecord::Base
has_many :projects
has_many :checkins
has_many :days
before_create :set_github_login!
def after_create
pull_history
end
def self.top_us... |
require 'openssl'
require 'base64'
require 'cgi'
require 'uri'
module EARMMS::DiscourseSSOHelpers
def discourse_sso_enabled?
return false unless EARMMS.app_config[:discourse_sso].respond_to?(:[])
return false unless EARMMS.app_config[:discourse_sso][:enabled] == true
# check secret
return false unle... |
class DamageTokenSerializer < ActiveModel::Serializer
attributes :value, :fake
end |
class CreateEspecifications < ActiveRecord::Migration[5.0]
def change
create_table :especifications do |t|
t.text :descricao
t.references :type, foreign_key: true
t.integer :qtde
t.decimal :valor_un
t.references :interest, foreign_key: true
t.references :modality, foreign_key: ... |
class AddCommentForQitaToSingleCustomers < ActiveRecord::Migration
def change
add_column :single_customers, :comment_for_qita, :string
end
end
|
json.array!(@dietdocuments) do |dietdocument|
json.extract! dietdocument, :id, :diet_id
json.url dietdocument_url(dietdocument, format: :json)
end
|
class TasksController < ApplicationController
respond_to :json
def index
tasks = Task.all
render json: tasks
end
def create
task = Task.new(task_params)
if task.save
render json: task, status: 201
else
render json: {}, status: 400
end
end
def update
task = Task.fin... |
module MindpinSidebar
class Railtie < Rails::Railtie
initializer 'mindpin_sidebar.helper' do |app|
ActionView::Base.send :include, MindpinSidebar::Helpers
end
config.to_prepare do
filename = File.join(Rails.root.to_s, 'config/mindpin_sidebar_config.rb')
load filename if File.exi... |
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) { User.create!(username: "example", email: "example@gmail.com", password: "password") }
it { is_expected.to have_many(:RegisteredApplication) }
describe "attributes" do
it "has title and body attributes" do
expect(user).to have_at... |
class VenueTypesController < ApplicationController
before_filter :authenticate_admin!
# GET /venue_types
# GET /venue_types.json
def index
@venue_types = VenueType.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @venue_types }
end
end
# GET /venu... |
# == Schema Information
#
# Table name: posts
#
# id :bigint(8) not null, primary key
# date :date
# rationale :text
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint(8)
# status :integer default("submitted")
#
require 'rails_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.