Hi, I''ve read posts on approaches to handling static files, but my question is a little different. I am mixing and matching dynamic and static pages for an "employee" section of a website. So I have apps/controller/employee_controller.rb and associated view stuff. But I also have public/employee/*.html But of course if I trying this: http://localhost:3000/employee/main.html I get: Action Controller: Exception caught Unknown action No action responded to main.html How would I use routes.rb to by-pass EmployeeController when the request ends in .html, so that Rails justs looks in public/employee/ for such requests? Or do I really need different names so the controller and public/employee/ don''t clash? Thanks. Paul -- 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 -~----------~----~----~----~------~----~------~--~---
It''s working now. I added this to routes.rb: map.connect "employee/:name", :controller => "employee", :action => "show_page", :section => "employee" And now this works: http://localhost:3000/employee/main (dynamically rendering a page via show_page action and corresponding template) And this works: http://localhost:3000/employee/main.html (rendering the static file public/employee/main.html and by-passing the controller) Now I just need to figure out *why* it works... Cheers -- 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 -~----------~----~----~----~------~----~------~--~---
Paul Harv wrote:> > Hi, > > I''ve read posts on approaches to handling static files, but my question > is a little different. > > I am mixing and matching dynamic and static pages for an "employee" > section of a website. > > So I have > apps/controller/employee_controller.rb and associated view stuff. > > But I also have > public/employee/*.html > > But of course if I trying this: > > http://localhost:3000/employee/main.html > > I get: > Action Controller: Exception caught > Unknown action > No action responded to main.html > > How would I use routes.rb to by-pass EmployeeController when the request > ends in .html, so that Rails justs looks in public/employee/ for such > requests? > > Or do I really need different names so the controller and > public/employee/ don''t clash? >Yes I think you already have the answer. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 6, 2006, at 4:31 PM, Paul Harv wrote:> > It''s working now. I added this to routes.rb: > > map.connect "employee/:name", :controller => "employee", :action => > "show_page", :section => "employee" > > And now this works: > http://localhost:3000/employee/main > (dynamically rendering a page via show_page action and corresponding > template) > > And this works: > http://localhost:3000/employee/main.html > (rendering the static file public/employee/main.html and by-passing > the > controller) > > Now I just need to figure out *why* it works...I bet the reason is 1. First the web server looks for a static resource 2a. If it finds it on disk it serves it 2b. Otherwise it calls the Rail''s dispatcher If that''s correct you are going through 2a. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 6, 2006, at 4:52 PM, Xavier Noria wrote:>> It''s working now. I added this to routes.rb: >> >> map.connect "employee/:name", :controller => "employee", :action => >> "show_page", :section => "employee" >> >> And now this works: >> http://localhost:3000/employee/main >> (dynamically rendering a page via show_page action and corresponding >> template) >> >> And this works: >> http://localhost:3000/employee/main.html >> (rendering the static file public/employee/main.html and by-passing >> the >> controller) >> >> Now I just need to figure out *why* it works... > > I bet the reason is > > 1. First the web server looks for a static resource > > 2a. If it finds it on disk it serves it > > 2b. Otherwise it calls the Rail''s dispatcher > > If that''s correct you are going through 2a.Well, that certainly does not coincide with the reported behaviour at the beginning of the thread, but it is certainly what WEBrick does: def service(req, res) #:nodoc: unless handle_file(req, res) begin REQUEST_MUTEX.lock unless ActionController::Base.allow_concurrency unless handle_dispatch(req, res) raise WEBrick::HTTPStatus::NotFound, "`#{req.path}'' not found." end ensure unless ActionController::Base.allow_concurrency REQUEST_MUTEX.unlock if REQUEST_MUTEX.locked? end end end end If handle_file() succeeds Rails is not reached. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---