Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails6 New Functions

k.yanagimoto
September 25, 2019

Rails6 New Functions

k.yanagimoto

September 25, 2019
Tweet

More Decks by k.yanagimoto

Other Decks in Technology

Transcript

  1. ॕ Rails 6 release • Date: Aug 15th 2019 •

    ৽͍͠ίϯϙʔωϯτ Action Text / Action Mailbox • Webpackerͷ࠾༻ • ෳ਺DB઀ଓɺฒྻςετ࣮ߦ(TDD is dead͔ΒͷྲྀΕ) • > 2.5 https://railsguides.jp/6_0_release_notes.html
  2. Action Text • WYSIWYG (΢Οδ΢Οά, What You See Is What

    You Getͷུͩͬͯ) EditorͷTrixΛ ؆୯ʹ࢖͑ΔΑɻ • ActiveStorageΛEditorͰೖྗͨ͠FileΛอ ଘ͢Δҝʹར༻͍ͯ͠Δɻ
 WYSIWYG Editor಺ʹFileΛૠೖͨ࣌͠͸ ActiveStorageʹDirectUpload͞ΕΔ໛ ༷ɻ
  3. ෳ਺DB઀ଓ • config/database.yaml
 • app/models/hoge.rb • config/environments
 Sample: 
 https://github.com/

    effectiveDevOps/devops_meter/ blob/master/config/environments/ production.rb#L109
  4. ͱΓ͋͑ͣɺ࡞ͬͯΈ·͠ΐ͏ $ gem i bundler $ gem i rails #

    YarnΛར༻͢ΔͷͰɺInstallɹhttps://yarnpkg.com/en/docs/install $ brew install yarn $ brew install postgresql $ rails new sample -d postgresql
  5. # DockerͰdatabaseཱͯΔ $ brew cask install docker $ docker run

    --name dev-postgres -e POSTGRES_USER=nikotama -e POSTGRES_PASSWORD=postgres -p 15432:5432 -d postgres:11 # ֬ೝ $ docker container exec -it dev-postgres bash $$ psql -U nikotama $$ \l #database Ұཡ
  6. $ vi config/database.yml ## developmentͷusername, password, host, portΛมߋɻ $ rake

    db:create $ bundle exec rails action_text:install $ bundle exec rails action_mailbox:install $ bundle exec rails db:migrate
  7. # Edit Gemfile
 $ vi Gemfile
 ## image_processingͷίϝϯτΞ΢τΛ֎͢ $ bundle

    install $ bundle exec rails generate scaffold post title:string body:rich_text $ bundle exec rake db:migrate
  8. $ bundle exec rails s # Another pane
 $ bin/webpack-dev-server

    # Access to http://localhost:3000/posts # WYSIWYG Editorग़ݱɻ
  9. $ docker container exec -it dev-postgres bash $$ psql -U

    nikotama $$$ \l
 $$$ \c sample_app_development
 $$$ \d
 $$$ select * from posts;
 $$$ select * from action_text_rich_texts;
 $$$ select * from active_storage_attachments;
 $$$ select * from active_storage_blobs; $ tree ./storage/