如何在Rails中的link_to中传递div?

时间:2021-09-14 20:44:50

I want to pass a div inside a link_to statement. This is not working for me:

我想在link_to语句中传递一个div。这对我不起作用:

 <%= link_to :controller => 'abouts', :action => 'index', :anchor => 'teacher-account' do %>
    <div class="accordion-inner">
         About Me
    </div>
   <%= end %>

1 个解决方案

#1


1  

The link_to helper supports some options to pass in the url and the html for example: link_to(body, url_options = {}, html_options = {}).

link_to帮助器支持一些传递url和html的选项,例如:link_to(body,url_options = {},html_options = {})。

So you might be able to try this:

所以你可以试试这个:

link_to('About me', { controller: 'abouts', action: 'index' }, anchor: 'teacher-account', class: "accordion-inner")

#1


1  

The link_to helper supports some options to pass in the url and the html for example: link_to(body, url_options = {}, html_options = {}).

link_to帮助器支持一些传递url和html的选项,例如:link_to(body,url_options = {},html_options = {})。

So you might be able to try this:

所以你可以试试这个:

link_to('About me', { controller: 'abouts', action: 'index' }, anchor: 'teacher-account', class: "accordion-inner")