text stringlengths 10 2.61M |
|---|
class CreateTasks < ActiveRecord::Migration
def change
create_table :tasks do |t|
t.text :name
t.text :description
t.integer :user_id
t.boolean :approved, default: false
t.integer :percent_complete
t.timestamps
end
end
end |
require 'spec_helper'
describe AjaxController do
context "with tweets" do
before :each do
3.times do
FactoryGirl.create(:tweet)
end
3.times do
FactoryGirl.create(:tweet, :user_screen_name=>"Startupaus")
end
end
describe "GET 'tweets'" do
it "returns tweets" do
xhr :get, :... |
class Verb < ApplicationRecord
has_many :keywords
has_many :documents, through: :keywords, source: :keywordable, source_type: 'Document'
has_many :categories, through: :keywords, source: :keywordable, source_type: 'Category'
end
|
require "action_controller/railtie"
require "active_model"
require 'omniauth-twitter'
require 'devise-i18n/view_helpers'
class User
def email
'me@example.com'
end
def pending_reconfirmation?
false
end
def self.unlock_strategy_enabled?(something)
true
end
def self.omniauth_providers
[:t... |
class Role < ActiveRecord::Base
has_and_belongs_to_many :app_users
end |
class Api::V1::CatsController < ApplicationController
before_action :authorized, only: [:cat_fav, :user_favs]
def index
category_id = params[:category_id].present? ? params[:category_id].to_i : nil
breed_id = params[:breed_id].present? ? params[:breed_id] : nil
cats = Cat.search(category_id, breed_id)
... |
class AddForeignKeyToResults < ActiveRecord::Migration[6.0]
def change
add_foreign_key :results, :users
add_foreign_key :results, :races
end
end
|
# frozen_string_literal: true
Sequel.migration do
change do
add_column :coaches, :certifications, "text[]"
end
end
|
require_relative '../test_helper'
class CommentsControllerTest < ActionController::TestCase
def setup
sign_in(writers(:eloy))
@story = stories(:collector_collection)
end
test 'creates a comment for a story' do
assert_difference '@story.comments.count', +1 do
post 'create', story_id: @story.to_... |
class ChangelogsController < ApplicationController
load_and_authorize_resource :project
load_and_authorize_resource :changelog, :through => :project
def index
@changelogs = @project.changelogs.order('last_commit_date DESC').page(params[:page])
end
def show
respond_to do |format|
format.text d... |
class Customer < ActiveRecord::Base
has_many :invoices
has_many :merchants, through: :invoices
validates :first_name, presence: true
validates :last_name, presence: true
end
|
class Api::V1::RecipesController < Api::V1::BaseController
before_action :set_recipe, only: [:show, :update, :destroy]
# GET /recipes
def index
@recipes = Recipe.all.paginate(page: params[:page], per_page: 20)
json_response(@recipes)
end
# GET /recipes/:id
def show
json_response(@recipe)
end... |
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/foreign_key_saver/version', __FILE__)
spec = Gem::Specification.new do |gem|
gem.name = 'foreign_key_saver'
gem.version = ForeignKeySaver::VERSION
gem.summary = "Adds support for foreign key constraints to ActiveRecord schema operations... |
Facter.add(:definition) do
setcode do
Facter.value(:hostname) == 'master'
end
end
|
class Match < ApplicationRecord
belongs_to :home_team, class_name: 'Team', foreign_key: 'home_team_id'
belongs_to :guest_team, class_name: 'Team', foreign_key: 'guest_team_id'
has_many :goals, dependent: :destroy
validates_presence_of :home_team, :guest_team
end
|
require 'rubygems'
require 'ramaze'
require 'ramaze/spec/helper'
module MechanizeSpecHelper
# shortcuts for mechanize
def click(link)
@page = agent.click(link)
end
def link(text)
page.links.text(text).first
end
def click_link(text)
click link(text)
end
def submit(form)
@page = agent.... |
class UserCoursesController < ApplicationController
load_and_authorize_resource
before_action :load_course, only: :show
def index
type = params[:type]
get_user_courses = current_user.user_courses
if type != "pending" && type != "started" && type != "finished"
@user_courses = get_user_courses
... |
class Location < ApplicationRecord
has_many :melocations
has_many :my_memories, :through => :melocations
end
|
require_relative 'app_loader'
class TestAppApp < Roda
include Isomorfeus::PreactViewHelper
use Isomorfeus::AssetManager::RackMiddleware
plugin :public, root: 'public'
def page_content(host, location)
req = Rack::Request.new(env)
skip_ssr = req.params.key?("skip_ssr") ? true : false
rendered_tree ... |
class FoodsController < ApplicationController
def index
@foods = Food.all
end
def new
@food = Food.new
end
def create
food = Food.new(food_params)
food.save
redirect_to foods_path
end
def show
@food = Food.find(params[:id])
... |
#!/usr/bin/env ruby
class CashRegister
def initialize
@total = 0.00
end
def purchase(amount)
@total += amount
end
def total
@total
end
def pay(paid)
if paid > total
@change = paid - total
@total = 0
else
@total -= paid
end
end
end
if __FILE__ == $0
regi... |
feature "Proposals - List" do
context 'Visitor' do
scenario "Access invalid" do
visit proposals_path
expect(current_path).to eq new_session_path
end
end
context 'Admin' do
let(:user) { create :user }
background do
login user.email, user.... |
class Job < ApplicationRecord
belongs_to :user
has_many :message
has_and_belongs_to_many :documents
end |
module CDI
module V1
module PageStructure
class ModelSerializer::SkillSerializer < ActiveModel::Serializer
attributes :id, :name, :description, :position
end
end
end
end
|
class CreateResourceStorageEvaArrays < ActiveRecord::Migration[5.0]
def change
create_table :resource_storage_eva_arrays do |t|
t.string :name
t.string :model
t.string :serial
t.string :firmware
t.integer :space_total
t.integer :space_available
t.integer :space_used
... |
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root to: "books#index"
resources :books do
resources :comments, only: :create
end
#resources :categories, except: [:new, :show]
end
|
class CreateProtos < ActiveRecord::Migration
def change
create_table :protos do |t|
t.string :title
t.text :catch_copy
t.text :concept
t.references :user
t.integer :likes_count
t.timestamps null: false
end
end
end
|
class CreateResources < ActiveRecord::Migration
def up
create_table :resources do |t|
t.belongs_to :category, :member
t.string :name
end
add_index :resources, :category_id
add_index :resources, :member_id
end
def down
drop_table :resources
end
end
|
require_relative 'board_case'
require_relative 'player'
class Board
attr_accessor :arr_boardcase
def initialize
@arr_boardcase = []
@arr_boardcase << BoardCase.new("A1")
@arr_boardcase << BoardCase.new("A2")
@arr_boardcase << BoardCase.new("A3")
@arr_boardcase << BoardCase.new("B1")
@arr_b... |
require './lib/message'
class PlacementValidator
attr_reader :grid, :ship, :c1, :c2
def initialize(grid, ship, begin_coord, end_coord)
@grid = grid
@ship = ship
@c1 = begin_coord
@c2 = end_coord
end
def find_actual_coords # helper
if c1[0] == c2[0]
Array(c1..c2)
else
Array... |
require 'rails_helper'
RSpec.describe Tagging, type: :model do
describe 'Associations' do
it { is_expected.to belong_to :tag }
it { is_expected.to belong_to :news }
end
end
|
class SchoolWelcomeWizard < ApplicationRecord
belongs_to :user
belongs_to :school
validates :step, presence: true
enum step: {
allocation: 'allocation',
techsource_account: 'techsource_account',
will_other_order: 'will_other_order',
devices_you_can_order: 'devices_you_can_order',
chromeboo... |
require "spec_helper"
RSpec.describe "Day 21: Scrambled Letters and Hash" do
let(:runner) { Runner.new("2016/21") }
let(:input) do
<<~TXT
swap position 4 with position 0
swap letter d with letter b
reverse positions 0 through 4
rotate left 1 step
move position 1 to position 4
... |
module OCELOT
Java::OrgOdftoolkitSimple::TextDocument.class_eval do
# look up an execution path for an undefined method
def method_missing(name, *args, &block)
if OCELOT::Text.respond_to? name
OCELOT::Text.send name, *args, &block
else
# Set some mappings on a case-by-case basis
... |
class SongwritersController < ApplicationController
before_action :set_songwriter, only: [:show, :update, :destroy]
# GET /songwriters
def index
@songwriters = Songwriter.all
render json: @songwriters
end
# GET /songwriters/1
def show
render json: @songwriter
end
# POST /songwriters
de... |
require 'csv'
require 'time'
class Transaction
attr_reader :id, :invoice_id, :credit_card_number, :credit_card_expiration_date, :result, :created_at, :updated_at
def initialize(input)
puts input
@id = input["id"]
@invoice_id = input["invoice_id"]
@credit_card_number = input["credit_card_number"]
... |
#--------------------------------------------------
# Name: dangdangbook.rb
# Description: This script is used to download books from http://read.dangdang.com/
# The content of book is saved as text file under the same directory with this script
#
# Prerequisit:
# ... |
class AddColumnToLineItemsHc < ActiveRecord::Migration
def change
add_column :line_items, :homecurrency_amount, :float
end
end
|
class FinanceInflow < ActiveRecord::Base
attr_accessible :amount, :debited_from, :income_type
validates_presence_of :amount, :debited_from, :income_type
validates :amount, :numericality => { :only_integer => true }
end
|
#!/usr/bin/ruby -w
# Programmer: Chris Bunch (cgb@cs.ucsb.edu)
require 'openssl'
require 'soap/rpc/driver'
require 'timeout'
# Sometimes SOAP calls take a long time if large amounts of data are being
# sent over the network: for this first version we don't want these calls to
# endlessly timeout and retry, so as a ha... |
require 'pry'
class MenuItem
attr_accessor
attr_reader :dish_name, :price, :restaurant
@@all = []
def self.all
@@all
end
def initialize(restaurant,dish_name,price)
@restaurant = restaurant
@dish_name = dish_name
@price = price
@@all << self
end
... |
class AddActiveToAnimals < ActiveRecord::Migration
def change
add_column :animals, :active, :boolean, default: true
Animal.update_all(active: true)
end
end
|
require 'spec_helper'
describe PagesController do
integrate_views
before(:each) do
@base_title = "Ruby on Rails Sample Application | "
end
describe "GET 'random_page'" do
it "should not be successful" do
get 'random_page'
response.should_not be_success
end
end
describe "GET 'hom... |
class Drug < ActiveRecord::Base
attr_accessible :brand, :price_per_unit, :quantity, :title
validates_presence_of :brand, :price_per_unit, :quantity, :title
def decrease_quantity(qty)
if self.quantity < qty
raise InvalidDataError, "Quantity not available"
else
self.update_attribute(:quantity, ... |
class CreateSteps < ActiveRecord::Migration
def change
create_table :steps do |t|
t.string :name, :step_class, null: false
t.integer :day, :position, null: false
t.belongs_to :program, null: false
t.timestamps
end
add_index :steps, :program_id
end
end
|
namespace :test do
desc 'Run rspec'
task run: :environment do
require 'tty'
require 'tty-command'
abort 'InfluxDB not running' unless influx_running?
command = TTY::Command.new(printer: :quiet, color: true)
p "Running rspec via 'rspec'"
start = Time.now
begin
# command.run('rspec... |
class ImagesController < ApplicationController
def index
end
def show
@image = Image.find(params[:id])
@keywords = @image.keywords
if current_user
@new_comment = Comment.new
@comments = Comment.where(image_id: @image.id).to_a
@new_favorite = Favorite.new
@favorite = Favorite.w... |
Rails.application.routes.draw do
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
root 'home#index'
get 'homepage', to: 'home#index'
get 'exchanges/*pane', to: 'home#app'
get 'exchanges/:id/*pane', to: 'home#app'
get 'exchange/:id', to: 'e... |
class FontPhetsarath < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/phetsarath"
desc "Phetsarath"
homepage "https://fonts.google.com/earlyaccess"
def install
(share/"fonts").install "Phetsarath-Bold.ttf"
(share/"fonts").install ... |
class DictsController < ApplicationController
def index
dict = Dict.new(params[:dict])
sql = ' 1 '
sql += " and title like '%#{dict.title}%'" if dict.title.present?
sql += " and category like '%#{dict.category}%'" if dict.category.present?
@dicts = Dict.search_by_sql(sql,params[:page])
respon... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
describe 'Bindings' do
it { Vedeu.bound?(:_keypress_).must_equal(true) }
it { Vedeu.bound?(:_drb_input_).must_equal(true) }
it { Vedeu.bound?(:_command_).must_equal(true) }
end
module Input
describe Mapper do
let(:describ... |
json.array!(@facilities) do |facility|
json.extract! facility, :id, :name, :town, :district, :region, :latitude, :longitude, :phone, :website, :specialty, :photo, :category
json.url facility_url(facility, format: :json)
end
|
require 'spec_helper'
describe "quick_tweets/edit" do
before(:each) do
@sport = FactoryGirl.create(:sport)
@quick_tweet = assign(:quick_tweet, stub_model(QuickTweet,
:sport_id => @sport.id,
:name => "MyString",
:tweet => "MyString",
:happy => false
))
end
it "renders the edit... |
require 'digest'
class Student < ActiveRecord::Base
# attr_accessible :password, :password_confirmation
belongs_to :religion
belongs_to :gender
belongs_to :college
belongs_to :course
belongs_to :guide
has_many :card_plans
has_many :recaps
belongs_to :active
validates :nim, uniqueness: true
vali... |
class Picture < ApplicationRecord
def generate
def gen_filename(name)
"public/tmp/_#{name}_#{Time.now.strftime("%s")}.jpg"
end
# def url_encode(str)
# return URI.encode(str)
# end
options = {}
#name = url_encode self.name
normal = Dir.glob("lib/assets/templates/*.jpg")
b... |
class WeightliftingDefinitionsController < ApplicationController
before_action :set_weightlifting_definition, only: [:show, :edit, :update, :destroy]
# GET /weightlifting_definitions
# GET /weightlifting_definitions.json
def index
@weightlifting_definitions = WeightliftingDefinition.all
end
# GET /wei... |
class UserSerializer < ActiveModel::Serializer
attributes :id, :email, :name
has_many :weight_entries
has_many :meal_entries
has_many :exercise_entries
has_many :recipes
end |
class Item < ApplicationRecord
validates :item_name, presence:true
validates :item_name_kana, presence:true
validates :price, presence: true,numericality: {only_integer: true, greater_than: 0 }
validates :stock, presence: true,numericality: {only_integer: true, greater_than_or_equal: 0 }
validates :artist_name, pr... |
#!/usr/bin/env ruby
require 'test/unit'
require 'given/test_unit'
class AdapterTest < Given::TestCase
include Given::TestUnit::Adapter
Code = Given::Code
def add_assertion
super
@assertion_counted = true
end
Given do
When { given_assert("Then", Code.new("T", lambda { true })) }
Then { @as... |
require 'spec_helper'
describe SignHost::PayloadCreator do
it 'creates a json representation from a contract' do
contract = build_contract
json_contract = SignHost::PayloadCreator.create(contract)
expect(json_contract).to eq(expected_payload_with_signers(0))
end
it 'creates a json representation wit... |
class Track
include Lotus::Entity
self.attributes = :artist_title, :title
def queries
["#{better_artist_title} #{better_title}", better_title]
end
private
def better_artist_title
artist_title.gsub("ft.", "feat.")
end
def better_title
title.gsub("ft.", "feat.")
end
end
|
# Let's define Tree but this time parameterized by :value_type,
Tree = Algebrick.type(:value_type) do |tree|
variants Empty = atom,
Leaf = type(:value_type) { fields value: :value_type },
Node = type(:value_type) { fields left: tree, right: tree }
end
# with method depth defined as before.
mo... |
require("spec_helper")
describe(Venue) do
it { should have_many(:bands).through(:concerts) }
it("validates presence of the venue's name") do
venue = Venue.new({:venuename => ""})
expect(venue.save()).to(eq(false))
end
it("ensures the length of the venue is at most 50 characters") do
venue = Venue... |
# The Walkmydog app installation representing class
class Installation
include DataMapper::Resource
# property :id, Serial
property :object_id, String, required: true, length: 255, key: true
property :email, String, required: true, length: 255
property :created_at, Da... |
class User < ApplicationRecord
after_initialize :set_defaults, unless: :persisted?
has_secure_password :validations => false
#A user can create many (has many) events, and also can belong to many events
#through the 'user_events' table
has_many :user_events, dependent: :destroy
# to be clear on... |
class StatManIdOnNatsStats < ActiveRecord::Migration
def up
remove_column :stat_men, :nats_stats_id
add_column :nats_stats, :stat_man_id, :integer
end
def down
end
end
|
require 'uri'
module YoutubeMultipleDL
class URL
def initialize(url:)
@url = url
end
def valid?
@url =~ URI::regexp
end
def to_s
@url
end
end
end |
class AddPendSecretriaAluno < ActiveRecord::Migration
def self.up
add_column :alunos, :pend_secretaria, :boolean
end
def self.down
remove_column :alunos, :pend_secretaria
end
end
|
require "concerns/user_provided_services"
class AppConfigCredentials
extend UserProvidedService
def self.api_enabled
if use_env_var?
ENV["API_ENABLED"]
else
credentials(base_name("app_config"))["API_ENABLED"]
end
end
def self.welcome_email
if use_env_var?
ENV["WELCOME_EMAIL"... |
# encoding: UTF-8
require 'yaml'
module Creq
# Module for holding parameters in .yml file
# Usage:
#
# module Settings
# extend ParamHolder
# extend self
#
# parameter :param1, default: 2
# parameter :param2, default: 2
# end
#
# require_re... |
class TwilioSmsService
# TwilioSmsService.new("your message here").call
attr_reader :message
def initialize(message)
@message = message
end
def call
client = Twilio::REST::Client.new
client.messages.create({
from: Rails.application.secrets.twilio_number,
to: "+447549273987",
bod... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :firstname
t.string :lastname
t.string :email
t.string :password
t.string :avatar
t.string :street
t.string :city
t.string :country
t.string :birthday
t.string :bi... |
Rails.application.routes.draw do
get '/(:seed)', to: "get_name#index"
end
|
# frozen_string_literal: true
module Bookshelf
module Actions
module Books
class Show < Bookshelf::Action
include Deps['repositories.books']
params do
required(:id).filled(:integer, gteq?: 0)
end
def handle(req, res)
params = req.params
halt 4... |
module CommentsHelper
# Helper that allows user to submit form or cancel
# form; cancel returns the user to products#show or the comments#index
# Accepts a reference to the form button/link are on
# cancel_name: name for the cancel link; default is Cancel
def submit_with_cancel_comments(form, cancel_name = t... |
#
# Copyright 2012-2015 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
module MasterDataParent
# it sets up master data
def master_data(attribute, master=nil, options = {})
attribute = attribute.to_sym
attribute_s = attribute.to_s
return if self.class.method_defined? "#{attribute_s}_master"
if master.is_a? Class
master_classname = master.name
else
... |
module Api
module V1
class UsersController < V1::ApiController
skip_before_action :check_basic_auth, only: [:create]
def show
user = User.find_by_id(params[:id])
render json: user
end
def index
users = User.all
render json: users
end
def cre... |
Rails.application.routes.draw do
namespace :admin do
resources :jobs do
resources :applications, only: %i(show edit index update)
end
resources :long_jobs, only: %i(index show)
root to: 'jobs#index'
get 'candidates/export', to: 'candidates#export', as: :export_candidates
resources :candi... |
# Copyright 2012-2013 Red Hat, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
class SkedlsController < ApplicationController
# GET /skedls
# GET /skedls.json
def index
@skedls = Skedl.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @skedls }
end
end
# GET /skedls/1
# GET /skedls/1.json
def show
@skedl = Skedl.find(par... |
class Post < ActiveRecord::Base
attr_accessible :body, :title, :author_id
validates :title, :length => { :in => 4..80 }
validates :body, :presence => true
belongs_to :author
has_many :tags
has_many :categories
has_many :comments, :dependent => :destroy
end
|
require 'sinatra/base'
require 'sinatra/json'
module Steps
class FakeGitHubApi
attr_reader :secret
def call(env)
params = JSON.parse(env["rack.input"].read)
@secret = params.fetch("config").fetch("secret")
headers = { "Content-Type" => "application/json" }
body = { "id" => 42 }
... |
class Rating
SCORES = {
'0-' => 0,
'0' => 1,
'0+' => 2,
'1-' => 3,
'1' => 4,
'1+' => 5,
'2-' => 6,
'2' => 7,
'2+' => 8,
'3-' => 9,
'3' => 10,
'3+' => 11
}.freeze
DESCRIPTIONS = {
0 => 'Painful',
1 => 'Unlistenable',
2 => 'Almost unlistenable',
... |
class AddSignUpColumns < ActiveRecord::Migration[5.0]
def change
add_column(:players, :age_level, :integer)
add_column(:players, :tryout_number, :integer)
add_column(:players, :position, :string)
end
end
|
package "httpd" do
action :install
end
service "httpd" do
action [ :enable, :start ]
end
cookbook_file "/var/www/html/index.html" do
source "index.html"
mode "0644"
end
package "httpd" do
action :install
end
service "httpd" do
action [ :enable, :start ]
end
# disable the default virtual host
execute "... |
FactoryGirl.define do
factory :repository, class: Hash do
full_name { "#{Faker::Internet.user_name}/#{name}" }
is_private true
links {{
self: FactoryGirl.attributes_for(:link, href: "https://bitbucket.org/api/2.0/repositories/#{full_name}"),
html: FactoryGirl.attributes_for(:link, href: "https... |
require 'csv'
require 'pry'
module RideShare
class Driver < User
attr_reader :vin, :driven_trips
attr_accessor :status
VALID_STATUSES = [:AVAILABLE, :UNAVAILABLE]
def initialize(input)
# raises an argument error if bogus status for drivers is given
if VALID_STATUSES.include?(input[:stat... |
require File.expand_path('../support/test_application', __FILE__)
def monkey_patch_minitest_to_do_nothing
# Rails 3.1's test_help file requires Turn, which loads Minitest in autorun
# mode. This means that Minitest tests will run after these RSpec tests are
# finished running. This will break on CI since we pass... |
require 'spec_helper'
describe CronSpec::SingleValueCronValue do
before(:each) do
@cv = CronSpec::SingleValueCronValue.new(0, 32, 8)
end
it "should indicate effective if the value matches" do
@cv.is_effective?(8).should be true
end
it "should indicate not effective if value does not match" do
... |
require 'byebug'
def range(start_number, end_number)
return [] if end_number <= start_number
return [start_number] if end_number == start_number + 1
[start_number] + range(start_number + 1, end_number)
end
def array_sum_recursive(array)
return array[0] if array.length == 1
array[0] + array_sum_recursive(a... |
require File.expand_path('../teststrap', __FILE__)
require File.expand_path('../fixtures/test', __FILE__)
context "has_plugin macro" do
helper(:macro) { RiotMongoMapper::HasPluginAssertion.new }
setup do
mock_model do
plugin Plugins::Test
end
end
asserts "passes when has plugin" do
macro.... |
class PortalsController < ApplicationController
before_action :register
def index
@grid_portals = PortalsGrid.new(params[:portals_grid]) do |scope|
scope.page(params[:page])
end
end
def new
@portal = Portal.new
build_portals
end
def edit
@portal = Portal.find params[:id]
build_portals
end
de... |
class TodosController < ApplicationController
before_action :set_todo, only: [:show, :edit, :update, :destroy]
def index
@todos = Todo.all
authorize @todos
end
def show
end
def new
@todo = Todo.new
authorize @todo
end
def edit
@todo = Todo.find(params[:... |
class ApplicationController < ActionController::Base
include Clearance::Controller
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def enroll
user = User.find(params[:id])
course = Course.find(params[:id])
... |
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'ユーザー新規登録' do
before do
@user = FactoryBot.build(:user)
end
context '内容に問題ない場合' do
it 'すべての値が正しく入力されていれば保存できること' do
expect(@user).to be_valid
end
end
context '内容に問題がある場合' do
it 'ニックネームが入力されていない場... |
require "application_system_test_case"
class UsersShowsTest < ApplicationSystemTestCase
setup do
@max = User.create(firstname: 'mas', lastname: 'simo', email: 'mass@imo.fr')
@bab = User.create(firstname: 'bab', lastname: 'ounet', email: 'bab@ounet.fr')
end
test "1 - Visiting the index" do
visit ro... |
class Tem::Session
include Tem::Abi
include Tem::Apdus::Buffers
include Tem::Apdus::Keys
include Tem::Apdus::Lifecycle
include Tem::Apdus::Tag
include Tem::Admin::Emit
include Tem::Admin::Migrate
include Tem::CA
include Tem::ECert
include Tem::SeClosures
include Tem::Toolkit
... |
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
root to: 'admin/dashboard#index'
namespace :api do
get '/setup', to: 'game#index'
get '/category', to: 'category#index'
get '/category/:id/movie', to: 'movie#index'
resources :ranking... |
class UsersController < ApplicationController
before_action :authorize_user, only: [:show]
before_action :admin_only, only: [:index]
def home
@name = current_user ? @current_user.username : "Stranger"
end
def index
@users = User.all.limit(20)
end
def new
end
def create
user = User.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.