Skip to content

Instantly share code, notes, and snippets.

Created March 19, 2011 19:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chikamichi/877737 to your computer and use it in GitHub Desktop.
Apotomo support for builders
# in lib/apotomo/widget.rb
# This comes redundant with Cells internals, but this is due to what may be a flaw in current Apotomo's design,
# which bypass Cells workflow (render_cell_for) and hook directly into AbstractController::Rendering #render_state
# Renders the +widget+ (instance or id).
def render_widget(widget_id, state=:display, *args)
if widget_id.kind_of?(Widget)
widget = widget_id
widget = find_widget(widget_id) or raise "Couldn't render non-existent widget `#{widget_id}`"
# *** added ***
# Ensure the proper widget class is used in case the widget delegates to some other fellow
target_class = self.class.build_class_for(parent_controller, widget.class, args.first)
if widget.class != target_class
widget =, widget_id, args.first)
# *** /added ***
widget.invoke(state, *args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment