「Tep3-onk」の版間の差分

提供: wikipokpok
移動先: 案内検索
(new)
(new)
106行目: 106行目:
  
 
  $ bin/dev
 
  $ bin/dev
 +
 +
$ rails generate controller StaticPages home help about contact
  
 
エラー
 
エラー

2022年9月5日 (月) 11:30時点における版

ローカル

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の確認

% bundle -v
Bundler version 2.3.21

new

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

daisyui

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

% yarn add daisyui

コピー

% scp -r ~/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

new

rails new tep30 --css tailwind -d postgresql

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

$ 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">  // テーマを選ぶ
$ 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 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

コピーのとき

$ bundle install

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