开发者

Rails partials: Trouble finding where to put reference to new method in my partial

I'm fairly new to Rails and am trying to figure out how to add a method to the ActiveView class so I can then access a new method from the partials.

Here's some sample code:

%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

I want to be able to call the current_aim method in the above partial, but am having trouble getting Ruby to recognize its existance.

Thanks.


The call to current_aim in de second line is incorrect, you should change it to this

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


Just put the method 'current_aim' into the ApplicationHelper :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜