Monday, May 08, 2006

render_component different from link_to options

This one got me stuck for about an hour. I couldn't figure out why this wasn't calling the method of the component, but it was rendering the view of the component.

render_component :controller => "poll", :action => :show, :id => @event.poll

It ends up that this would be all fine and dandy if it was a call to link_to() rather than render_component even though the nature of the parameters is practically the same. So for render_component(), it should be:

render_component :controller => "poll", :action => "show", :id => @event.poll.id

it needs strings instead of symbols for :action, and it doesn't convert an ActiveRecord object to its id--it needs to be explicitly stated.

No comments:

Post a Comment