「Tep8」の版間の差分

提供: wikipokpok
移動先: 案内検索
(user)
(user)
44行目: 44行目:
  
 
view更新
 
view更新
# config/initializers/devise.rb
+
# config/initializers/devise.rb
 
  config.scoped_views = true
 
  config.scoped_views = true
  
  <nowiki>def after_sign_in_path_for(resource)
+
ログイン後のパス
 +
  <nowiki># app/controllers/application_controller.rb
 +
def after_sign_in_path_for(resource)
 
   notes_path
 
   notes_path
 
end</nowiki>
 
end</nowiki>

2023年6月2日 (金) 13:21時点における版

準備

create application

% rails new . --css=tailwind --javascript=esbuild --database=postgresql
% bin/bundle add tailwindcss-rails
% bin/rails tailwindcss:install
% bin/setup
% rails generate scaffold NameList name:string kana:string head:boolean line:integer buddhist_name:string alive:boolean birth:string death:string g_age:string memo:text generation:string
validates :name, presence: true
t.string :name, null: false
% bin/rails db:drop db:create db:migrate
% bin/rails test:system
% bin/dev

テストデータ

テストデータと開発データの同期

# db/seeds.rb

puts "\n== Seeding the database with fixtures =="
system("bin/rails db:fixtures:load")
bin/rails db:seed

note

% rails generate scaffold Note name:string kind:integer line:integer

user

gem 'devise', '~> 4.9', '>= 4.9.2
% bundle install
% bin/rails generate devise:install
bin/rails generate devise User
bin/rails db:migrate

view更新

# config/initializers/devise.rb
config.scoped_views = true

ログイン後のパス

# app/controllers/application_controller.rb
def after_sign_in_path_for(resource)
  notes_path
end

company

% rails generate model Company name

関連付け

% bin/rails generate migration add_company_reference_to_notes company:references
% bin/rails generate migration add_company_reference_to_users  company:references
% bin/rails generate migration add_note_reference_to_name_list note:references


bin/rails db:drop db:create db:migrate