active_scaffold :something do |config|
config.list.columns = [ :initial, :columns ]
end
def update_table_config
get_columns_for_run(params[:run_id]).each do |column_name|
active_scaffold_config.list.columns.add column_name
end
This was working but it had one dramatic bug. Each subsequent request
of the controller caused the set of columns to be re-added.
I thought I could solve this by storing a constant with the base set
of columns then just use columns = before my .add.
DEFAULT_COLUMNS = [ :initial, :columns ]
active_scaffold :something do |config|
config.list.columns = DEFAULT_COLUMNS
end
def update_table_config
active_scaffold_config.list.columns = DEFAULT_COLUMNS
get_columns_for_run(params[:run_id]).each do |column_name|
active_scaffold_config.list.columns.add column_name
end
But I get an odd exception when I try this. Unfortunately, I'm not at
the office right now so I can't give the exact error, but it was
something to do with active_scaffold.class or some-such. :(
I was hoping someone might be able to just look at this code and
clearly see some thing that I did wrong or suggest the right way to do
it.
If it doesn't make enough sense, I'll post the actual code snippits
and full error message when I get into the office.
Thanks, Daniel
On May 10, 11:59 am, "Lance Ivy" <l...@cainlevy.net> wrote:
> Also try:
>
> active_scaffold_config.list.columns.add(column_name) unless
> active_scaffold_config.list.columns.include?(column_name)
>