Hi, I had an argument with the web designer about a philosophical(not very practical) issue. Normally, we have new.html.erb and edit.html.erb and they share _form.html.erb as a partial render. The designer said that there should be only one view template and use if-statement for minor differences. For example, they all should be combined into form.html.erb. She thinks that it''s better design-wise. No redundancy, blah blah... I am against it. But I failed to convince her. What do you think? Thanks. Sam -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I wrote my app in your way. So I support you. I don''t think it is better to write only one template for both new and edit. Because they are different methods in controller, and sometimes they take different parameters and submit different parameters too. On Nov 13, 7:33 am, Sam Kong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I had an argument with the web designer about a philosophical(not very > practical) issue. > > Normally, we have new.html.erb and edit.html.erb and they share > _form.html.erb as a partial render. > The designer said that there should be only one view template and use > if-statement for minor differences. > > For example, they all should be combined into form.html.erb. > She thinks that it''s better design-wise. > No redundancy, blah blah... > > I am against it. > But I failed to convince her. > > What do you think? > > Thanks. > > Sam > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
boblu is correct. Look at it from a RESTful perspective: what action is being executed? Create and update are separate actions, thus they need to be represented by separate files. Any crossover and redundancy is to be resolved through the inclusion of partials. On Nov 12, 8:18 pm, boblu <bobl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I wrote my app in your way. So I support you. > I don''t think it is better to write only one template for both new and > edit. > Because they are different methods in controller, and sometimes they > take different parameters and submit different parameters too. > > On Nov 13, 7:33 am, Sam Kong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > Hi, > > > I had an argument with the web designer about a philosophical(not very > > practical) issue. > > > Normally, we have new.html.erb and edit.html.erb and they share > > _form.html.erb as a partial render. > > The designer said that there should be only one view template and use > > if-statement for minor differences. > > > For example, they all should be combined into form.html.erb. > > She thinks that it''s better design-wise. > > No redundancy, blah blah... > > > I am against it. > > But I failed to convince her. > > > What do you think? > > > Thanks. > > > Sam > > -- > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
The web designer is wrong in thinking that because you have separate edit and new views files that most of the page is different and not sharing a greate deal of code. They are ignoring the fact that most template view are views within views. Especially if you are using a partial - where you have a template within a template within a template. The outer template is the layout. Into this is inserted the view. And into this is inserted the form partial. In effect you have: layout | view | partial | view | layout Where the partial is within the view which is within the layout. A classic onion skin type arrangement. With your two views what you effectively have are: layout | edit | form | edit | layout and layout | new | form | new | layout So by choosing a different view you are doing one big if. That is if view is ''edit'' slot the ''edit'' template in the middle layer, or if the view is ''new'' slot the ''new'' template into the middle layer. What''s more this is far neater than using lots of if statements with a single template. You''ve separated the parts that need to be different into two separate files, so far less chance that you''ll confuse the two actions : much less likely that something that should only occur in a new action will pop up in an edit action. You''ve also reduced the number of times you need to run the if. Just once - to decide which middle template to use, rather than at every point in the single template where a choice needs to be made. I think your developer is demonstrating a fundamental lack of understanding about how Rails templates work. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> She thinks that it''s better design-wise. > No redundancy, blah blah...<tongue-in-cheek> She''s a Web Designer... she should go design her CSS files and make pretty pictures with Photoshop, and leave the implementation details to those who know about implementation details... the designer shouldn''t care if its Rails, or php, or the "Next Big Thing"... after all you don''t pee on her images... (you don''t do you? Because that would be bad form) </tongue-in-cheek> -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---