Topic: html_escape inside a controller

I'm trying to call html_escape from within a controller. Maybe this is a bad idea, but I'm doing an AJAX request and I can't think of how to generate the HTML in the view.

Maybe there is a better way. I have a database table with 25 columns, and displaying them all at once is just bad looking. So I have checkboxes at the top of the page where the user can select which columns to view. When the user modifies these checkboxes, I want to send off an AJAX request to grab the columns that they selected and display them on the page.

Right now, this is done with observe_form that calls a method in my controller, and then the controller finds all records and essentially generates the HTML that is in the view, except for all the columns requested, instead of just the one default column.

It seems like there should be a better way, so someone please enlighten me if there is...but if there isn't, how can I call html_escape from within my controller? wink

Last edited by syko (2006-12-19 10:23:30)

Re: html_escape inside a controller

I found a better way of doing it, using render :partial inside the view...so this way the helper stuff is all still in the view and the code in the controller action is minimal. I still would like a faster way than doing a find_all every time the user checks/unchecks a box, but for now this will do.