DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Generic Actions

12.24.2005
| 1131 views |
  • submit to reddit
        // Generic Actions


  def selector selector_type
    # do normal selector crap
    # TODO: iterate model... find id's build selection
    # find text's build searchable intellitext actions
    # bind information
    # ------------------------

    # render specified template
    @dKlass = instance_eval("#{selector_type.capitalize}")
    tpl_name = "#{selector_type}_selector"
    @iobj = instance_eval("#{selector_type.capitalize}.find(:all)")
    render :partial => "selector"
  end

  def method_missing(method_id, *arguments)
    if match = /selector_(\w*)/.match(method_id.to_s)
        selector( match[1] )
    end
  end