Forum: Ruby on Rails Displaying/Editing data fields shortcut?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms. (Guest)
on 2013-07-24 20:41
(Received via mailing list)
I have several pages of data (Customer address info, etc) that I want to
minimize the code I have to write to display & edit the fields.

I thought of pointing show and edit to the same view, so they use the
html layout. The only difference, is that the text fields are wrapped in
function that looks are the controller action to determine if the field
displayed as text, or is an editable item.

Would this be considered too much of an ugly hack?


  def tfMacro(cl, member, text, options = {})
    (controller.action_name =~ /edit|new|dup/)? (text_field cl, member,
options) : "<i>#{text}</i>"
This topic is locked and can not be replied to.