Hide attributes?

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

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 %>

<%= column.human_name %>
<% end %>

etc.

  • james

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