Ruby on Rails Wednesday, January 5, 2011

I have an app that manages tapes. Each tape has a number (separate from
the record ID in MySQL).

When a tape is added, the number field can be filled in. But when the
record is subsequently edited, the number should not be editable.

Both the "new" and "edit" views include (render) the same form partial.
What would be considered best practice here?

1. Logic in the partial that checks to see if the action is "new" or
"edit", and changes the form appropriately

2. Two different partials.

3. Remove the partial rendering and just have the "new" and "edit" views
be complete forms

I'm also interested in the "Rails philosophy" behind any recommendation.
For example, I'd think that choice 1 is frowned upon, because it puts
logic in a view, which should be minimized. But that choice creates the
least amount of duplication, so it may make the code easier to manage
long term. Which idea takes precedence?

--
Posted via http://www.ruby-forum.com/.

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment