我有一句话,在我的布局/申请中填满了链接,希望目前的位置与“积极”相挂钩。
现在使用:
<%= link_to About Us , { :controller => aboutus }, :class => "menu#{ active if params[:controller] == aboutus }" %>
但是,这对我来说是一种 pre。
没有人有更好的想法?
我有一句话,在我的布局/申请中填满了链接,希望目前的位置与“积极”相挂钩。
现在使用:
<%= link_to About Us , { :controller => aboutus }, :class => "menu#{ active if params[:controller] == aboutus }" %>
但是,这对我来说是一种 pre。
没有人有更好的想法?
您可以采用类似于“联系”的助手方法。
其名称为“联系_to_unless_ Current”。
rel=“noreferer”http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelpers.html (详见本文)
HTH
<代码>link_to_unless_ Current 这种方法实际上不会产生联系,也不会增加一个活跃的类别。 如果你仍然愿意这样做,你可以使用<代码>当值_page方法,核对本页是否与你指明的路线相吻合:
<ul id="main_nav">
<li><%= link_to "Search", search_path, :class => ( active if current_page?(search_path)) %></li>
</ul>
或者,如果你想在总结要素上增加这一类别:
<li class="<%= active if current_page?(search_path) %>">
<%= link_to "Search", search_path %>
</li>
一条带有li子扎根的道路的范例,即试图用 content子做,但如果情况如此,则不会uck。
<li<%= " class= active ".html_safe if current_page?(root_path) %>>
<%= link_to "Home", root_path %>
</li>
i 在将班级与boot锁保持空白时,会有一些问题(如果我记得好的话)
collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...
We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...
As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...
I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?
I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...
I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml
guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...
I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...