text
stringlengths
10
2.61M
class UserAddressesController < ApplicationController include SetUser include UserConfirmation include UserSignedIn before_action :user_signed_in before_action :set_user before_action :user_confirmation # 配送先住所編集機能 def update @address = @user.address if @address.update(user_address_param...
# frozen_string_literal: true module GraphQL module Types class String < GraphQL::Schema::Scalar description "Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text." def self.coerce_result(value, ctx) str = va...
################################### # # This method creates an additional disk and attaches it to the VM # # Copyright (C) 2016, Christian Jung # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, ei...
require 'spec_helper' bool_options = [true, false] describe 'secure_linux_cis::redhat7::cis_1_1_4' do on_supported_os.each do |os, os_facts| bool_options.each do |option| context "on #{os}" do let(:facts) do os_facts.merge( 'mountpoints' => { '/tmp' => { ...
class MoreDefaultValueChanges < ActiveRecord::Migration def change change_column_default(:users, :points, 0) change_column_default(:users, :all_bets, 0) change_column_default(:users, :curr_bets, 0) change_column_default(:users, :won_bets, 0) change_column_default(:users, :lost_bets, 0) remove_column...
class Project < ApplicationRecord has_many :tasks validates_presence_of :name, :description end
# -*- coding: utf-8 -*- # # Author:: lnznt # Copyright:: (C) 2011 lnznt. # License:: Ruby's # require 'yaml' require 'gmrw/extension/all' module GMRW; module SSH2 class << self ; property :config ; end module Server; module Config include GMRW extend self property_ro :default, 'Hash.new{{}}.merge(YAM...
class NewsController < ApplicationController def index @news = News.paginate :per_page => 3, :page => params[:page], :order => 'created_at DESC' end end
module Dotpkgbuilder class Builder def initialize(options = {}) @context = Context.new(options) end def build(package_name, version) @context.package_name = package_name @context.version = version distribution = Distribution.new(@context) distribution.run end end end...
module Obfuscator class Generic class UnkownObfuscationTypeError < StandardError; end attr_accessor :model, :columns def scrub!(model_name = "User", columns = []) @model = model_name.singularize.constantize if columns.is_a?(Hash) store_types_from_column_values(columns) @colu...
class HostelsController < ApplicationController before_filter :login_required filter_access_to :all,:except => [:student_hostel_details] filter_access_to [:student_hostel_details], :attribute_check => true, :load_method => lambda { Student.find(params[:id]) } before_filter :set_precision before_filter :protec...
class ChangeTypeToInt < ActiveRecord::Migration def down remove_column :changes, :type end end
# Base class for scenes module SDC class Scene # Methods for internal stuff, don't change these if inherited def initialize at_init end def main_update update end def main_draw SDC.window.clear draw if SDC.window.imgui_defined? then SDC.window.imgui_update draw_imgui end ...
class CreateScheduleTagRelations < ActiveRecord::Migration[5.1] def change create_table :schedule_tag_relations do |t| t.references :schedule, foreign_key: true, type: :integer t.references :tag, foreign_key: true t.timestamps end end end
class CreateTableEntitiesTags < ActiveRecord::Migration def self.up create_table :entities_tags, :id => false do |t| t.integer :entity_id t.integer :tag_id end add_index :entities_tags, :entity_id add_index :entities_tags, :tag_id end def self.down remove_index :entities_tags, :en...
class Billboard < ActiveRecord::Base outpost_model include Schedulable include StatusMethods include PublishedScope include AutoPublishedAt include PostReferenceAssociation LAYOUTS = { 1 => "1 - TOP: Slideshow / BOTTOM: Video (16:9), Mobile (1:1)", 2 => "2 - TOP: Slideshow / BOTTOM: Triptych of ...
class UsersController < ApplicationController before_action :import_users def index @users = User.where('distance < ?', (params[:distance].to_i * 1000)) end private def import_users User.import! unless User.first end end
=begin Exemples partagés pour les Things Entendu qu'on doit pouvoir utiliser le même fonctionnement pour toutes les parties du site. La seule chose qui distingue les things est l'« id sans type » de l'objet contenant la thing. Par exemple, pour l'accueil, cet id sans type est "p000", pour un article "p000arti00...
number = 1 while number < 100 if number.odd? print "#{number} " end number += 1 end
class Classroom < ApplicationRecord belongs_to :campus has_many :lessons def name if !self.id.nil? self.number end end end
class ToniNovels::CLI def call puts "Welcome to Toni Morrison's Bookstore!" list_novels menu goodbye end def list_novels puts "List of Novels:" # puts <<~DOC # 1. Beloved by Toni Morrison - $32.00 # 2. Sula by Toni Morrison - $19.84 # 3. The Blue...
Rails.application.routes.draw do root 'home#index' # route to API docs get 'apidocs', to: redirect('/swagger/dist/index.html#!/default/') # namespace APIs w/ version namespace :api, defaults: {format: :json} do namespace :v1 do resources :drugs, only: [:index, :show] resources :events,...
def sign_in(email, password) visit '/' within 'form' do fill_in 'Email', with: email fill_in 'Password', with: password end click_button 'Log in' end shared_context 'Rendered partial' do let!(:rendered) { render partial: partial } let(:page) { Capybara::Node::Simple.new(rendered) } end
# frozen_string_literal: true module GraphQL class Schema class Member module HasArguments def self.included(cls) cls.extend(ArgumentClassAccessor) cls.include(ArgumentObjectLoader) end def self.extended(cls) cls.extend(ArgumentClassAccessor) ...
class Dashboard::SectionsController < DashboardController before_filter :load_issue, except: :sort respond_to :json, :html def index @sections = @issue.sections respond_with(@sections) end def new @section = @issue.sections.build end def create @section = @issue.sections.build(params[...
# Inspec test for recipe opencv::default # The Inspec reference, with examples and extensive documentation, can be # found at https://docs.chef.io/inspec_reference.html control 'opencv' do impact 1.0 title 'Verify OpenCV and its dependencies are installed' %w( cmake gfortran libjpeg8-dev libtif...
# The NPR Importer is here because NPR, through their API, gives us more # information about a given segment than an RSS feed does. # # A program with its source set to "npr-api" is assumed to have segmented # episodes. This might not always be the case with the NPR API, I really # don't know, but we'll leave it like ...
module ApplicationHelper ALERTS = { notice: 'success', alert: 'danger' }.freeze def current_year Date.current.year end def github_url(author, repo) link_to 'Test Guru', "https://github.com/#{author}/#{repo}", target: :blank end def alert(type) ALERTS[type.to_sym] || 'warning' end end
# rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/PerceivedComplexity class Board attr_reader :cell def initialize @cell = { '1' => "\s", '2' => "\s", '3' => "\s", '4' => "\s", '5' => "\s", '6' => "\s", '7' => "\s", '8' => "\s", '9' => "\s" } end def matrix_display ...
input_file = ARGV[0] # putting the contents of the file output by .read directly def print_all(f) puts f.read() end # seeks to point in file specified by first arg, in this case # to absolute location due to IO::SEEK::SET. # IO_SEEK_CUR = amount + current pos # IO::SEEK_END = seeks to amount plus end of stream (use...
require 'spec_helper' describe Opportune::Outcome do describe "An initialized Outcome" do before do @utility = -23 @a = Action.new(@utility) end it "should return a utility" do @a.utility.should == -23 end end end
# This file is used by Rack-based servers to start the application. require 'vcr' require 'webmock' VCR.configure do |c| c.cassette_library_dir = './cache/' c.hook_into :webmock end use VCR::Middleware::Rack do |cassette| cassette.name 'cassette' cassette.options :record => :new_episodes, ...
class ApplicationController < ActionController::Base protect_from_forgery with: :null_session before_filter :configure_permitted_parameters, if: :devise_controller? private def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) do |u| u.permit(:email, :account_id,:uid,:password, ...
RSpec.describe User, type: :model do describe "Validations" do it { should validate_presence_of(:first_name) } it { should validate_presence_of(:last_name) } it { should validate_presence_of(:email) } end describe "Associations" do it { should have_many(:inviter_bets).class_name('Bet').with_forei...
class ChoosesController < ApplicationController before_action :set_book_variables, only: [:post_choose, :delete_choose] def post_choose choose = current_user.chooses.new(user_id: current_user.id, book_id: @book.id) choose.save end def delete_choose choose = current_user.chooses.find_by(user_id: cu...
require 'rails_helper' # As an authenticated user, I want to be able to log in to my account, so I can use the app. feature "users can log in" do scenario "user can log in" do User.create(first_name: "Simon", last_name: "Smith", username: "simonsmith", email: "simon@smith.com", password: "1234567") visit r...
class AddPrivacyStatusToEvents < ActiveRecord::Migration def change add_column :events, :privacy_status, :integer, default: 0 end end
desc "Setting up Privileges and Admin Roles" task "initial_setup" do Tenant.switch!("amazon") user = User.where(username: "admin", firstname: "admin", password: "password").first_or_create admin = Role.where(title: "admin").first_or_create privileges = ['create_items', 'update_items', 'destroy_items', 'creat...
# frozen_string_literal: true RubyNext::Core.patch Array, method: :deconstruct, version: "2.7" do <<~RUBY def deconstruct self end RUBY end # We need to hack `respond_to?` in Ruby 2.5, since it's not working with refinements if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6") RubyNext::Cor...
class AuthenticationsController < ApplicationController before_action :set_authentication, only: [:show, :edit, :update, :destroy] # GET /authentications # GET /authentications.json def index if current_user @authentications = current_user.authentications else flash[:notice]='Please login first...
class FontUnkempt < Formula head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "apache/unkempt" desc "Unkempt" homepage "https://fonts.google.com/specimen/Unkempt" def install (share/"fonts").install "Unkempt-Bold.ttf" (share/"fonts").install "Unk...
class CreateSubscriptionPlans < ActiveRecord::Migration def change create_table :subscription_plans do |t| t.string :name, :null => false t.string :stripe_id, :null => false# just ID @ stripe t.integer :amount, :null => false t.integer :total_payments t.string :...
class CreateGroopings < ActiveRecord::Migration def change create_table :groopings do |t| t.string :groop_name t.timestamps end end end
class Storage class << self attr_reader :mutex def init! @mutex = Mutex.new @backend = Hash.new end def next_uid uid = Util.generate_alnum_string(8) mutex.synchronize do while has_key?(uid) uid = Util.generate_alnum_string(8) end end uid...
# frozen_string_literal: true require 'spec_helper' require 'bolt/executor' require 'bolt/target' describe 'wait_until_available' do let(:executor) { Bolt::Executor.new } let(:inventory) { mock('inventory') } let(:target) { Bolt::Target.new('test.example.com') } let(:tasks_enabled) { true } let(:result_set)...
class MoveGalleryImagesToCarrierwave < ActiveRecord::Migration def change add_column :gallery_items, :image, :string remove_column :gallery_items, :gallery_item_image_file_name remove_column :gallery_items, :gallery_item_image_content_type remove_column :gallery_items, :gallery_item_image_file_size ...
# encoding: utf-8 require 'spec_helper' describe Admin::UsersController do let(:user) { create_user! } context "non-admin users" do before do I18n.locale = "en" I18n.default_locale = "en" sign_in(:user, user) end it "are not able to access the index action" do get 'index' ...
class RemoveColumnsFromActualWorkOrder < ActiveRecord::Migration def change remove_column :actual_work_orders, :program_office remove_column :actual_work_orders, :project_manager_id end end
class CreateGuests < ActiveRecord::Migration def change create_table :guests do |t| t.text :last_name t.text :first_name t.text :address t.text :email t.text :phone_number t.boolean :reception t.boolean :nijikai t.timestamps null: false end end end
class ApplicationRecord < ActiveRecord::Base self.abstract_class = true scoped_search on: [:title, :author, :genre, :classification, :year] end
class Rubymine < Cask url 'http://download.jetbrains.com/ruby/RubyMine-6.0.1.dmg' homepage 'http://www.jetbrains.com/ruby/' version '6.0.1' sha1 'aa530d89c0055a408e5a9a41f2f33c84239db1cc' link 'RubyMine.app' end
RSpec.describe BetStepsHelper, type: :helper do describe "#invitee_amount_at_risk" do it "calculates the invitee's amount at risk based on the inviter's odds & amount at risk" do bet = build(:bet, odds: 2, inviter_amount_at_risk: 50) expect(helper.invitee_amount_at_risk(bet)).to eq 100 end end ...
require 'securerandom' require 'test_helper' module Search module Indices class DocumentsIndexTest < ActiveSupport::TestCase setup do delete_indices @khan_repo = repositories(:khan) @lt = organizations(:lt) end test '#index_name is composed with repo ID and environment'...
# frozen_string_literal: true module Vedeu module Borders # Provides the mechanism to decorate an interface with a border on # all edges, or specific edges. The characters which are used for # the border parts (e.g. the corners, verticals and horizontals) # can be customised as can the colours and ...
require 'rails_helper' RSpec.describe Contributors::TopContributorsOrganizer, type: :interactor do it 'includes Organizer module' do expect(described_class.included_modules.include?(Interactor::Organizer)).to be true end before do allow(Contributors::Validator).to receive(:call!) { :success } allow(...
module ApiHelpers def json JSON.parse(response.body).deep_symbolize_keys end def json_data json[:data] end def json_errors json[:errors].try(:first) end end
class MachineLearning include Singleton attr_reader :classifier IGNORE_WORDS = ['the', 'my', 'i', 'dont', 'of', 'for', 'and'] def initialize @classifier = StuffClassifier::Bayes.new("Industries") @classifier.ignore_words = MachineLearning::IGNORE_WORDS end def self.classify(text) self.instan...
# @author Kristian Mandrup # # Common Read API # require 'set' module Troles::Common::Api module Read # Ensures that the common API methods always have a common underlying model to work on # @note This Set should be cached and only invalidated when the user has a change of roles # @return Array<Symb...
class ApartmentsController < ApplicationController before_action :authenticate_user!, only: [:new, :create, :edit, :update, :show] before_action :set_apartment, only: [:show, :edit, :update, :destroy] include Pundit after_action :verify_authorized, except: :index, unless: :skip_pundit? # Uncomment when you...
class LineItem < ActiveRecord::Base belongs_to :cart belongs_to :line_itemable, polymorphic: true attr_accessible :cart_id, :line_itemable_id, :line_itemable_type, :qty, :unit_price, :unit_shipping_cost def line_item_title "#{self.line_itemable_type} ##{self.line_itemable_id}" end RailsAdmin.co...
module CDI module V1 class ChannelSerializer < ActiveModel::Serializer has_one :student_class, serializer: SimpleStudentClassSerializer has_one :learning_track, serializer: SimpleLearningTrackSerializer attributes :name end end end
class BlogAppsController < ApplicationController before_action :set_blog_app, only: %i[show edit update destroy] before_action :authenticate_user!, except: %w[index recent show] before_action :correct_user, only: %w[edit update destroy] # GET /blog_apps or /blog_apps.json def index @blog_apps = BlogApp.a...
module MaterialsForm class StrainForm include ActiveModel::Model attr_accessor :id, :name, :desc validates :name, presence: true def initialize(record_id = nil) set_record(record_id) end def submit(params) map_attributes(params) if valid? SaveStrain.call(params).r...
#!/usr/bin/env ruby require 'optparse' require 'ois-notifier' OptionParser.new do |opts| opts.banner = "Usage: ois-notifier [options]" opts.on('-w', '--write-crontab') do puts 'TODO: write to crontab' end opts.on('-c', '--clear-crontab') do puts 'TODO: remove from crontab' end opts.on('-f', '--...
class Task::Auth < ActiveRecord::Base belongs_to :author, class_name: "Task::Author", dependent: :destroy counter_culture :author, column_name: "tasks_count" belongs_to :task, class_name: "Task::Info", dependent: :destroy counter_culture :task, column_name: "auths_count" structure do timestamps...
require "minitest" require_relative "maze_impl.rb" class TestSuite describe "maze implementations" do it "can be initialized correctly" do #Nothing atm end it "can accept strings as input" do end it "can reject invalid inputs" do end it "can display the maze"...
class V1::LocationVisitsController < V1::ApiController def create @location_visit = LocationVisit.create location_visit_params if @location_visit.persisted? render_200 else render_400(@location_visit.errors.messages) end end private def location_visit_params params.permit(:loca...
require 'rails_helper' describe Backend::GalleriesController do let(:title) { 'foobar title' } let(:description) { Faker::Lorem.paragraph(8)[0..150] } let(:deletable) { true } let(:gallery_params) { { title: title, description: description, deletable: deletable, image_ids: [image.id] } } let(:user) { create(...
# Pretty Inspect Gem class Object =begin This gem extends Object::inspect to "pretty" inspect arrays and hashes. Example: (copy this to irb) require 'pretty_inspect' require 'bigdecimal' class X def initialize @y = BigDecimal(31.41592653589796,4) @f = false @t = true ...
class AddDefaultPictureViews < ActiveRecord::Migration def change change_column :pictures, :views, :integer, default: 0 end end
require "linear_solver/version" require "linear_solver/calculation_unsolvable_error" module LinearSolver def self.solve_equal(goal, starting_value, &block) self.solve_with_stopper(goal, starting_value, ->(a, b) { a == b }, &block) end def self.solve_with_stopper(goal, starting_value, stopping_comparator, &...
# encoding: utf-8 module Glyph # The Glyph::Config class is used (you don't say!) to store configuration data. Essentially it wraps a Hash of Hashes # and provides some useful methods to access keys and subkeys. class Config include Glyph::Utils # Initializes the configuration with a hash of options: # * :...
class QueueController < ApplicationController protect_from_forgery before_filter :authenticate_user!, :except => [ :index ] def index if user_signed_in? redirect_to profile_path end end def show end def add if params[:url] == "" redirect_to profile_path, :alert => "ur...
#!/usr/bin/env ruby #illustrative Ruby code to return all abbreviations for the given argument: e.g. for "abc": a, ab, abc, ac, b, c, bc require 'rubygems' require 'set' #to measure performance require 'ruby-prof' class Abbrev attr_accessor :a, :C #holds initial string def initialize(str) @a = str @C =...
module De module Error exceptions = %w[TypeError ArgumentNumerError InvalidExpressionError AbstractClassObjectCreationError MethodShouldBeOverridenByExtendingClassError] exceptions.each { |e| const_set(e, Class.new(StandardError)) } end end
class CreateCommunities < ActiveRecord::Migration[5.1] def change create_table :communities do |t| t.string :name, null: false, index: true t.integer :category, default: nil, null: false, limit: 1 t.text :image, null: false t.timestamps end end end
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable validates :username, :presence => true, :uniqueness => true validates :firstname, :presence => true validates :lastname, :p...
require 'rubygems' require 'rake' require 'rake/testtask' APP_VERSION="2.3.0" APP_NAME='Ruby on Rails.tmbundle' APP_ROOT=File.dirname(__FILE__) RUBY_APP='ruby' desc "TMBundle Test Task" task :default => [ :test ] Rake::TestTask.new { |t| t.libs << "test" t.pattern = 'Support/test/*_test.rb' t.verbose = true ...
require "rails_helper" RSpec.describe OnDutyLocator, "#locate" do let(:firm_1) { SecureRandom.uuid } let(:firm_2) { SecureRandom.uuid } let(:firm_3) { SecureRandom.uuid } let(:first_shift) { build_stubbed :shift, starting_time: Time.parse("12:00") } let(:last_shift) { build_stubbed :shift, starting_time: T...
module QML module NameHelper module_function def to_underscore(sym) sym.to_s.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase.to_sym end def to_upper_underscore(sym) to_underscore(sym).upcase end end end
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "example_helper.rb")) describe Relevance::Tarantula::FormSubmission do describe "with a good form" do # TODO: add more from field types to this example form as needed before do @tag = Hpricot(%q{ <form action="/session" m...
require('capybara/rspec') require('./app') Capybara.app = Sinatra::Application set(:show_exceptions, false) describe('adding a new stylist', {:type => :feature}) do it('allows a user to click a stylist and see all their clients and details') do visit('/') click_link('View All Stylists') fill_in('stylist_...
# frozen_string_literal: true module Vedeu module Terminal # Store the current mode of the terminal. # module Mode include Vedeu::Common extend self # Returns a boolean indicating whether the terminal is currently # in `cooked` mode. # # @return [Boolean] def...
require 'spec_helper' describe ShopifyImport::Importers::UserImporter, type: :service do subject { described_class.new(resource) } before { authenticate_with_shopify } describe '#import!', vcr: { cassette_name: 'shopify_import/importers/user_importer/import' } do let(:resource) { ShopifyAPI::Customer.find(...
require 'mongoid' Mongoid.load!('config/mongoid.yml') module Model class Post include Mongoid::Document field :title, type: String field :body, type: String has_many :comments validates :title, presence: true validates :title, uniqueness: false validates :body, presence: true validates :bo...
require 'lita' require 'trackerific' module Lita module Handlers class Trackerific < Handler route(/track/, :track, command: true, help: { 'track tracking-id-code' => 'Returns the tracking status of the package with tracking-id-code' }) def self.default_config(config) config.f...
require 'watir-webdriver' require 'RMagick' include Magick def human_sort (items) items.sort_by { |item| item.to_s.split(/(\d+)/).map { |e| [e.to_i, e] } } end # # Create a gif of a page state over previous commits. # output_file = ARGV[1].nil? ? "animation" : ARGV[1] browser = Watir::Browser.new branch = `git bra...
module Dashboard class JudgesController < Dashboard::BaseController before_filter :require_current_challenge, only: [:index, :new, :create] before_filter :set_current_challenge load_and_authorize_resource add_crumb 'Jurado' def index @challenges = organization.challenges.order('created_at D...
class AddVisibleToBiodatabase < ActiveRecord::Migration def self.up add_column :biodatabases, :visible, :boolean, :default => true,:null => false end def self.down remove_column :biodatabases, :visible end end
require 'test_helper' class GroupTest < ActiveSupport::TestCase # test "the truth" do # assert true # end test 'join_public_group' do group = groups(:public_group) user = users(:two) assert(! group.is_member?(user), "User is already member of public group") assert(group.can_join?(user), "Use...
class AddVisitedToSubmittedReports < ActiveRecord::Migration def change add_column :submitted_reports, :visited, :boolean, :default => false end end
name 'user' maintainer 'Ares' maintainer_email 'ar3s.cz@gmail.com' license 'All rights reserved' description 'Installs/Configures user so others cookbook can rely on them' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.1.2' attribute 'user',...
module Disqussion class Forums < Client # Creates a new forum. # @accessibility: public key, secret key # @methods: GET # @format: json, jsonp # @authenticated: true # @limited: false # @param website [String] Disqus website name. # @param name [String] Forum name. # @param short_n...
# == Schema Information # Schema version: 20110408205527 # # Table name: lists # # id :integer not null, primary key # name :string(255) # description :string(255) # user_id :integer # created_at :datetime # updated_at :datetime # class List < ActiveRecord::Base belongs_to :user ...
module Donors class DashboardController < ApplicationController def index @donations = current_donor.donations.attended @blood_alerts = BloodAlert.all @announcements = Announcement.order(:created_at).first 3 end end end
class QuizzesController < ApplicationController before_action :require_user before_action :is_admin?, only: [:index, :new, :create, :edit, :update, :destroy] before_action :set_quiz, only: [:edit, :update, :show, :submit_quiz] before_action :quiz_answers, only: [:submit_quiz] def index @quizzes = Q...
require_relative 'test_helper' begin require 'tilt/markaby' describe 'tilt/markaby' do def before @block = lambda do |t| File.read(File.dirname(__FILE__) + "/#{t.file}") end end it "should be able to render a markaby template with static html" do tilt = Tilt::MarkabyTemplate...
def turn_count(board) counter = 0 board.each { |token| if token == 'X' || token == 'O' then counter += 1 end } counter end def current_player(board) turn_count(board).even? ? 'X' : 'O' end
class User < ApplicationRecord has_secure_password has_many :generators validates :name, uniqueness: true, presence: true validates :password, length: { minimum: 4 }, if: -> { new_record? || changes[:password_digest] } validates :password, confirmation: true, if: -> { new_record? || changes[:password_digest...
module ApplicationHelper def translate(key) module_part = controller.class.name.split("::").first.downcase controller_part = controller_name I18n.t("#{module_part}.#{controller_part}.#{action_name}.#{key}") end def data_view_name controller_name.humanize end def dashboard_data_view_name ...