Get updates

Scott Passing :id When Rendering a Component

For the time being I’ve decided to forgo acts_as_tree and roll my own solution for nested list display. At this point I don’t think I really need to parse and display the entire tree in one fell swoop, it seems more natural to display the top level and retrieve children of a node when the user clicks and expands the node.

Since my “list” action has been doing fine to display list items, I quickly made it context-aware and used it as a component to render the children of a node when an item is expanded. Consulting my rails book I tried to render like this:

render_component(:action => 'list', :params => { :context => :branch, :id => parent } )

If :id is the parameter I want to pass to my list action so it can render children of parent, it goes in the :params hash, right? Hmm, for some reason my logs show that the component request has the :id value I want, but my list action retrieves a value of nil for :id. What the heck?

It turns out that render_component() is more than a little weird in its format. As I discovered, while other parameters go inside the :params hash, :id won’t work unless it stands alone. The call that works looks like:

render_component(:action => 'list', :params => { :context => :branch }, :id => parent )

Leave a Reply

Fatal error: Uncaught Error: Call to undefined function show_subscription_checkbox() in /home/dmetro/ Stack trace: #0 /home/dmetro/ require() #1 /home/dmetro/ comments_template() #2 /home/dmetro/ include('/home/dmetro/3d...') #3 /home/dmetro/ require_once('/home/dmetro/3d...') #4 /home/dmetro/ require('/home/dmetro/3d...') #5 {main} thrown in /home/dmetro/ on line 90