2010-01-17 18 views
0

我對Rails相當陌生,想弄清楚如何將方法添加到ActiveView類,以便我可以從諧音。Rails部分:在我的部分中找不到引用新方法的地方

下面是一些示例代碼:

%li 
    =link_to "#{h aim_small.description.shorten} #{"(current aim)" if aim_small.description == current_aim.description}", :action => 'show', :id => aim_small 
    .options 
    =link_to "edit", :controller => 'aims', :action => 'edit', :id => aim_small 
    =link_to "remove", :controller => 'aims', :action => 'destroy', :id => aim_small 

我希望能夠調用current_aim方法在上面的部分,但我有麻煩的Ruby承認它的存在。

謝謝。

回答

1

在德第二行current_aim調用不正確,則應該將其更改爲這個

=link_to "#{h aim_small.description.shorten} #{current_aim if aim_small.description == current_aim.description}", :action => 'show', :id => aim_small 
0

只要把方法「current_aim」到ApplicationHelper :)