图像未显示应用程序布局

时间:2013-09-06 06:26:00

标签: html ruby-on-rails-4 assets

我的application.html.erb中有一张图片。它在我的根视图中正确显示,但当我移动到login时,该图像消失了。我所说的图像是ChainLogo.png。我有什么想法吗?

我的根布局现在看起来像这样:

<%= stylesheet_link_tag "home", :media => "all" %>
<div id="home_log_in">
    <%= link_to 'Log-in', login_index_path %>
</div>

我的application.html.erb看起来像这样:

<!DOCTYPE html>
<html>
<head>
  <title>Chain</title>
  <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= yield %>
    <div id="main_banner"> </div>
    <div id="main_logo"><img src="assets/images/ChainLogo.png"></div> 

</body>
</html>

我的login.html.erb看起来像这样:

<%= stylesheet_link_tag "login", :media => "all" %>

<div id="signin_form">  
    <%=form_for :user  do |f| %>

        <%= f.text_field :email, :id => "email_input", :placeholder => "enter email" %>             
    <div id="signmeup_button">
        <%= f.text_field :password, :id => '"password', :placeholder => "enter password"%>
    </div>

    <div id="just_email_signup">
        <%= f.submit %> 

    <% end %>
    </div>

</div>

1 个答案:

答案 0 :(得分:1)

请使用rails标记在application.html.erb文件中附加图片<img src="assets/images/ChainLogo.png">,而不是此<%= image_tag "ChainLogo.png" %>