text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require 'rails_helper'
describe Akismet do
let(:client) { Akismet::Client.new(api_key: 'akismetkey', base_url: 'someurl') }
let(:post_args) do
{
content_type: "forum-post",
permalink: "http://test.localhost/t/this-is-a-test-topic-49/1889/1",
comment_author: "br... |
require "formant/version"
require 'active_model'
require 'active_support/all'
require 'action_view'
require 'phony_rails'
module Formant
include ActionView::Helpers::NumberHelper
#
# Base class for Form objects.
#
# See https://www.reinteractive.net/posts/158-form-objects-in-rails
# (among others) for m... |
module Humi
class Middleware < Faraday::Middleware
autoload :Authentication, "humi/middleware/authentication"
autoload :Authorization, "humi/middleware/authorization"
autoload :Logger, "humi/middleware/logger"
def initialize(app, client, options)
@app = app
@client = client
... |
module Byebug
#
# Holds an array of subcommands for a command
#
class SubcommandList
def initialize(commands, parent)
@commands = commands
@parent = parent
end
def find(name)
@commands.find { |cmd| cmd.match(name) }
end
def help(name)
subcmd = find(name)
retur... |
class String
define_method(:word_count) do | needle |
punctuation_list = [',','.','?','!','(',')','#','@',':',';']
needle.downcase!()
word_haystack = self.downcase()
punctuation_list.each() do | punctuation |
word_haystack.gsub!(punctuation,'')
end
word_haystack = word_haystack.split(' '... |
require_relative 'piece'
class Bishop < Piece
def to_s
@player.color == 'white' ? "\u2657" : "\u265D"
end
def update_available_moves
# TODO: finish this
@available_moves = []
end
end
# class Bishop < Piece
#
# def to_s
# @player.color == 'white' ? "\u2657" : "\u265D"
# end
#
# def allo... |
require 'spec_helper'
require 'app/models/linter/base'
module Linter
class Test < Base
FILE_REGEXP = /.+\.yes\z/
end
end
describe Linter::Base do
describe '.can_lint?' do
it 'uses the FILE_REGEXP to determine the match' do
yes_lint = Linter::Test.can_lint?('foo.yes')
no_lint = Linter::Test.c... |
module Photos
class Cli
class LocalFileSystemBrowser < Base
def initialize(file_system)
@file_system = file_system
end
def browse
directory = select_directory
photo = select_photo(directory)
photo_menu(photo)
end
def select_directory
... |
class Attendance < ApplicationRecord
belongs_to :user
belongs_to :event
include Workflow
workflow_column :state
workflow do
state :request_sent do
event :accept, :transitions_to => :accepted
event :reject, :transitions_to => :rejected
end
state :accepted
state :rejected
end
def self.show_accept... |
require 'rails_helper'
feature "the signup process" do
it "has a new user page" do
visit '/users/new'
expect(page).to have_content('Sign Up')
expect(page).to have_field('Username')
expect(page).to have_field('Password')
end
feature "signing up a user" do
it "shows username on the homepag... |
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# body :text(65535)
# user_id :integer
# sent_to_user_id :integer
# visibility :integer
# created_at :datetime not null
# updated_at :datetime not null
# re... |
require 'rails_helper'
RSpec.describe VideoPreviewsController do
let(:video_preview) { create(:video_preview) }
describe 'GET show' do
it 'renders page' do
get :show, id: video_preview.id
expect(assigns(:video_preview)).to be_present
expect(response).to be_success
end
context 'as js... |
Pod::Spec.new do |s|
s.name = "ViberPPLocalization"
s.version = "1.0.0"
s.summary = "ViberPP Localizations"
s.license = 'MIT'
s.author = { "Enea Gjoka" => "enea@unlimapps.com" }
s.homepage = 'https://github.com/eni9889/localizations.git'
s.platfor... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module DataReaders
class AdditionalDateFormatSelector
attr_reader :pattern_hash
def initialize(pattern_hash)
@pattern_hash = pattern_hash
end
def find_closest(goal_pa... |
class User < ApplicationRecord
has_secure_password
has_secure_token
# adding account_type to prevent The single-table inheritance mechanism failure before validation
attr_accessor :account_type
before_create :assign_type
TYPES = %w(Admin Restaurant Employee)
validates :account_type, inclusion: { in: T... |
require File.dirname(__FILE__) + '/../test_helper'
class ContactsMailerTest < ActionMailer::TestCase
tests ContactsMailer
def test_signup
@expected.subject = 'ContactsMailer#signup'
@expected.body = read_fixture('signup')
@expected.date = Time.now
assert_equal @expected.encoded, ContactsMail... |
require 'spec_helper'
describe Devise::SessionsController do
describe 'routing' do
it 'GET /users/sign_in' do
expect(get '/users/sign_in').to route_to('devise/sessions#new')
end
it 'POST /users/sign_in' do
expect(post '/users/sign_in').to route_to('devise/sessions#create')
end
it 'G... |
class Friendship < ActiveRecord::Base
belongs_to :user
belongs_to :friend, :class_name => "User"
has_many :person_interests, :as => :person
has_many :interests, :through => :person_interests
end
|
# coding: us-ascii
# frozen_string_literal: true
# Copyight (c) 2013 Kenichi Kamiya
# An reader/writer library for the LTSV(Labeled Tab Separated Values) format
# See LTSV specs http://ltsv.org/
require_relative 'ltsv/version'
module LTSV
ROW_SEPARATOR = "\n".freeze
COLUMN_DELIMITER = "\t".freeze
LABEL_END... |
class Platforms < BasePackage
include SingleVersion
desc "Android platforms headers and libraries"
release version: '24', crystax_version: 6
# todo:
#build_depends_on default_compiler
ARCHIVE_TOP_DIRS = ['platforms'] # todo: , 'samples']
attr_accessor :src_dir, :install_dir
def release_director... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
local_vars_file = File.join(File.dirname(__FILE__), "vars.yml")
local_vars = YAML.load_file(local_vars_file)
ssh = local_vars["ssh"]
vm = local_vars["aws"]
Vagrant.configure("2") do |config|
mach... |
class Zones < ActiveRecord::Base
has_many :channels
has_many :users
validates :lat, :presence => true
validates :long, :presence => true
end
|
class AlertView
include Capybara::DSL
def message
find('.alert').text.chomp
end
end |
# frozen_string_literal: true
module Growi
module ImageConverter
# Image Markdownとアタッチされた画像を対応させるクラス
class AttachedImageFile
def initialize(markdown_images, attached_file)
@data = attached_file
@markdown_images = markdown_images
end
attr_accessor :data, :markdown_images
... |
class ResponsesController < ApplicationController
before_action :set_response, only: [:show, :edit, :destroy]
before_action :authenticate_user!, only: [:show]
def index
@received_responses = Response.where(response_user_id: current_user.id)
@sent_responses = Response.where(user_id: current_... |
Ohai.plugin(:Mysql) do
provides 'mysql'
depends 'platform', 'platform_family'
def mysql_status
so = shell_out("#{mysqladmin_bin} status")
mysqlstatus = so.stdout.strip
# rubocop:disable Metrics/LineLength
return Hash[mysqlstatus.scan(/(\w+): (\w+)/).map { |(k, v)| [k.downcase.to_sym, v.to_i] }]
... |
class FontMonoisome < Formula
version "0.61"
url "https://github.com/larsenwork/monoid/blob/master/Monoisome/Monoisome-Regular.ttf?raw=true", verified: "github.com/larsenwork/monoid/"
desc "Monoisome"
homepage "https://larsenwork.com/monoid/"
def install
(share/"fonts").install "Monoisome-Regular.ttf"
e... |
require "rails_helper"
RSpec.describe ProjectRole, type: :model do
it { is_expected.to belong_to(:identity) }
it { is_expected.to belong_to(:protocol) }
end
|
class DemoMailer < ActionMailer::Base
default from: "do-not-reply@marketforms.net"
def scheduled_demo(event)
@prospect = event.prospect
@event = event
mail(:to => "sales@marketforms.com", :subject => "A demo has been scheduled! #{event.follow_up.try(:strftime, '%b. %-d %l:%M%P %Z')}")
end
end
|
##code is okay ## array for what a win is
WIN_COMBINATIONS = [
[0,1,2], # Top row
[3,4,5], # Middle row
[6,7,8], # Bottom row
[0,3,6], # Left column
[1,4,7], # Middle column
[2,5,8], # Right column
[0,4,8], # left-to-right diagonal
[6,4,2] # right-to-left diagonal
]
##code is okay ## prints the boa... |
require 'rspec/core/rake_task'
require 'puppet'
require 'yaml'
def get_modules
if ENV['mods']
ENV['mods'].split(',').map { |x| x == 'manifests' ? x : "modules/#{x}" }
else
['manifests', 'modules/*']
end
end
FileList['lib/tasks/*.rake'].each do |rake_file|
import rake_file
end
desc "Run all tests exce... |
module Abaci
class Railtie < Rails::Railtie
initializer "abaci.set_time_zone" do |app|
Abaci.time_zone = app.config.time_zone
end
end
end
|
class Event < ActiveRecord::Base
belongs_to :track
has_and_belongs_to_many :scouts
has_many :heat_groups
# validate :only_one_active_event
validates_presence_of :name
# scope :current_event, where(:active => true)
def has_associated?
self.scouts.count > 0
end
def self.current_event
Event.w... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :update_sanitized_params, if: :devise_controller?
def update_sanitized_params
devise_parameter_sa... |
require 'javaclass/classfile/class_format_error'
module JavaClass
module ClassFile
# The +CAFEBABE+ magic of a class file. This just checks if CAFEBABE is here.
# Author:: Peter Kofler
class ClassMagic # ZenTest SKIP
CAFE_BABE = "\xCA\xFE\xBA\xBE"
# Check the class magic in th... |
module OurTextHelper
def pluralize_upcase(singular)
the_thing = singular.to_s.upcase
return the_thing if ["OTHER", "FRUIT", "SPORT"].include? the_thing # It should be SPORT bar not SPORTS bar
the_thing.pluralize(2).upcase
end
end
ALPHABET = 'ABCDEFGHJKMNPQRSTUVWXYZ'
RANGE = 0..5
class String
def rand... |
require 'rails_helper'
describe Person do
it 'will create a person' do
person = Person.create(title: 'Mrs.', first_name: 'Keri', last_name: 'Clowes')
expect(person).to be_valid
end
it 'will not allow a person with no first name or title to be saved' do
person = Person.create(title: '', first_name: '... |
class Student < ActiveRecord::Base
has_many :grade
accepts_nested_attributes_for :grade
end
|
class ActivitiesController < ApplicationController
def index
@activities = YAML.load_file("#{Rails.root}/config/activities.yml")
end
end
|
class Goal < ActiveRecord::Base
attr_accessible :complete, :content
belongs_to :goal_set
default_scope :order=> 'created_at'
scope :complete, where(:complete => true)
end
|
class Trend < ApplicationRecord
has_many :images
has_many :tweets
has_many :links
end |
class Instruments::LandingsController < ApplicationController
before_action :define_landing, only: [:show, :activate, :update_settings]
before_action :authenticate_user!
before_action :landing_params, only: [:update_settings]
require "will_paginate/array"
def index
@for_free = current_user.free_land_numb... |
class CandidatesController < ApplicationController
def index
@candidates = Candidate.all
end
def show
@candidate = Candidate.find_by_id(params[:id])
end
def create
liar = Candidate.new(race_id: params[:race_id], name: params[:name],
hometown_at: params[:hometown_at], par... |
class CalendarController < ApplicationController
before_action :confirm_logged_in
def interviewData
if authorize([:all])
serveData(:interviews)
end
end
def eventData
if authorize([:all])
serveData(:events)
end
end
def appointmentData
... |
require 'spec_helper'
module Darksky
describe Client do
let(:api_key) { 'api_key' }
let(:client) { Client.new }
it 'initializes with a default configuration' do
client = Darksky::Client.new
expect(client.configuration.api_key).to be_nil
end
it 'initializes with a custom... |
require File.dirname(__FILE__) + '/spec_helper'
describe Blueprints::Configuration do
before do
@config = Blueprints::Configuration.new
end
it "should have filename with default value" do
@config.filename.should == %w{blueprint.rb blueprint/*.rb spec/blueprint.rb spec/blueprint/*.rb test/blueprint.rb te... |
require 'rails_helper'
describe Gift do
context 'associations' do
it 'should belong to menu items' do
should belong_to :menu_item
end
it 'should belong to receiver' do
should belong_to :receiver
end
it 'should belong to giver' do
should belong_to :giver
end
end
cont... |
FactoryBot.define do
factory :brand do
sequence :name do |n|
"brand#{n}"
end
sequence :address do |n|
"#{n} test st"
end
city { "test" }
state { "MA" }
zip_code { "12345" }
phone_number { "123-456-7890" }
website { "https://test.com" }
end
end
|
class CreateJobs < ActiveRecord::Migration
def change
create_table :jobs do |t|
t.string :project_name
t.string :country
t.string :start_date
t.string :end_date
t.text :brief_description
t.text :job_description
t.text :work_information
t.text :skills
t.string ... |
class ApplicationController < ActionController::API
before_action :puts_hi_100_times
def puts_hi_100_times
puts "hi" * 100
end
end
|
module CamaleonCms
class Category < CamaleonCms::TermTaxonomy
alias_attribute :site_id, :term_group
alias_attribute :post_type_id, :status
default_scope { where(taxonomy: :category) }
scope :no_empty, -> { where('count > 0') } # return all categories that contains at least one post
scope :empty, ... |
json.array!(@instagrams) do |instagram|
json.extract! instagram, :id, :image_url
json.url instagram_url(instagram, format: :json)
end
|
module ClinkCloud
class StatusResource < BaseResource
resources do
default_handler do |response|
fail "Unexpected response status #{response.status}... #{response.body}"
end
action :find do
verb :get
path { "/v2/operations/#{account_alias}/status/:id" }
handler(2... |
class ApplicationController < ActionController::Base
protect_from_forgery
include SessionsHelper
def authenticate
if !logged_in?
flash[:warning] = "Please sign in before proceding."
redirect_to login_path
end
end
end
|
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :rememberable, :validatable
# Setup accessible (or protected) attributes for your model
... |
class Album < ActiveRecord::Base
belongs_to :publisher
has_many :songs
validates :name, presence: true, length: { in: 2..50 }
validates :cover_art, presence: true
validates :released_on, presence: true, format: { with: /\A\d{4}-\d{2}-\d{2}\z/, message: "should be in the format YYYY-MM-DD" }
validates :pu... |
# I worked on this challenge [by myself, with: ].
# This challenge took me [#] hours.
# Pseudocode
# 1. Define a method super_fizzbuzz which takes an array for an argument.
# 2. Create an array to put in fizzbuzzed array.
# 3. Iterate each element of the array to see if they are divisible 3,5, or 15.
# 4. For element... |
class Beacon < ApplicationRecord
#include Mongoid::Document
validates_uniqueness_of :name, :unique_reference
belongs_to :store
has_many :advertisements
# Method to search by Beacon Name
def self.filter_by_name(text)
joins("INNER JOIN stores ON stores.id = beacons.store_id").where("(LOWER(stores.name)... |
class AddUserTimezone < ActiveRecord::Migration
def change
add_column :users, :timezone, :string, limit: 255, default: "UTC"
end
end
|
module Bowline::Generators
class BinderGenerator < NamedGenerator
desc <<-DESC
Generates a new binder.
DESC
alias :plain_class_name :class_name
def class_name
super + "Binder < Bowline::Binders::#{bind_type.capitalize}"
end
def bind_name
plain_class_name.singularize... |
class IssuesController < ApplicationController
def update_sort_order
target_obj = Issue.find(params[:target_id])
target_obj.relative_sort(params[:anchor], params[:anchor_id])
head 200
end
def create
# Validate input
error_messages = []
error_messages << "A title must be provided." if pa... |
json.user do
json.extract! @user,
:id,
:username,
:description,
:email,
:country,
:city,
:websiteURL,
:instagram,
:facebook,
:twitter
if @user.banner_image.attached?
json.bannerImage url_for(@user.banner_image)
else
json.banner_image nil
end
if @user.user_photo.attached?
... |
class CreateSpecialAbilities < ActiveRecord::Migration[5.1]
def change
create_table :special_abilities do |t|
t.string :name
t.text :desc
t.integer :attack_bonus
t.string :damage_dice
t.integer :damage_bonus
t.integer :attack_bonus
end
create_join_table :special_abiliti... |
class ChangeVariantidType < ActiveRecord::Migration
def change
change_column :variants, :shopify_variant_id, :bigint
end
end
|
# frozen_string_literal: true
module GraphQL
module StaticValidation
module VariableNamesAreUnique
def on_operation_definition(node, parent)
var_defns = node.variables
if var_defns.any?
vars_by_name = Hash.new { |h, k| h[k] = [] }
var_defns.each { |v| vars_by_name[v.name]... |
module Rosarium
class SimplePromise
def self.defer
promise = new
resolver = promise.method :resolve
rejecter = promise.method :reject
class <<promise
undef :resolve
undef :reject
end
Deferred.new(promise, resolver, rejecter)
end
def initialize
... |
class Order < ApplicationRecord
belongs_to :user
has_many :dishs, through: :cart_items
has_many :cart_items, dependent: :destroy
validates :delivery_type, :payment_type, presence: true
DELIVERY_TYPES = ["Courier(DPD)", "Personal collection", "InPost"]
PAYMENT_TYPES = ["Cash On Delivery", "Bank Transfer", ... |
# frozen_string_literal: true
Rails.application.routes.draw do
devise_for :users
devise_for :lockable_users, # for testing authy_lockable
class: 'LockableUser',
:path_names => {
:verify_authy => "/verify-token",
:enable_authy => "/enable-two-factor",
:verify_authy_installation => "/verify... |
class Question < ActiveRecord::Base
has_many :categories
has_many :question_types
end
|
class FontOfficeCodePro < Formula
version "1.004"
sha256 "9e24d15309ead8c523ec3f0444ed9c171bba535e109c43b1dde8abfa9d359150"
url "https://github.com/nathco/Office-Code-Pro/archive/#{version}.zip"
desc "Office Code Pro"
homepage "https://github.com/nathco/Office-Code-Pro"
def install
parent = File.dirname... |
class ModifyAgainEmails < ActiveRecord::Migration
def self.up
rename_column(:emails, :is_blind, :is_default)
add_column :emails, :comment, :string
remove_column :emails, :is_friendly
end
def self.down
end
end
|
class OfferingsController < ApplicationController
# returns json, to be rendered via ajax
def search_results
logger.debug "==================================="
query = params[:query] || {}
logger.info "QUERYING IN ENVIRONMENT: #{ENV['RAILS_ENV']}"
# process the groups
[:distrib, :wcult, :time... |
require_relative './chemical_databank'
# This is the adapter class
class RichCompound < Compound
private
attr_accessor :databank
public
def initialize(name)
super name
@databank = ChemicalDatabank.new
@boiling_point = @databank.get_boiling_point(@compound_name)
@melting_point = @databank.ge... |
class AddPopulationToStateAndCounty < ActiveRecord::Migration[6.1]
def change
add_column :counties, :population, :integer
add_column :states, :population, :integer
end
end
|
module PdfTempura
module Render
module Debug
class TableAnnotation < OutsideAnnotation
private
def box_color
"66CCFF"
end
def transparency
0.20
end
end
end
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :is_signed_in
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
# how to apply application level check: https://github.com/plataformatec/devise#contr... |
require 'rails_helper'
describe City do
it { should have_many(:dashboard_cities) }
it { should have_many(:dashboards) }
it { should belong_to(:hour) }
describe 'set_home' do
let(:cities) { create_list(:city, 5) }
it 'set self true home ' do
city = cities.first
city.set_home
expect... |
require "rails_helper"
RSpec.describe AdPlansController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/ad_plans").to route_to("ad_plans#index")
end
it "routes to #new" do
expect(:get => "/ad_plans/new").to route_to("ad_plans#new")
end
it "routes t... |
class Task < ActiveRecord::Base
attr_accessible :assigned_to, :completed_by, :completed_on, :created_by, :description, :due_date, :task_status_id, :title, :updated_by
validates :title, :presence => true, :length => { :minimum => 1 }
belongs_to :status, :class_name => "TaskStatusType", :foreign_key => 'task_status_id... |
# == Schema Information
#
# Table name: songs
#
# id :integer not null, primary key
# name :string
# genre_id :integer
# difficulty :integer
# artist_id :integer
# created_at :datetime not null
# updated_at :datetime not n... |
# frozen_string_literal: true
require "bundler/setup"
require "dotenv/load"
require "beyond_api"
require "factory_bot"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `M... |
module HubClient
class Action
attr_reader :api
attr_reader :path
def initialize(api, path)
@api = api
@path = path
end
def invoke(params)
api.post("/api/invoke/#{path}", params.to_json)
end
end
end
|
class Relationship < ActiveRecord::Base
belongs_to :follower, class_name: "User"
belongs_to :being_followed, class_name: "Event"
end
|
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
# Adapted from the Homebrew installer: http://brew.sh
SF_PREFIX = '/Library/Fonts'
SF_REPO = 'https://github.com/supermarin/YosemiteSanFranciscoFont'
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; bold 31; ... |
FactoryGirl.define do
factory :invitation do
email { Faker::Internet.email }
end
end |
require "test_helper"
class TestResolve < Test::Unit::TestCase
def setup
@env = Sprockets::Environment.new(File.expand_path(File.dirname(__FILE__)))
@env.append_path("fixtures/javascripts")
end
def test_resolve_eco_jst_from_coffeescript
content_type = content_type_for("view.coffee")
uri, _ = @e... |
include_recipe "zend-server::server"
package "curl"
execute "Installing composer" do
command "curl -s https://getcomposer.org/installer | /usr/local/zend/bin/php && mv composer.phar /usr/local/bin/composer"
action :run
not_if { ::File.exists?("/usr/local/bin/composer") }
end
|
require 'spec_helper'
describe "Courses and Lessons Pages" do
subject {page}
before do
courses = FactoryGirl.create_list(:course, 3, :is_active => true)
courses += FactoryGirl.create_list(:course, 4, :is_active => false)
sections = []
courses.each do |course|
5.times do
sections << ... |
class Train < ApplicationRecord
validates_presence_of :number
has_many :reservations
SEATS = begin
(1..6).to_a.map do |series|
["A", "B", "C"].map do |letter|
"#{series}#{letter}"
end
end
end.flatten
def available_seats
# ["1A", "1B", "1C", "1D", "1F"]
# TODO: 回传有空的座位,这里先暂时固定回... |
class SessionsController < ApplicationController
def new
end
def guest
user = User.find_by(email: "password")
login! user
redirect_to '/app/start'
end
def create
user = User.find_by_credentials(*user_params)
if user
login! user
redirect_to '/app/start'
else
flash.no... |
# frozen_string_literal: true
module Vedeu
module Input
# Stores each keypress or command to be retrieved later.
#
module Store
extend self
extend Vedeu::Repositories::Storage
# {include:file:docs/dsl/by_method/add_command.md}
# @param command [Symbol|String]
# @return [... |
require './db_setup.rb'
class TimeOnTasksMigration < ActiveRecord::Migration
def change
create_table :time_on_tasks do |t|
t.integer :project_id
t.integer :developer_id
t.float :time_spent
t.date :worked_on
end
end
end
|
# encoding: utf-8
class ContestAttachmentUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"assets/media/#{model.class.to_s.underscore}/#{m... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# Exercício 04
puts "Sabendo que:"
puts "1) O diâmetro de um círculo é 2x o seu raio."
puts "2) O comprimento de um círculo é seu diâmetro vezes o valor da constante matemática PI (3.1415...)"
puts "3) A área de um círculo é seu raio ao quadrado vezes o valor da constante matemática PI (3.1415...)"
puts
puts "Escreva ... |
class AddUserReferencesToWritings < ActiveRecord::Migration
def change
add_reference :writings, :user, index: true
end
end
|
require 'date'
require 'pg'
class Connection
attr_accessor :postgres, # the connection resulting from the connection string
:address, #
:port, #
:dbname, # connection string
:user, #
... |
class AddImageMetaToUsers < ActiveRecord::Migration
def change
add_column :users, :image_filename, :string
add_column :users, :image_size, :integer
add_column :users, :image_content_type, :string
end
end
|
class UsersController < ApplicationController
skip_before_action :authorize, only: [:create]
include ActionController::MimeResponds
def index
users = User.all
render json: users
end
def create
user = User.create!(user_params)
session[:user_id] = user.id
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe AdMediumSearchForm, type: :model do
describe 'attributes' do
subject(:search_form) { described_class.new }
describe '#name' do
it '呼べること' do
expect(search_form).to be_respond_to :name
end
end
end
describe '#sea... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.