这是我要转换为link_to的代码
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?category=Video+and+animation">Show me everything</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Intro">Intro</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Animation+%26+3D">Animation & 3D</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Editing+and+Post+Production">Editing and Post Production</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Other">Other</a></li>
</ul>
这就是它的样子
你将如何转换为例如
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Intro">Intro</a></li>
进入 <%= link_to "Intro", some_path(that goes to the above Url), method: :get %>
或者你如何将方法:: get 添加到上面的html href ,我需要它进行无休止的滚动,turbo链接会导致问题,所以我有使用方法:: get
这是seeds.rb我起诉用它的子类别创建类别
@category = Category.create!(name: "Video and animation")
["Intro", "Animation & 3D", "Editing and Post Production", "Other"].each do |name|
@subcategory = Subcategory.create!(name: name, category_id: @category.id)
end
答案 0 :(得分:1)
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?category=Video+and+animation" data-method="get">Show me everything</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Intro" data-method="get">Intro</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Animation+%26+3D" data-method="get">Animation & 3D</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Editing+and+Post+Production" data-method="get">Editing and Post Production</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Other" data-method="get">Other</a></li>
</ul>