text
stringlengths
10
2.61M
class SecretNumber # this class will generate our secret number for us attr_accessor :secret_number def initialize @secret_number = rand(1...10) end end
module Cloudpassage class FileIntegrityPolicies < Base def type 'fim_policies' end end end
module RHQ class Client def operation_definitions(id) http_get("/operation/definitions?resourceId=%s" % id) end def operation_create(op_def_id,resource_id) http_post("/operation/definition/#{op_def_id}?resourceId=#{resource_id}",{}) end def operation_schedule(draft) http_put("/...
class Api::V1::UsersController < Api::V1::BaseController # skip_before_action :verify_authenticity_token before_action :logged_in_user_filter, only: [:show] before_action :correct_user_filter, only: [:show, :update, :destroy] before_action :admin_user_filter, only: [:index ] # GET /api/v1/use...
module API module V1 class BaseController < ApplicationController # before_action :destroy_session rescue_from ActiveRecord::RecordNotFound, with: :record_not_found rescue_from ActiveFedora::RecordInvalid, with: :record_invalid # rescue_from Rack::QueryParser::InvalidParameterError, with:...
require 'bio' class Gene < ActiveRecord::Base def sequence f = Bio::FastaFormat.new(self.fasta_file) return f.seq end end
# Read about factories at http://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :task do description "My description" estimated_time 2 initial_estimated_time 3 worked_hours 4 hours_to_finish 0 feature end end
require 'base' class JRuby < Ruby homepage 'http://www.jruby.org/' url 'http://jruby.org.s3.amazonaws.com/downloads/1.6.2/jruby-bin-1.6.2.tar.gz', :as => 'jruby-1.6.2.tar.gz' md5 'a46f978c24a208717023bb4b8995c678' name 'ruby-jruby' section 'interpreters' version '1.6.2' description 'The JRuby Ruby virtu...
FactoryBot.define do factory :user do email {"a@a.com" } trait :with_profile do association :profile, :with_feed end end end
class AddTopIdToOutfits < ActiveRecord::Migration def change add_column :outfits, :top_id, :integer add_foreign_key :outfits, :tops add_column :outfits, :pant_id, :integer add_foreign_key :outfits, :pants add_column :outfits, :shoe_id, :integer add_foreign_key :outfits, :shoes end end
class TraktApi include HTTParty base_uri 'api.trakt.tv' def self.find_show(show) if show.genre == 'TV Shows' get("/search/shows.json/#{ENV['TRAKT_API_KEY']}", query: {query: "#{show.title}"}) else get("/search/movies.json/#{ENV['TRAKT_API_KEY']}", query: {query: "#{show.ti...
require 'http' module TalkUp class ApiGateway class ApiResponse HTTP_STATUS = { 200 => :ok, 201 => :created, 202 => :processing, 204 => :no_content, 403 => :forbidden, 404 => :not_found, 400 => :bad_request, 409 => :conflict, ...
def palindrome_count(n, b) sequence = (1...n).inject([0, 0]) do |seq, i| k = 1 + i/2 seq << b * seq[i] + b**k - seq[k] end sequence.last end def nonpalindrome_count(n, b) return 0 if n == 0 b**n - palindrome_count(n,b) end
Gem::Specification.new do |s| s.name = 'sneaql-aws' s.version = '0.0.4' s.date = '2017-10-02' s.summary = "sneaql extensions to interact with AWS" s.description = "provides extensions to sneaql allowing interaction with AWS" s.authors = ["jeremy winters"] s.email = 'jeremy....
1.upto(gets.to_i) do |case_number| n, m = gets.split.map(&:to_i) existing_directories = Array.new 1.upto(n) do existing_directories << gets.chomp end need_to_create_directories = Array.new 1.upto(m) do need_to_create_directories << gets.chomp end mkdir_commands_needed = 0 need_to_create_d...
require 'spec_helper' describe Game do describe "#self.init_recent_game", :recent => :true do let(:data) do summoner = Elophant::Summoner.new @summoner_name = 'wingsofdeathx' @summoner_id = 19660288 @account_id = 32354173 data = VCR.use_cassette "elophant/recent_games/#{@account_id}...
ActiveAdmin.register_page "Dashboard" do menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") } page_action :add_feed, method: :post do Feed.create(message: "Generated Feed") redirect_to admin_dashboard_path, notice: "Feed was added" end action_item :add do link_to "Generate Feed", admi...
class CreateTestDetails < ActiveRecord::Migration[6.0] def change create_table :test_details do |t| t.integer :test_id, foreign_key: true t.integer :question_id, foreign_key: true t.integer :answer_id, foreign_key: true t.integer :result t.timestamps end end end
module Byebug # # Common parent class for all of Byebug's states # class State attr_reader :interface def initialize(interface) @interface = interface end end end
class MusicLibraryController def initialize(path = './db/mp3s') @path = path @music_library = MusicImporter.new(path).import end def call puts "Welcome to your music library!" input = nil until input == "exit" puts "To list all of your songs, enter 'list songs'." puts "To list a...
class NQueens attr_accessor :board def initialize(n) @board = Array.new(n) { Array.new(n) } @size = n @solutions = 0 @iterations = 0 put_queen(0) display_stats end def put_queen(row) @size.times do |i| @iterations += 1 if is_valid?([row, i]) @board[row][i...
class BreweriesController < ApplicationController before_action :find_brewery, only: [:show, :edit, :update, :destroy] def index @breweries = Brewery.all.order("name ASC") end def show @review = Review.new end def new @brewery = Brewery.new end def create @brewery = Brewery.new(brewe...
require 'test_helper' class ReviewsControllerTest < ActionDispatch::IntegrationTest # test "the truth" do # assert true # end def setup @email = 'hoge@email.com' @user = User.new(name: 'hoge', nickname: 'hogechan', email: @email, password...
class Api::V1::MicropostSerializer < ActiveModel::Serializer embed :ids attributes :id, :content, :picture, :created_at, :updated_at has_one :user def picture object.picture.url end end
include_recipe 'newrelic::server_monitor_agent' # Adds the user +newrelic+ to the group +docker+ to enable New Relic Docker Server Monitoring. # This assumes that the New Relic Server Monitoring recipe +newrelic::default+ has been run before and therefore the # user +newrelic+ already exists. # # Refer to the New Reli...
class Micropost < ActiveRecord::Base attr_accessible :content, :user_id belongs_to :user validates_presence_of :user_id, :content validates_length_of :content, :maximum => 140 default_scope order: 'microposts.created_at DESC' end
class Product < ApplicationRecord belongs_to :customer belongs_to :product_type has_many :order_product has_many :orders, through: :order_product end
class Recipe < ActiveRecord::Base has_many :ingredients, through: :recipe_ingredient_instance has_many :recipe_igredient_instances end
# rubocop:disable Metrics/AbcSize require 'date' class Lesson1 def sum(val = 0) sum = 0 val.to_s.split('').each { |el| sum += el.to_i } sum end def age(birthday) return 'Invalid Date Format' if birthday.to_s.empty? days = (Date.today - Date.strptime(birthday.tr('/', ''), '%d%m%Y')).to_i (...
class Order < ActiveRecord::Base has_many :order_items has_many :items, through: :order_items belongs_to :user, :touch => true belongs_to :restaurant, :touch => true def self.pending where(status: "pending") end def self.find_or_create_new(id) if id Order.find(id) else Order.new ...
class Favorite < ActiveRecord::Base attr_accessible :user_id, :gist_id belongs_to :user belongs_to :gist validates :user_id, :uniqueness => { scope: :gist_id } validates :gist_id, :presence => true end
# frozen_string_literal: true RSpec.describe Api::V1::ChangePassword::CreateSchema do describe 'attributes' do describe 'token' do def schema(token) described_class.call(password: '123456', password_confirmation: '123456', token: token) end it { expect(schema(SecureRandom.hex)).to be_s...
# The networking retrieval for public and private side data is based on # SoftLayer's implementation of local and public interfaces as well as bonded # interfaces. This will need to be tweaked to work with outside network # implementations. require 'ohai' ohai_system = Ohai::System.new ohai_system.all_plugins ohai_sy...
require 'test_helper' # bundle exec ruby -Itest test/jobs/send_daily_notifications_job_test.rb class SendDailyNotificationsJobTest < ActiveJob::TestCase describe "when the project no longer exists" do before do @deleted_project_id = projects(:one).id projects(:one).destroy end test "no notif...
begin # 0.x name require 'zip/zipfilesystem' FILESYSTEM = Zip::ZipFile # Patch the zip for invalid Linux file system flags found in some JARs. module Zip # :nodoc:all class ZipEntry # uncomment next method to avoid swallowing errors, else we get +nil+ entries later. # def ZipEntry.read_c_dir_entry(io)...
class RemoveDayFromWorkoutGroup < ActiveRecord::Migration[5.1] def change remove_column :workout_groups, :day end end
class CommentMailer < ActionMailer::Base def comment_creation_email(comment, user) @comment = comment @user = user rel = DocumentUserRelation.find_by_document_id_and_user_id(comment.document.id, user.id) @url = code_url(rel.code) headers "Message-ID" => comment.message_id('create', user), ...
class UsersController < ApplicationController before_action :authenticate_user!, only: [:show] before_action :set_user, only: [ :show] before_action :set_search def show @conversations = Conversation.all @sold_courses = Course.where(:user_id => @user.id) end private def set_user @user = User....
#This file tells Rails how to connect #incoming requests to controllers and actions Rails.application.routes.draw do get 'users/new' get 'welcome/index' #this line gives us a new article path #a post to create articles, an edit article path #a patch to update articles,delete, show, and index resources :articles d...
require "vagrant/util/counter" require "log4r" module VagrantPlugins module DSC # The "Configuration" represents a configuration of how the DSC # provisioner should behave: data directories, working directory, # DSC Manifests etc. class Config < Vagrant.plugin("2", :config) extend Vagrant::Util...
class DeviceToken < ActiveRecord::Base belongs_to :user attr_accessible :device_token, :user_id end
require 'pry' require_relative 'player' class Game < HumanPlayer attr_accessor :human_player, :enemies def initialize(human_player) user = HumanPlayer.new(human_player) @human_player = user @enemies = [bot = Player.new("bot")]*4 end def kill_player @enemies.each do |bot| if bot.life_poi...
#1. arr = (15..20).to_a # a) puts "Aufgabe 1. a)" arr.each { |item| puts item } puts "______________________________\n" # b) puts "Aufgabe 1. b)" arr.map.with_index { |x, i| puts "Index: #{i} - Wert: #{x}" } puts "______________________________" puts "" # c) hash = Hash[arr.map { |x| [x, y = rand(100..200)]}] # ...
class AddFeaturesToProduct < ActiveRecord::Migration[6.0] def change add_column :refinery_caststone_products, :tag_line, :string, if_not_exists: true add_column :refinery_caststone_products, :summary, :text, if_not_exists: true add_column :refinery_caststone_products, :features, :text, if_not_exists: true...
# encoding: ascii-8bit require_relative '../spec_helper' include Bitcoin::Builder include Bitcoin::Blockchain include Bitcoin::Blockchain::Validation Bitcoin.network = :regtest [ [:archive, :sqlite], [:utxo, :sqlite, index_all_addrs: true, utxo_cache: 0], [:archive, :postgres], [:utxo, :postgres, index_all_...
RSpec.describe 'Dashboard' do let(:admin_user) { create :admin_user } before { sign_in(admin_user) } it 'shows dashboard' do visit '/admin' expect(find('#page_title')).to have_content('Dashboard') end end
# frozen_string_literal: true require 'rails_helper' RSpec.describe ReleaseReservationJob do describe 'perform' do let(:event) { create :event } let(:user) { create :user } let(:reservation) { create :reservation, event: event, user: user, state: state } before do create :ticket,...
class User < ActiveRecord::Base has_many :adoption_requests has_many :plantings has_many :maintenance_records has_many :notes # add authlogic acts_as_authentic do |c| # perishable tokens expire after 2 hours c.perishable_token_valid_for( 7200 ) c.logged_in_timeout = 3.days end validates :f...
class Movie < ApplicationRecord has_many :directors, through: :movie_directors has_many :movie_directors has_many :performers, through: :movie_performers has_many :movie_performers has_many :genres, through: :movie_genres has_many :movie_genres has_many :movie_subscriptions end
#!/usr/bin/env ruby -W require 'rubygems' require 'bcdatabase/commands' module Bcdatabase::Commands UTILITY_NAME = File.basename(__FILE__) end ###### MAIN command = ARGV.shift unless command $stderr.puts "Please specify a command." $stderr.puts Bcdatabase::Commands.help exit(1) end klass = Bcdatabase::Comm...
class ProfileController < ApplicationController def show @profile = profile @other_user = User.find(@profile.user_id) end def edit @profile = profile end def index if params[:query].present? @all_profiles ||= ProfileSearcher.new( query: params[:query] ).run else ...
require 'git' require 'github/markup' require 'active_gist' module Mist require 'mist/engine' require 'mist/configuration' require 'mist/repository' require 'mist/version' require 'mist/permalink' require 'mist/git_model' require "mist/code_example_parser" extend Mist::Configuration extend Mist::R...
class PipelineAggregator::Jenkins < PipelineAggregator::Base def initialize(config_data, datastore) @config_data = config_data # TODO Validate config file is correct @datastore = datastore # Create data dirs if it doesn't exist end def get_jenkinsmaster(jenkins_master) master = @config_da...
class AddCommentDayToTalks < ActiveRecord::Migration[5.1] def change add_column :talks, :comment_day, :string add_column :talks, :comment_user, :string remove_column :talks, :user_id, :integer remove_column :talks, :sport_id, :integer end end
require 'rails_helper' feature 'Identity removes a Procedure', js: true do let!(:protocol) { create_and_assign_protocol_to_me } let!(:participant) { protocol.participants.first } let!(:appointment) { participant.appointments.first } let!(:services) { protocol.organization.inclusive_child_services(:per_p...
require "user" class TweetsController < ApplicationController before_filter :find_user before_filter :find_tweet, except: [:index, :new, :create] crudable_filter parent: "user" # GET /:user_id/tweets # GET /:user_id/tweets.json def index @tweets = @user.tweets.all respond_to do |format| form...
# frozen_string_literal: true class Resolvers::HelloWorldResolver < Resolvers::BaseResolver description "Returns hello world" type String, null: false def resolve "Hello World" end end
class CreateSubscriptionCommand include ActiveModel::Model include ActiveEvent::Command form_name 'Subscription' attributes :user_id, :email, :topic_id end
class Player def health_check(last_health, current_health, warrior) if last_health > current_health # loosing health if current_health < 15 # low health warrior.walk! @direction_reverse #backup before healing else warrior.walk! @direction #charge forward and fight! end else ...
require 'test_helper' class UsersSignupTest < ActionDispatch::IntegrationTest test "valid signup information" do get signup_path name = "Example User" email = "user@example.com" password = "password" assert_difference 'User.count', 1 do post_via_redirect users_path, user: { name: name, ...
module Batsd # # Handles timer measurements ("|c") # # Timer measurements are aggregated in various ways across # aggregation intervals # class Handler::Timer < Handler # Handle the key, value, and sample rate for a timer # # Store timers in a hashed array (<code>{a: [], b:[]}</code>) and ...
class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable # devise :database_authenticatable, :registerable, # :recoverable, :rememberable, :validatable devise :database_authenticatable, :recoverable, :re...
class Ability include CanCan::Ability def initialize(user) # Define abilities for the passed in user here. For example: # user ||= User.new # guest user (not logged in) # can [:manage], :all do |item| # user.email=='dsmithco@gmail.com' # end can [:read], [Page, Website, Category] do...
# frozen_string_literal: true require 'rails_helper' include(ScoreHelper) RSpec.describe GamePointGiver do let(:gp) { GamePointGiver.new } let!(:tom) { create(:user, nickname: 'tom', ladder_games_lost: 0, ladder_games_won: 0) } let!(:alan) { create(:user, nickname: 'alan', ladder_games_lost: 0, ladder_games_won...
require 'test_helper' class LunchMenuItemsControllerTest < ActionDispatch::IntegrationTest setup do @lunch_menu_item = lunch_menu_items(:one) end test "should get index" do get lunch_menu_items_url assert_response :success end test "should get new" do get new_lunch_menu_item_url assert_...
class State < ActiveRecord::Base belongs_to :country has_many :presidents end
## # $Id: rpc_cmsd_opcode21.rb 8426 2010-02-09 04:15:15Z jduck $ ## ## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # Framework web site for more information on licensing and terms of use. # http://metasploit.com/projects/...
# Misc utilties to do data conversion from Hipchat to Mattermost module Hipmost module Conversion def self.convert_formatting_to_markdown(message) # According to Hipchat's docs, the only formatting commands which are # translatable to Mattermost are /code and /quote. # Relevant docs: https://co...
#!/usr/bin/env ruby =begin |-+. = Walls (all mean the same) R = Ring (Treasure) K = Key E = Exit H = Hero (Entrance, an SafeSpot) L = Locked Gate (needs Key) P = Pivot (center) of a door. D = Door Segment N = Snake =end require 'pp' require 'erb' def parse_file(level_filename) level = { map: [], ...
# coding: utf-8 class AddWorkerIdToAppointments < ActiveRecord::Migration def change add_column :appointments, :worker_id, :integer Appointment.reset_column_information Organization.all.each do |organization| if organization.workers.count.zero? organization.workers.create(name: 'по умолчанию...
module Api module V1 class VersionsController < ApplicationController before_action :authorize_editor! def create version = Version.new(version_params) version.script = current_script version.editors.push(current_editor) if version.save return render json: { ...
# == Schema Information # # Table name: ads # # id :integer not null, primary key # name :string # column :integer # row :integer # page_columns :integer # publication_id :integer # created_at :datetime not null # updated_at :datetime n...
module Reportable extend ActiveSupport::Concern ## *** GENERAL *** ## ## *** BALANCE SHEET *** ### def current_assets self.accounts.where(account_type: "cash") end def fixed_assets self.accounts.where(account_type: "fixed_assets") end def current_liabilities self.accounts.where(account_t...
# Rotation (Part 3) # If you take a number like 735291, and rotate it to the left, you get 352917. If you now keep the first digit fixed in place, and rotate the remaining digits, you get 329175. Keep the first 2 digits fixed in place and rotate again to 321759. Keep the first 3 digits fixed in place and rotate again ...
class Maze < ApplicationRecord before_save :default_values def default_values self.difficulty ||= 5 # byebug end belongs_to :player end
require 'spec_helper' describe Jekyll::Gitlab::Letsencrypt::Configuration do before { allow(Jekyll).to receive(:configuration).with({}).and_return config } let(:config) { {'gitlab-letsencrypt' => plugin_config} } let(:plugin_config) { {} } describe '#valid?' do subject { described_class } co...
class Message < ActionMailer::Base def hello(contact,attachment) @contact = contact unless attachment.blank? then attachments[attachment.original_filename] = { :content => attachment.read, :transfer_encoding => :binary } end mail( from: @contact.user_name, ...
module Simplepay ## # This is a base class from which to inherit functionality for all Amazon # Simple Pay services (Subscriptions, Marketplace Buttons, etc.) # # === Required Fields # # The following fields are required for all Simple Pay services: # # access_key:: Your Amazon Web Service (AWS)...
require './f5' require 'optparse' require 'pp' require 'ostruct' class Optparser LB_METHODS = %w[LB_METHOD_GLOBAL_AVAILABILITY LB_METHOD_TOPOLOGY] LB_METHOD_ALIASES = { "ga" => "LB_METHOD_GLOBAL_AVAILABILITY", "topology" => "LB_METHOD_TOPOLOGY"} def self.parse(args) options = OpenStruct.new opts = Opt...
# frozen_string_literal: true module Decidim module Opinions # A command with all the business logic when a user creates a new opinion. class CreateOpinionExport < Rectify::Command # Public: Initializes the command. # # form - A form object with the params. # current_user - Th...
require_relative '../test_helper' describe "Webfinger" do include TestHelper describe "#find_user" do before do @user = Fabricate(:user) end it "returns nil if it can't find the user" do refute Webfinger.find_user("acct:nada@rstat.us") end it "can find the user with acct:username...
# encoding: utf-8 # # © Copyright 2013 Hewlett-Packard Development Company, L.P. # 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 #...
module MedicalEntities class BloodAlertsController < ApplicationController before_action :set_blood_alert, only: [:show, :edit, :update, :destroy] # GET /medical_entities/blood_alerts # GET /medical_entities/blood_alerts.json def index @blood_alerts = BloodAlert.all end # GET /medical_...
class DatabankMailer < ActionMailer::Base default from: "databank@library.illinois.edu" def confirm_deposit(dataset_key) @dataset = Dataset.where(key: dataset_key).first subject = prepend_system_code("Illinois Data Bank] Dataset successfully deposited (#{@dataset.identifier})") if @dataset to_...
require 'test_helper' class GlycemiesControllerTest < ActionController::TestCase setup do @glycemy = glycemies(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:glycemies) end test "should get new" do get :new assert_response :success ...
module AlgoSDK class SuggestedParams "" " Contains various fields common to all transaction types. Args: fee (int): transaction fee (per byte if flat_fee is false). When flat_fee is true, fee may fall to zero but a group of N atomic transactions must st...
module FogTracker # Tracks one or more Fog accounts and exposes a {#query} on the results class Tracker #a Hash of account information (see accounts.example.yml) attr_reader :accounts # Creates an object for tracking multiple Fog accounts # @param [Hash] accounts a Hash of account information ...
require 'spec_helper' describe LolApi::Champion do before do @champion = FactoryGirl.build(:champion) end subject { @champion } it { should be_kind_of(LolApi::Champion)} it { should respond_to(:id) } it { should respond_to(:name) } it { should respond_to(:title) } it { should respond_to(:sta...
# Problem 292: Pythagorean Polygons # http://projecteuler.net/problem=292 # We shall define a pythagorean polygon to be a convex polygon with the following properties:there are at least three vertices, # no three vertices are aligned, # each vertex has integer coordinates, # each edge has integer length.For a given i...
require 'rails_helper' RSpec.describe "Quiz Queries" do before{ prepare_query_variables({}) prepare_context({}) @course = create(:course) 3.times do create(:quiz, course_id: @course.id) end } describe Queries::Quizzes do context 'when there are 3 quizzes in t...
require "selenium-webdriver" require 'webdriver-user-agent' class CuttlefishWebdriver < SimpleDelegator def initialize chrome_shim_path = ENV.fetch('GOOGLE_CHROME_SHIM', nil) options = Selenium::WebDriver::Chrome::Options.new if chrome_shim_path.nil? options.add_argument('--headless') option...
class Email::Domain < ActiveRecord::Base has_many :users, class_name: 'Email::User' has_many :aliases, class_name: 'Email::Alias' validates :name, presence: true validates :name, uniqueness: true end
# require modules here require 'yaml' def load_library(filepath) all_emoticons = YAML.load_file(filepath) emoticons = {:get_meaning=>{},:get_emoticon=>{}} # Add keys and values to get_meaning hash all_emoticons.map do |values| japanese_emoticon = values[1][1] english_meaning = values[0] emoticon...
require 'validatable' require 'digest/sha1' require 'tempfile' require 'schemastron' include Schemastron module Validity # Do all files in the descriptors exist in the package? def files_exist? p = package_path files.each do |f| fp = File.join(p, f[:path]) errors.add :completeness, "#{f...
class ReminderAttachmentsController < ApplicationController before_filter :login_required filter_access_to :all def download reminder_attachment=ReminderAttachment.find(params[:id]) send_file reminder_attachment.attachment.path, :type => reminder_attachment.attachment_content_type, :disposition => 'inline...
class CreateTeamGroupStatistic < ActiveRecord::Migration def change create_table :team_group_statistics do |t| t.references :team, index: true t.integer :games_played t.integer :games_won t.integer :games_lost t.integer :games_draw t.timestamps end end end
require 'baton' require 'bunny' require 'json' module Baton class API # Public: Method that publishes a message to an exchange. # # message - a json object containing the message # key - the routing key used to forward the message to the right queue(s) # # Examples # # publish("{\"...
module API module V1 class Notifications < API::V1::Base before do authenticate_user end namespace :notifications do desc 'List all notifications' get do total_unread = current_user.notifications.where(read: false).count notifications = paginate curr...
class User < ActiveRecord::Base validates :first_name, presence: true validates :email, presence: true validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create validates :first_name, length: { maximum: 26 } validates :first_name, length: { minimum: 3 } has_secure_password...
class SermonsController < ApplicationController def index @sermons = Sermon.all end def new @sermon = Sermon.new(sermon_params) end def create @sermon = Sermon.new(create_sermon_params) @sermon.save redirect_to @sermon end def show @sermon = Sermon.find(params[:id]) end pri...