Alex Baranosky
Alex Baranosky

Reputation: 50064

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.

Upvotes: 0

Views: 128

Answers (2)

Veger
Veger

Reputation: 37906

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

Upvotes: 1

Alex Baranosky
Alex Baranosky

Reputation: 50064

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

Upvotes: 0

Related Questions