Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 额外空白<;a></a>;出现_Ruby On Rails - Fatal编程技术网

Ruby on rails 额外空白<;a></a>;出现

Ruby on rails 额外空白<;a></a>;出现,ruby-on-rails,Ruby On Rails,当我进入菜单登录时,它工作得非常好,没有任何额外的功能,但是当我登录时,顶部有一个额外的空白。我怎样才能解决这个问题 服务器端html.erb <div id="myDropdown" class="dropdown-content"> <% if user_signed_in? %> <a><%= link_to('My Account', edit_user_registration_path) %> &

当我进入菜单登录时,它工作得非常好,没有任何额外的功能,但是当我登录时,顶部有一个额外的空白。我怎样才能解决这个问题

服务器端html.erb

    <div id="myDropdown" class="dropdown-content">
    <% if user_signed_in? %>
      <a><%= link_to('My Account', edit_user_registration_path) %>
      <%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
    <% else %>
      <%= link_to('Log in', new_user_session_path) %>
      <%= link_to('Sign up', new_user_registration_path) %></a>
    <% end %>
    </div>

它看起来像什么


我认为您不必编写显式标记

<%= link_to "Home", root_path %>
# => <a href="/">Home</a>

# => 
So

<%= link_to('My Account', edit_user_registration_path %>
# => <a href="/users/edit">My Account </a>

# => 
要删除额外的href标记one,只需从代码中删除标记及其结束语。它将正确渲染视图


这对我不起作用。我没有显示任何内容,而是出现语法错误。请不要复制过去。我刚才解释了link_to metho的作用。只需从代码中删除和,它就可以正常工作。我现在明白了。非常感谢你!
<%= link_to('My Account', edit_user_registration_path %>
# => <a href="/users/edit">My Account </a>