「Tep3-onk」の版間の差分

提供: wikipokpok
移動先: 案内検索
(db:rollback)
(postgres)
40行目: 40行目:
  
 
== postgres ==
 
== postgres ==
 +
$ heroku pg:backups:capture
 +
$ heroku pg:backups:download
 +
$ createdb mydb
 +
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
  
 
  <nowiki>=# select count(*) from clients;
 
  <nowiki>=# select count(*) from clients;

2022年9月12日 (月) 15:53時点における版

generate

$ rails generate scaffold User name:string email:string password_digest:string remember_digest:string admin:boolean activation_digest:string activated:boolean activated_at:datetime reset_digest:string reset_sent_at:datetime
$ rails generate scaffold User name:string email:string password_digest:string remember_digest:string role:integer activation_digest:string activated:boolean activated_at:datetime reset_digest:string reset_sent_at:datetime
% rails generate scaffold Note content:string user:references kind:integer meeting_time:integer role:integer line:integer
% rails generate scaffold Client user:references note:references content:string list:integer line:integer memo:text
% rails generate scaffold Other user:references note:references client:references name:string yomi:string client_name:boolean line:integer memo:text generation:string
$ rails generate scaffold Post content:text user:references picture:string
$ rails generate model Relationship follower_id:integer followed_id:integer
$ rails db:migrate RAILS_ENV=production
$ bin/dev
$ rails generate controller StaticPages home help about contact

エラー

ActionView::Template::Error (The asset "tailwind.css" is not present in the asset pipeline.

config/envitonments/production.rb

config.assets.compile = true

db:rollback

% rails db:migrate:status
% rails db:rollback STEP=3
% rails db:migrate
$ rails db:migrate:down VERSION=20200504051127
$ rails db:migrate:up VERSION=20200504051127

postgres

$ heroku pg:backups:capture
$ heroku pg:backups:download
$ createdb mydb
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
=# select count(*) from clients;
 count 
-------
  4209
(1 row)

ローカル

rubyの確認

プロジェクトディレクトリに移動

% cd rails_app_tepnote/3tep

カレントディレクトリでrubyのバージョン確認

% rbenv version            
2.7.1 (set by /Users/jq/.rbenv/version)

使用できるrubyのバージョン確認

% rbenv versions
  system
  2.6.6
* 2.7.1 (set by /Users/jq/.rbenv/version)
  2.7.4
  2.7.5
  3.0.0
  3.1.2

カレントディレクトリで使う rubyのバージョンを指定する

% rbenv local 3.1.2

確認 2.7.1から3.1.2に変わった

% rbenv version    
3.1.2 (set by /Users/jq/rails_app_tepnote/3tep/.ruby-version)

% rbenv versions
  system
  2.6.6
  2.7.1
  2.7.4
  2.7.5
  3.0.0
* 3.1.2 (set by /Users/jq/rails_app_tepnote/3tep/.ruby-version)

railsの確認

カレントディレクトリで確認 無かったのでインストールする

% rails -v
rbenv: rails: command not found
% gem install rails
% rails -v         
Rails 7.0.3.1

bundlerの確認

% gem search ^bundler$ --all
bundler (2.3.21, 2.3.20, 2.3.19, 2.3.18, 2.3.17,.......
% gem list bundler

*** LOCAL GEMS ***

bundler (2.2.17, default: 2.1.4)

バージョンを指定してインストール

% gem install bundler -v 2.3.21

確認

% gem list bundler             

*** LOCAL GEMS ***

bundler (2.3.21, 2.2.17, default: 2.1.4
% bundle -v
Bundler version 2.3.21

postgresqlの確認

% psql --version
psql (PostgreSQL) 14.5 (Homebrew)

new

% rails new tep30 -d postgresql --css tailwind または rails new tep30 -d postgresql --css bootstrap
% cd tep30
% bundle install
% rails db:create
% rails db:migrate
% rails s

daisyui

tailwind css UIコンポーネント インストール

% yarn add daisyui

コピー

% scp -r --exclude-from='exclude-file.txt' ~/rails_app_tepnote/3tep/tep30 xxx:/home/xxx

ホスト

確認

$ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
$ rails -v
Rails 7.0.3.1
$ bundle -v
Bundler version 2.3.21
$ psql --version

new

$ rails new tep30 -d postgresql --css bootstrap または rails new tep30 --css tailwind -d postgresql

database.yml username:などを確認する (2箇所)

$ bundle install --without test development
$ rails db:create RAILS_ENV=production
$ rails db:migrate RAILS_ENV=production

daisyuiをインストール

$ yarn add daisyui

config/tailwind.config.js

plugins: [
    require('@tailwindcss/forms'),
    require('@tailwindcss/aspect-ratio'),
    require('@tailwindcss/typography'),
    require('daisyui'),    // ← 追記する
  ],

app/views/layouts/application.html.erb

<html data-theme="light">  // テーマを選ぶ


同期

% rsync -r ~/rails_app_tepnote/4tep/ host:/home/tep/

除外するファイルをまとめる

exclude-file.txt
    production.rb
    database.yml
% rsync -r --exclude-from='exclude-file.txt' ~/rails_app_tepnote/tep5/ jq:/home/jq/tep5/


$ bundle install  --without test development

database.yml username:などを確認する (2箇所)

$ rails db:create RAILS_ENV=production
または
$ rails db:reset RAILS_ENV=production

エラーのとき

ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`

master.key credentials.yml.enc 削除して作り直す

$ EDITOR="vi" bin/rails credentials:edit
$ rails db:migrate RAILS_ENV=production

エラー

ActionView::Template::Error (The asset "tailwind.css" is not present in the asset pipeline.

config/envitonments/production.rb

config.assets.compile = true

daisyuiをインストール

$ yarn add daisyui