2020-06-01から1ヶ月間の記事一覧
config/initializers/simple_form.rb # 必須フィールドのマークを消す config.label_text = ->(label, required, explicit_label) { label.to_s } # 必須フィールドのマークを消す config.required_by_default = false
前提 app/models/product.rb # frozen_string_literal: true class Product < ApplicationRecord has_one :stock end app/models/stock.rb # frozen_string_literal: true class Stock < ApplicationRecord belongs_to :product end 書く db/seeds.rb # froz…
= link_to 'ユーザー登録', new_user_registration_path = link_to 'ログアウト', destroy_user_session_path, method: :delete
validatableモジュールのソースコード devise/models/validatable.rb # frozen_string_literal: true module Devise module Models # Validatable creates all needed validations for a user email and password. # It's optional, given you may want to c…
やりたいこと サインアップするためのパラメータに、email, password以外に screen_name というパラメータを追加したい。 前提 以下の手順を完了していること。 (DBのカラムは以下手順で追加済みです) now-on-air.hatenablog.com 手順 $ rails g devise:view…
gem 'letter_opener' $ bundle install config/environments/development.rb config.action_mailer.delivery_method = :letter_opener
必ずやる手順 gem 'devise' $ bundle install $ rails generate devise:install Running via Spring preloader in process 74332 create config/initializers/devise.rb create config/locales/devise.en.yml =============================================…
テーブル作成 # frozen_string_literal: true class CreateProducts < ActiveRecord::Migration[6.0] def change create_table :products do |t| # NOT NULL制約 t.string :name, null: false t.integer :price, null: false t.timestamps end end end 複数…
# frozen_string_literal: true class User < ApplicationRecord validates :screen_name, # 必須 presence: true, # 長さ length: { maximum: 20 }, # 一意制約(大文字小文字区別しない) uniqueness: { case_sensitive: false } end # frozen_string_litera…
これから適宜追記していきます。 AllCops: Exclude: - 'db/schema.rb' Documentation: Enabled: false
# frozen_string_literal: true blog.toshimaru.net blog.oliva.co.jp
適宜追記していきます。 保存系 カーソルが外れると自動保存されること(確かデフォルトでそうだったはず) 一定時間経過で自動保存されること(秒数も指定できるので、1secにしてる) 保存時にファイル末尾が改行されること 保存時に行末の空白が除去されること…
適宜更新です。 rails db:xxxxx root@1f4605d9b6ff:/workspace# rails db:drop Dropped database 'rails_docker_development' Dropped database 'rails_docker_test' root@1f4605d9b6ff:/workspace# rails db:create Created database 'rails_docker_develop…