Dynamic Columns with Ajax Scaffold
October 28th, 2006
I”ve been asked a couple of times how to dynamically setup the columns displayed by the AS plugin dependant on the permissions of the user, so I though a quick post would be a good idea.
Basically its very simple, you simply define a hash of all the columns you potentially wish to display keyed by the column name, so something like:
@@columns_hash[:user] = ScaffoldColumn.new(..) @@columns_hash[:foo] = ScaffoldColumn.new(:name => 'bar')
Then define a before_filter along the lines of:
before_filter :create_columns, :only => ['table', 'update_table']Read the rest of this entry