0

私はRailsにかなり慣れていないので、メソッドをActiveViewクラスに追加して、パーシャルから新しいメソッドにアクセスできるようにする方法を見つけようとしています。

サンプルコードは次のとおりです。

%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 にその存在を認識させるのに苦労しています。

ありがとう。

4

2 に答える 2

1

2行目の呼び出しcurrent_aimが正しくないため、これに変更する必要があります

=link_to "#{h aim_small.description.shorten} #{current_aim if aim_small.description == current_aim.description}", :action => 'show', :id => aim_small
于 2010-01-17T08:45:59.650 に答える
0

メソッド「current_aim」をApplicationHelperに入れるだけです:)

于 2010-01-17T06:17:56.417 に答える