0
레일 3 프로젝트에서 트위터 부트 스트랩을 사용하고 성공적인 포스트 생성시 플래시 메시지를 표시하는 데 문제가 있습니다.플래시 성공 메시지가 표시되지 않습니다.
여기 코드가 있습니다 - 내가 잘못하고있는 것을 알려주실 수 있습니까 ??
감사합니다,
파이
게시물 컨트롤러
def create
@post = Post.new(params[:post])
@post.user = current_user
respond_to do |format|
if verify_recaptcha && @post.save
format.html { redirect_to '/home'}
format.json { render :json => @post, :status => :created, :location => @post }
flash[:notice] = "Thank you, your request has been submitted."
else
format.html { render :action => "new" }
format.json { render :json => @post.errors, :status => :unprocessable_entity }
end
end
end
APPLICATION.HTML.ERB보기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The little chits that ended 3 years of unemployment for me.</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag "application", :media => 'all' %>
<link href="images/favicon.ico" rel="shortcut icon">
<link href="images/apple-touch-icon.png" rel="apple-touch-icon">
<link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon" sizes="72x72">
<link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon" sizes="114x114">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/home">LittleChits</a>
<div class="container nav-collapse">
<ul class="nav">
<li><%= link_to "Home", "/home" %></li>
<li><%= link_to "How it Works", "/howitworks" %></li>
<li><%= link_to "About Us", "/thestory" %></li>
<li><%= link_to "Plans & Pricing", "/posts/new" %></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<div class="content">
<div class="row">
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>
<%= yield %>
</div><!--/row-->
</div><!--/content-->
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<%= javascript_include_tag "application" %>
</body>
</html>
시도해 보았습니다. 작동하지 않았습니다 ... 위의 application.html.erb 코드를 참조하십시오. (플래쉬 코드는 끝이 가까워짐) – hikmatyar