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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Mar 07, 2007 at 05:53:42AM -0800, ned.c.amazotz wrote :> 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?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. -- ,========================. | Pierre-Alexandre Meyer | | email : pam-1sEOgp2Wo8Qdnm+yROfE0A@public.gmane.org | `========================'' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 7, 2007, at 2:53 PM, ned.c.amazotz wrote:> 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.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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---