Rails6 New Functions

F726c60218757a2e4b82a09c491af75a?s=47 k.yanagimoto
September 25, 2019

Rails6 New Functions

F726c60218757a2e4b82a09c491af75a?s=128

k.yanagimoto

September 25, 2019
Tweet

Transcript

  1. Rails 6 @kyanagimoto

  2. ॕ 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
  3. Action Text • WYSIWYG (΢Οδ΢Οά, What You See Is What

    You Getͷུͩͬͯ) EditorͷTrixΛ ؆୯ʹ࢖͑ΔΑɻ • ActiveStorageΛEditorͰೖྗͨ͠FileΛอ ଘ͢Δҝʹར༻͍ͯ͠Δɻ
 WYSIWYG Editor಺ʹFileΛૠೖͨ࣌͠͸ ActiveStorageʹDirectUpload͞ΕΔ໛ ༷ɻ
  4. Action Mailbox • Mailͷड৴ॲཧͷͨΊͷίϯϙʔωϯτ
 * ActionMailer: MailΛRubyͰ࢖͏ͨΊObjectʹม׵͢ΔͨΊ
 Cloudͷϝʔϧॲཧ΍อଘ͸ࣗલͰ΍Δඞཁ͋ͬͨɻ • ActiveStorageʹMailΛอଘɺAction

    Mailbox༻ͷDB Tableඞཁ
  5. Webpacker • Rails಺ͷJavaScript Library͸npmͰެ։͞Ε͍ͯΔ΋ͷΛར༻ • CoffeeScript…ɻ(Action CableͰGenerate͞ΕΔίʔυ͕มԽ)

  6. ෳ਺DB઀ଓ • config/database.yaml
 • app/models/hoge.rb • config/environments
 Sample: 
 https://github.com/

    effectiveDevOps/devops_meter/ blob/master/config/environments/ production.rb#L109
  7. Parallelize test • github.com/rspec/rspec-rails/issues/2104
 rspecͷରԠ͸Ͳ͏΋·ͩΈ͍ͨͳײ͡ɻ

  8. ͱΓ͋͑ͣɺ࡞ͬͯΈ·͠ΐ͏ $ 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
  9. # 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 Ұཡ
  10. $ 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
  11. # Edit Gemfile
 $ vi Gemfile
 ## image_processingͷίϝϯτΞ΢τΛ֎͢ $ bundle

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

    # Access to http://localhost:3000/posts # WYSIWYG Editorग़ݱɻ
  13. $ 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/