0
난로 레일 앱 https://gist.github.com/suryart/7418454에 대한 부트 스트랩 경고를 표시하기 위해이 요령을 따르려고합니다. 내용이있는 코드를 가지고 :레일은 도우미를 사용하여 부트 스트랩 경고를 표시합니다.
application_helper.rb :
def bootstrap_class_for flash_type
{ success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type] || flash_type.to_s
end
def flash_messages(opts = {})
flash.each do |msg_type, message|
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
concat message
end)
end
nil
end
application.html.erb
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>
문제는 내가 어떤 표시되지 오전 ApplicationHelper 모듈 메시지가 표시됩니다.
def flash_messages
@flash_msg = ""
flash.each do |msg_type, message|
@flash_msg = concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
concat message
end)
puts "@flash_msg: #{@flash_msg}"
end
@flash_msg
end
:
는 내가 HTML을 반환하는 내 도우미에서 이런 일을했다, 그래서 어쩌면 내가 .each 반복자의 내용을 반환해야 요지가 nil을 반환 보여주는 어쩌면 때문에 생각 나는이 그렇게 작동이 있음을 얻을 어떻게<div class="alert alert-info fade in"><button class="close" data-dismiss="alert">x</button>Signed in successfully.</div>
: 당신이 인쇄 문의 출력에서 볼 때 나를이 페이지에 대한 HTML을 입력 보여주는, 말은 실제로 내가 필요로하는 HTML입니다 마지막 부분 만 반환하고 전체 페이지는 반환하지 않습니까?