Nebs Petrovic wrote: > Ok I understand what you're saying. I'm not just trying to design > everything before I get my feet wet, I've already started and I know how > to implement features when I can clearly see them fit into an MVC > "model".
(BTW "Ok" is spelled "Okay" - it's a real word. OK is an historical backronym.) The amount of books you seem to have read to get here indicates you like researching before doing! > I just hit a roadblock (which is why I'm here) because I wanted to > accomplish a simple task like "ok, I have a "contact us" link, now I > want it to point to a page that displays contact information". Now my > question is, do I create a controller called ContactInfo and then use > its show method to display this page? Or should this page be a method > call of some other controller? Or none of the above? Do the simplest thing that could possibly work. Just keep telling yourself "You Aren't Gonna Need It." YAGNI. contact_us.html is just names and (shrouded) addresses, so throw it into public/ Its link is now link_to 'Contact Us', '/contact_us.html'. Put that into layout.html.erb, and you are done; all pages have it. > Hypothetical (and unrealistic) situation: Just think of a completly > static website with no control logic, just links to other static pages. > How would you do this with rails? Do you create a controller called > "Website" and have a method for each page? Or do you create a > controller for each page and use their show methods to display the > views? Or do you not even create controllers? The other good thing about YAGNI is it usually errs on the side of performance. Counterexamples abound, but in this case giving static HTML pages to your web server, without any Ruby code between them and your clients, is the most efficient technique! > Ok now stepping out of this hypothetical bubble. Let's say now my > website is filled with static pages but has the ability to login/logout > users (dynamic aspect). Now the user authentication I can deal with in > rails. My problem is how to handle the rest of that static stuff (the > other pages) while still being able to use the application.html.erb as a > layout for every page (including the static ones). Do you see what I > mean? Yes. You are my "onsite customer", and we just wrote a static website in HTML. Now you want logic, so I refactor it. Add the Salted Authentication plugin. Write tests that show some pages require users. (The plugin comes with the login_as test helper.) Use tidy -i -asxhtml --wrap 130 -m file.html to convert the HTML to XHTML (so it's compliant & testable). Fix every error and warning. Move the files from public to app/views/my_controller/ You only need one controller so far. Use routes.rb Pass all the tests, and write tests with assert_generates which check the routes are correct. Now tell me the next feature and I will sketch out the migration path for you! The point is to use tests to ensure that each change - from too simple to less simple - is safe and elegant, not a bunch of hacking and thrashing. -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---