Wednesday, July 24, 2013

[Rails] Displaying/Editing data fields shortcut?

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/736810bc-2ef9-4eb6-9238-69e4167e556e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate