Rails - Why is HAML showing the full hash?
Posted
by
Mr. Demetrius Michael
on Stack Overflow
See other posts from Stack Overflow
or by Mr. Demetrius Michael
Published on 2012-12-05T04:57:28Z
Indexed on
2012/12/05
5:03 UTC
Read the original article
Hit count: 262
View:
!!!
%html
%head
%title= full_title(yield(:title))
=stylesheet_link_tag "application", media: "all"
=javascript_include_tag "application"
=csrf_meta_tags
=render 'layouts/shim'
%body
=render 'layouts/header'
.container
=flash.each do |key, value|
%div{class: "alert alert-#{key}"} #{value}
Controller
def create
@user = User.new(params[:user])
if @user.save
flash[:success] = "This is Correct"
redirect_to @user
else
flash[:wrong] = "no"
render 'new'
end
end
Regardless of the flash (:success or :wrong or otherwise) it always compiles the entire hash as html (below)
Output:
<!DOCTYPE html>
....
<div class='container'>
<div class='alert alert-wrong'>no</div>
{:wrong=>"no"}
</div>
</body>
</html>
I have no idea why {:wrong=>"no"}
is being displayed. I've been staring at this terminal for hours. What's interesting is that the hash is being outputted with the container
id, but not in the alert
class. It feels like an indentation problem, but I went through several permutations with no success.
© Stack Overflow or respective owner