Hey all, Does any have suggestions to whether I should create a controller for every web page on my site or just create an action for every web page in same controller if those actions will never require database calls? It doesn''t make sense to create a controller/model for a single web page if it isn'';t going to require sql. However, I do need the url to actual show the different page just as in any site. So I''m just curious what are best practices to approach this. Thanks for any response. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
write the function @ application_controller that can be access in any controller. for more info read abt application controller doc. nirosh -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
nirosh wrote:> write the function @ application_controller that can be access in any > controller. > for more info read abt application controller doc. > > niroshHey thanks for the response. What about the image paths. This is in css and it''s not linking to the images folder: background: #b8e5d1 url(/public/images/mastgrad.png) top left no-repeat; public/images incorrect path? I don''t understand because it looks like thats the path structure in my app. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, May 23, 2010 at 5:07 AM, John Merlino <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> nirosh wrote: >> write the function @ application_controller that can be access in any >> controller. >> for more info read abt application controller doc.Or create a utility controller, call it "home" or whatever, that handles all the non-model pages you need. That''s pretty typical.> What about the image paths. This is in css and it''s not linking to the > images folder: > background: #b8e5d1 url(/public/images/mastgrad.png) top left no-repeat; > > public/images incorrect path? I don''t understand because it looks like > thats the path structure in my app."public" is the root directory of all the static resources -- so you only want to use `background: #b8e5d1 url( /images/mastgrad.png ) ...` HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
John Merlino wrote:> Hey all, > Does any have suggestions to whether I should create a controller for > every web page on my site or just create an action for every web page in > same controller if those actions will never require database calls?Do neither. Use a single controller action for your static pages, and give it the name of the page as a parameter.> It > doesn''t make sense to create a controller/model for a single web page if > it isn'';t going to require sql.That''s poor reasoning.> However, I do need the url to actual > show the different page just as in any site. So I''m just curious what > are best practices to approach this. Thanks for any response.You can use routing to make the URLs be anything you like. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, May 23, 2010 at 9:12 AM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> John Merlino wrote: > > Hey all, > > Does any have suggestions to whether I should create a controller for > > every web page on my site or just create an action for every web page in > > same controller if those actions will never require database calls? > > Do neither. Use a single controller action for your static pages, and > give it the name of the page as a parameter. >If the OP is, in fact, talking about static pages, you might consider, for performance reasons, putting them in a structure under /public and letting Apache, et.al. deliver them without the involvement of mongrel / passenger / your rails app. HTH, Bill -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I understand the idea of having apache serving static content but anyways what do you think about this as i am with similar question in mind. #controller class HomeController < ApplicationController def index page = params[''page''] if page begin render "page_views/" + page rescue ActionView::MissingTemplate render "errors/404.html", :status=> 404 end end end end #router as the last 2 lines after all options have been excluded match ''/:page'' => ''home#index'' , :as=> :page root :to => "home#index" Would this be good practice? Might be raw but it does the job for my needs. What you think folks On May 23, 7:06 pm, Bill Walton <bwalton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, May 23, 2010 at 9:12 AM, Marnen Laibow-Koser > <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > > > John Merlino wrote: > > > Hey all, > > > Does any have suggestions to whether I should create a controller for > > > every web page on my site or just create an action for every web page in > > > same controller if those actions will never require database calls? > > > Do neither. Use a single controller action for your static pages, and > > give it the name of the page as a parameter. > > If the OP is, in fact, talking about static pages, you might consider, for > performance reasons, putting them in a structure under /public and letting > Apache, et.al. deliver them without the involvement of mongrel / passenger / > your rails app. > > HTH, > Bill > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
I understand the idea of having apache serving static content but anyways what do you think about this as i am with similar question in mind. #controller class HomeController < ApplicationController def index page = params[''page''] if page begin # page var is the same as the name of my "page.html.erb" as in about.html.erb to process a param with value about etc.. render "page_views/" + page rescue ActionView::MissingTemplate render "errors/404.html", :status=> 404 end end end end #end of class #router as the last 2 lines after all options have been excluded match ''/:page'' => ''home#index'' , :as=> :page root :to => "home#index" Would this be good practice? Might be raw but it does the job for my needs. What you think folks On May 23, 7:06 pm, Bill Walton <bwalton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, May 23, 2010 at 9:12 AM, Marnen Laibow-Koser > <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > > > John Merlino wrote: > > > Hey all, > > > Does any have suggestions to whether I should create a controller for > > > every web page on my site or just create an action for every web page in > > > same controller if those actions will never require database calls? > > > Do neither. Use a single controller action for your static pages, and > > give it the name of the page as a parameter. > > If the OP is, in fact, talking about static pages, you might consider, for > performance reasons, putting them in a structure under /public and letting > Apache, et.al. deliver them without the involvement of mongrel / passenger / > your rails app. > > HTH, > Bill > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.