In Gemfile: # Use Capistrano for deployment group :development do gem 'capistrano' gem 'capistrano-passenger' gem 'capistrano-rails' gem 'capistrano-bundler' gem 'capistrano-rvm' gem 'highline' end In deploy.rb # Set rvm type #set :rvm\_type, :user set :rvm\_custom\_path, '/usr/local/rvm' # Remote server using rvm set :rvm\_ruby\_version, '[email protected]' In config/environment/production.rb config.require_master_key = true
read moreWhen I deploying a new rails 5.2.0 app to production machine, which has been the other rails 5.2.0 app there, I encounter a serious problem: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage ArgumentError: invalid base64 /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing' /var/www/blogApp/shared/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/application.rb:433:in `secret_key_base' Below are a part of debug info when I use capistrano to deploying a rails 5.2.0 app: DEBUG [b79779f0] Command: cd /var/www/blogApp/releases/20180802145508 && ( export RAILS_ENV="production" RAILS_GROUPS="" ; /usr/local/rvm/bin/rvm [email protected] do bundle exec rake assets:precompile )
read more都 2018 年了, MySQL 資料庫字元編碼請使用 utf8mb4,原因是從來沒有一個時代,能夠從手機如此容易輸入 emoji 表情符號。若是新開的案子就直接使用 utf8mb4 當作字元
read more假設兩個 Model : A, B, 一對一關係,例如 A has B, B belongs A,當要撈出 A 中有 B 且符合 在 B 的篩選欄位條件。A 是 Post 貼文, B 是 Comment 評論,A 和 B 的更新日期時間欄位都是
read moreImportant: The result of 10/110 in SQLite is 0 and different with 0.09090909 when manipulating in MySQL. When testing Laravel Eloquent ORM both at local machine with SQLite and at remote machine with MySQL, you will find some execution results don’t same as expected at local machine. That’s is because SQLite won’t transform integer to real number automatically. Workaround: Add multiply 1.0 to ORM SQL statement and it becomes portable
read moreRefer from link: http://laragems.com/post/a-quick-way-to-display-a-sql-query-in-tinker Please enter tinker command: php artisan tinker Type below code: DB::listen(function ($query) { dump($query->sql); dump($query->bindings); dump($query->time); }); And from above line on, every ORM manipulation you type will show what transformed SQL is.
read more