how to exclude field from edit

I'd like to exclude certain fields from rails' edit view. I want the value of these fields to be calculated by the database. I'd like the value visible in rails, but I'd like to hide the field when in edit mode. Can I do this? How?

TIA.

You can access in your view to controller.action_name. So you could write a my_text_field(params) helper working like:

controller.action_name != 'edit' ? text_field(params) : hidden_field(params)

Hope I've understood your problem.

The programmer chooses the fields to show in a form. In you are using scaffolding you'll need to adapt the edit view to your needs.

On the other hand, if in addition you need to ensure users don't inject values in that field have a look at attr_protected and, in recent Rails, attr_readonly.

-- fxn