Rails 6@kyanagimoto
View Slide
ॕ Rails 6 release• Date: Aug 15th 2019• ৽͍͠ίϯϙʔωϯτ Action Text / Action Mailbox• Webpackerͷ࠾༻• ෳDBଓɺฒྻςετ࣮ߦ(TDD is dead͔ΒͷྲྀΕ)• > 2.5https://railsguides.jp/6_0_release_notes.html
Action Text• WYSIWYG (ΟδΟά, What You SeeIs What You Getͷུͩͬͯ) EditorͷTrixΛ؆୯ʹ͑ΔΑɻ• ActiveStorageΛEditorͰೖྗͨ͠FileΛอଘ͢Δҝʹར༻͍ͯ͠Δɻ WYSIWYG EditorʹFileΛૠೖͨ࣌͠ActiveStorageʹDirectUpload͞ΕΔ༷ɻ
Action Mailbox• Mailͷड৴ॲཧͷͨΊͷίϯϙʔωϯτ * ActionMailer: MailΛRubyͰ͏ͨΊObjectʹม͢ΔͨΊ CloudͷϝʔϧॲཧอଘࣗલͰΔඞཁ͋ͬͨɻ• ActiveStorageʹMailΛอଘɺAction Mailbox༻ͷDB Tableඞཁ
Webpacker• RailsͷJavaScript LibrarynpmͰެ։͞Ε͍ͯΔͷΛར༻• CoffeeScript…ɻ(Action CableͰGenerate͞ΕΔίʔυ͕มԽ)
ෳDBଓ• config/database.yaml • app/models/hoge.rb• config/environments Sample: https://github.com/effectiveDevOps/devops_meter/blob/master/config/environments/production.rb#L109
Parallelize test• github.com/rspec/rspec-rails/issues/2104 rspecͷରԠͲ͏·ͩΈ͍ͨͳײ͡ɻ
ͱΓ͋͑ͣɺ࡞ͬͯΈ·͠ΐ͏$ 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
# DockerͰdatabaseཱͯΔ$ brew cask install docker$ docker run --name dev-postgres -e POSTGRES_USER=nikotama -ePOSTGRES_PASSWORD=postgres -p 15432:5432 -d postgres:11# ֬ೝ$ docker container exec -it dev-postgres bash$$ psql -U nikotama$$ \l #database Ұཡ
$ 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
# Edit Gemfile $ vi Gemfile ## image_processingͷίϝϯτΞτΛ֎͢$ bundle install$ bundle exec rails generate scaffold post title:string body:rich_text$ bundle exec rake db:migrate
$ bundle exec rails s# Another pane $ bin/webpack-dev-server# Access to http://localhost:3000/posts# WYSIWYG Editorग़ݱɻ
$ 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/