On Dec 6, 2010, at 3:36 PM, Tuishimi wrote: > Struggling. ErrorLogs is the class, it belongs_to error_type. I want > the index page for ErrorLog (error_logs) to have a filter that can > limit selection to error_types... > > My filter-menu happily shows the appropriate error_types... here is > my code. > > def index > finder = params[:error_type] ? > ErrorLog.send(params[:error_type]) : ErrorLog > hobo_index finder > end >
One note on this: don't do this. Consider what might happen, for instance, if somebody passed 'delete_all' in params[:error_type]. Uh-oh! > <collection: replace> > <table-plus fields="this, error_type, detail"> > <empty-message:>No errors found!</empty-message:> > <prepend-header:> > <div class="filter"> > Display by Error Type: > <filter-menu param-name="error_type" > options="&ErrorType.all"/> > </div> > </prepend-header:> > </table-plus> > </collection:> > > > ... > > I get an error saying: > > NoMethodError in Error logsController#index > > undefined method `ERROR_TYPE_1' for #<Class:0x4b919723> > > ...where ERROR_TYPE_1 is one of the errors in the dropdown... > > I've tried following the online stuff I could find for this. I am > sure I am missing something simple. Note that the generated HTML is going to send back whatever the ErrorType models yield from to_s; you may need to munge the value into the correct format if that doesn't match the scopes defined on ErrorLog. --Matt Jones -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
