DRY relative to edit and show

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

DRY relative to edit and show

Greg Freemyer
I'm a newbie, but it seems like edit and show should somehow share a
partial form.

In particular I've customized the layout of my edit form by using a
table and multiple rows/columns and I want my show form to look the
same.

Currently I've modified my show view to use _form, but now all the
fields are read/write and obviously they need to be read only on the
show form.

Any ideas, or just do form layout work twice?

Thanks
Greg
--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: DRY relative to edit and show

Toby Boudreaux
If none of your fields in your 'show' action are editable, why do you
want to use a form?

Assuming you want a form (in a table) for editing and a table for
showing, it isn't redundant (or in violation of the DRY rule) to have
separate partials or views. The two are inherently different.



Greg Freemyer wrote:

> I'm a newbie, but it seems like edit and show should somehow share a
> partial form.
>
> In particular I've customized the layout of my edit form by using a
> table and multiple rows/columns and I want my show form to look the
> same.
>
> Currently I've modified my show view to use _form, but now all the
> fields are read/write and obviously they need to be read only on the
> show form.
>
> Any ideas, or just do form layout work twice?
>
> Thanks
> Greg
> --
> Greg Freemyer
> The Norcross Group
> Forensics for the 21st Century
> _______________________________________________
> Rails mailing list
> [hidden email]
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: DRY relative to edit and show

codeslush
I have ran into the same concern and fundamentally feel like it is a duplication of effort - even though the two actions perform different purposes I want them to share 100% of the look-and-feel.  I find myself copying and pasting the appropriate show and edit files every time and then going through and changing them as necessary for the designated action.
 
When I want to change the look-and-feel of one, I have to change the other as well.  I understand Toby's argument, but it doesn't change the fact that it is duplicating the effort.
 
It would be nice if rails had a native way to set all the readonly attributes (or enabled, etc... as appropriate for the control) to true or false based on the view being a show or edit.  This would eliminate the duplication we see between the actions.
 
Just my opinion! 
 
Michael


Toby Boudreaux <[hidden email]> wrote:
If none of your fields in your 'show' action are editable, why do you
want to use a form?

Assuming you want a form (in a table) for editing and a table for
showing, it isn't redundant (or in violation of the DRY rule) to have
separate partials or views. The two are inherently different.



Greg Freemyer wrote:

> I'm a newbie, but it seems like edit and show should somehow share a
> partial form.
>
> In particular I've customized the layout of my edit form by using a
> table and multiple rows/columns and I want my show form to look the
> same.
>
> Currently I've modified my show view to use _form, but now all the
> fields are read/write and obviously they need to be read only on the
> show form.
>
> Any ideas, or just do form layout work twice?
>
> Thanks
> Greg
> --
> Greg Freemyer
> The Norcross Group
> Forensics for the 21st Century
> _______________________________________________
> Rails mailing list
> [hidden email]
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails


Yahoo! for Good - Make a difference this year.
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: DRY relative to edit and show

Greg Freemyer
In reply to this post by Toby Boudreaux
On 12/23/05, Toby Boudreaux <[hidden email]> wrote:
> If none of your fields in your 'show' action are editable, why do you
> want to use a form?
>
> Assuming you want a form (in a table) for editing and a table for
> showing, it isn't redundant (or in violation of the DRY rule) to have
> separate partials or views. The two are inherently different.
>
your right, I don't need a form.  Just trying to eliminate the
redundant table layouts.

Greg
--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: DRY relative to edit and show

Rich Clingman
In reply to this post by codeslush
> It would be nice if rails had a native way to set all the readonly attributes (or enabled, etc... as appropriate for the control) to true or false based on the view being a show or edit.  This would eliminate the duplication we see between the actions. <
 
If you're using the RoR helpers to create the forms (/app/views/.../_form)
    <%= text_field 'table', 'field'  %>
, what about creating an application-wide helper that will set read-only attribute based on a flag or global?
    <%= my_text_field 'table', 'field',  read_only %>
 
Rich Clingman
 
----- Original Message -----
Sent: Friday, December 23, 2005 10:13 AM
Subject: Re: [Rails] DRY relative to edit and show

I have ran into the same concern and fundamentally feel like it is a duplication of effort - even though the two actions perform different purposes I want them to share 100% of the look-and-feel.  I find myself copying and pasting the appropriate show and edit files every time and then going through and changing them as necessary for the designated action.
 
When I want to change the look-and-feel of one, I have to change the other as well.  I understand Toby's argument, but it doesn't change the fact that it is duplicating the effort.
 
It would be nice if rails had a native way to set all the readonly attributes (or enabled, etc... as appropriate for the control) to true or false based on the view being a show or edit.  This would eliminate the duplication we see between the actions.
 
Just my opinion! 
 
Michael


Toby Boudreaux <[hidden email]> wrote:
If none of your fields in your 'show' action are editable, why do you
want to use a form?

Assuming you want a form (in a table) for editing and a table for
showing, it isn't redundant (or in violation of the DRY rule) to have
separate partials or views. The two are inherently different.



Greg Freemyer wrote:

> I'm a newbie, but it seems like edit and show should somehow share a
> partial form.
>
> In particular I've customized the layout of my edit form by using a
> table and multiple rows/columns and I want my show form to look the
> same.
>
> Currently I've modified my show view to use _form, but now all the
> fields are read/write and obviously they need to be read only on the
> show form.
> < BR>> Any ideas, or just do form layout work twice?
>
> Thanks
> Greg
> --
> Greg Freemyer
> The Norcross Group
> Forensics for the 21st Century
> _______________________________________________
> Rails mailing list
> [hidden email]
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails


Yahoo! for Good - Make a difference this year.


_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails

_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails