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 <[email protected]> wrote:
> On Sun, May 23, 2010 at 9:12 AM, Marnen Laibow-Koser
> <[email protected]>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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.