Is there a quick and easy way to hide certain attributes? For example, with ''members'', I don''t want the password field to show up in ''list''. Something like ''attr_protected :password''. thanks csn __________________________________ Yahoo! Mail - PC Magazine Editors'' Choice 2005 http://mail.yahoo.com
If you''re basing your views on the standard scaffold, you can limit the columns displayed by generating the list of content_columns in the controller action: @content_columns = User.content_columns @content_columns.delete_if { |c| ["salted_password", "salt", "security_token", "token_expiry"].include?(c.name) } ... and then in your list.rhtml view: <% for column in @content_columns %> <th><%= column.human_name %></th> <% end %> etc. - james On 11/11/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Is there a quick and easy way to hide certain > attributes? For example, with ''members'', I don''t want > the password field to show up in ''list''. Something > like ''attr_protected :password''. > > thanks > csn > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors'' Choice 2005 > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
james.adam wrote:> If you''re basing your views on the standard scaffold, you can limit > the columns displayed by generating the list of content_columns in the > controller action: > > @content_columns = User.content_columns > @content_columns.delete_if { |c| ["salted_password", "salt", > "security_token", "token_expiry"].include?(c.name) }Thanks, this works great on the level of a single controller. But how can I implement hiding on a more global level, e.g. if I never wanted to show the lock_version or created_at fields in list tables generated by scaffolds? My guess is to put this code in controllers/application.rb but what do I use for the object? @content_columns = __WHATHERE?__.content_columns @content_columns.delete_if { |c| ["salted_password", "salt", "security_token", "token_expiry"].include?(c.name) } Thanks for your help R -- Posted via http://www.ruby-forum.com/.