从我的 app/assets/images 向我的 Rails 应用程序添加徽标

Posted

技术标签:

【中文标题】从我的 app/assets/images 向我的 Rails 应用程序添加徽标【英文标题】:adding logo to my rails app from my app/assets/images 【发布时间】:2021-08-11 17:22:16 【问题描述】:

我正在使用 rails 和 tailwind css 开发我的 intagram 克隆应用程序。我已经设法创建了一个导航栏,我正在尝试在“导航栏”的左侧添加一个徽标,但是当我在本地运行它时,图像没有加载。

我的 navbae.html.erb :

<nav class="flex justify-between items-center">
  <a href=<%= root_path %>>
  <%= image_tag "/images/logo.png" %>
  </a>  
  <div>
    <% if user_signed_in?%>
        <a><%= link_to"Home", root_path, class: "text-lg no-underline text-grey-darkest hover:text-blue-dark ml-2"%> <i class="fas fa-home"></i></a>
        <a><%= link_to"My profile", profile_path(current_user.username), class: "text-lg no-underline text-grey-darkest hover:text-blue-dark ml-2"%> <i class="far fa-user"></i> </a>
        <a><%= link_to"New Post",new_post_path, class: "text-lg no-underline text-grey-darkest hover:text-blue-dark ml-2"%> <i class="fas fa-plus-square"></i></a>
        <a><%= link_to "log out", destroy_user_session_path,method: :delete, class: "text-lg no-underline text-grey-darkest hover:text-blue-dark ml-2" %> <i class="fas fa-sign-out-alt"></i></a>
        <%else%>
    <a><%= link_to "sign up", new_user_registration_path,class: "text-lg no-underline text-grey-darkest hover:text-blue-dark ml-2" %> <i class="fas fa-user-plus"></i></a>
    <a><%= link_to "sign in", new_user_session_path,class: "text-lg no-underline text-grey-darkest hover:text-blue-dark ml-2" %><i class="fas fa-sign-in-alt"></i></a>
  <%end%>
  </div>
</nav>

【问题讨论】:

【参考方案1】:

如果您的徽标位于此路径app/assets/images/logo.png,您也许应该这样做

<%= image_tag 'logo.png' %>

【讨论】:

以上是关于从我的 app/assets/images 向我的 Rails 应用程序添加徽标的主要内容,如果未能解决你的问题,请参考以下文章

我如何从我的 GUI 向我的 matlab 模拟工作区 struct() 提供输入

带有资产管道的背景图像

Rails 4:资产未在生产中加载

如何使用 @rails/webpacker 加载本地字体?

Rails 不会在生产模式下加载我的图像资产

我试图向我的不和谐机器人添加播放命令,但是