LoginSignup
9
9

More than 5 years have passed since last update.

SQALEでデプロイ時にやったことまとめ

Posted at

SQALEにRailsアプリをデブロイした際に嵌ってしまったのでメモ。まだよくわかっていないことがあるので、訂正・ご指摘あればどしどしくださいませ。

■STEP1
SQALEが用意してくれているマニュアルを見ながらデブロイをした。データはきちんとアップされたようだが、「Soryy, something went wrong.」と怒られてしまう。

■STEP2
設定ファイルを見直した。

config/environments/production.rb
   # Don't fallback to assets pipeline if a precompiled asset is missed
-  config.assets.compile = false
+  config.assets.compile = true

これでSTEP1のエラーは解消したが、また別のエラーが出てしまう。

■STEP3
log/production.logを開いてエラーログを確認した。

views/layout/application.html.erb
<%= bootstrap_flash %>
<%= yield %>

このbootstrap_flashというメソッドがないと怒られた。
これはいつ追加したのか謎なんですが・・・
bootstrapをベースにしたCSSフレームワークを導入したんですが、それを追加したときに追加されたのだろうか。↓がそのフレームワーク。
http://wbpreview.com/previews/WB0GRG7H2/index.html

■STEP4
bootstrap_flashでググると解決策が見つかった。
https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails/BootstrapFlashHelper

bootstrap_flash_helperを追加します。下記のディレクトリに新規にファイルを作り、ソースをそのまま貼付けることで、エラーが出なくなりました。

app/helpers/bootstrap_flash_helper.rb
module BootstrapFlashHelper
  ALERT_TYPES = [:error, :info, :success, :warning]


  def bootstrap_flash
    flash_messages = []
    flash.each do |type, message|
      # Skip empty messages, e.g. for devise messages set to nothing in a locale file.
      next if message.blank?


      type = :success if type == :notice
      type = :error   if type == :alert
      next unless ALERT_TYPES.include?(type)


      Array(message).each do |msg|
        text = content_tag(:div,
                           content_tag(:button, raw("&times;"), :class => "close", "data-dismiss" => "alert") +
                           msg.html_safe, :class => "alert fade in alert-#{type}")
        flash_messages << text if msg
      end
    end
    flash_messages.join("\n").html_safe
  end
end
9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9