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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
72194fb0ebfff4114fb39f3806661f9f?d=identicon&s=25 xscribe@gmail.com (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
same
html layout. The only difference, is that the text fields are wrapped in
a
helper
function that looks are the controller action to determine if the field
is
displayed as text, or is an editable item.

Would this be considered too much of an ugly hack?

-p


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