Hi all Very simple question, im sure, but I cant find docs anywhere that tell me how to do this. What I want is for the index page of the server to be generated from rails, is www.wibble.com/ will result in a page that has been processed by rails, has the templates etc.>From what I can see, the index page comes from public/index.html How doI get this to be a rails page? Thanks Jonathan Gill
On Wed, Apr 26, 2006 at 01:27:18AM +0800, Jonathan Gill wrote:> Hi all > > Very simple question, im sure, but I cant find docs anywhere that tell > me how to do this. > > What I want is for the index page of the server to be generated from > rails, is www.wibble.com/ will result in a page that has been processed > by rails, has the templates etc. > > >From what I can see, the index page comes from public/index.html How do > I get this to be a rails page?In config/routes.rb, put something like this: map.connect '''', :controller => "maincontroller", :action => "index" Naturally, you will want to change the names of the controller and the action to suit your own needs. You will also want to move the current public/index.html out of the way. Dan -- Daniel Bye PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc PGP Key fingerprint: D349 B109 0EB8 2554 4D75 B79A 8B17 F97C 1622 166A _ ASCII ribbon campaign ( ) - against HTML, vCards and X - proprietary attachments in e-mail / \ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060425/5f91141c/attachment-0001.bin
Rails pages are handled by routes, and there is no route that matches the root of the domain by default. in config/routes.rb map.connect '''', :controller => ''my_controller'', :action => ''index'' Then delete public/index.html since it will interfer with the routing. Jonathan Gill wrote:> Hi all > > Very simple question, im sure, but I cant find docs anywhere that tell > me how to do this. > > What I want is for the index page of the server to be generated from > rails, is www.wibble.com/ will result in a page that has been processed > by rails, has the templates etc. > >>From what I can see, the index page comes from public/index.html How do > I get this to be a rails page? > > Thanks > > Jonathan Gill-- Posted via http://www.ruby-forum.com/.
Hi Dan> > What I want is for the index page of the server to be generated from > > rails, is www.wibble.com/ will result in a page that has been processed > > by rails, has the templates etc.> In config/routes.rb, put something like this: > > map.connect '''', :controller => "maincontroller", :action => "index" >So if I right, say I have a controller called home that should handle the top level of the site I would use something like : map.connect '''', :controller => "home", :action => "index" Is that right?> You will also want to move the current public/index.html out of the way.I bet I forget that bit :) Thanks Jonathan
Jonathan Gill <jonathan.gill@securecirt.com> writes:> Hi all > > Very simple question, im sure, but I cant find docs anywhere that tell > me how to do this. >Search in the wiki.> What I want is for the index page of the server to be generated from > rails, is www.wibble.com/ will result in a page that has been processed > by rails, has the templates etc. > >>From what I can see, the index page comes from public/index.html How do > I get this to be a rails page?Delete index.html and add the line below to the config/routes.rb file map.connect ''/'', :controller =>"my_controller", ... HTH. -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com Read my blog at: http://cuttingtheredtape.blogspot.com/ ,---- | "War is Peace! Freedom is Slavery! Ignorance is Strength!" | -- Orwell, 1984, 1948 `----
On Wed, Apr 26, 2006 at 01:45:23AM +0800, Jonathan Gill wrote:> Hi Dan > > > > What I want is for the index page of the server to be generated from > > > rails, is www.wibble.com/ will result in a page that has been processed > > > by rails, has the templates etc. > > > In config/routes.rb, put something like this: > > > > map.connect '''', :controller => "maincontroller", :action => "index" > > > > So if I right, say I have a controller called home that should handle > the top level of the site I would use something like : > > map.connect '''', :controller => "home", :action => "index" > > Is that right?Yep, that would do it. Assuming you have the right action and view etc in place to render the home page.> > > You will also want to move the current public/index.html out of the way. > > I bet I forget that bit :)Heheh! If you keep getting the same index page you see now, that should at least serve to jog your memory! Dan -- Daniel Bye PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc PGP Key fingerprint: D349 B109 0EB8 2554 4D75 B79A 8B17 F97C 1622 166A _ ASCII ribbon campaign ( ) - against HTML, vCards and X - proprietary attachments in e-mail / \ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060425/527dee9c/attachment.bin
On Tue, 2006-04-25 at 19:47 +0100, Daniel Bye wrote:> > > > > In config/routes.rb, put something like this: > > > > > > map.connect '''', :controller => "maincontroller", :action => "index" > > >I usually put two lines in for this. It isn''t always needed but I had to have the second line for my plugin to work (broomstick). The second line will allow you to use url_for and have it map back to the correct controller/action instead of just ''/''. Here''s what mine looks like. map.connect ''/maincontroller/index'', :controller => "maincontroller", :action => "index" map.connect '''', :controller => "maincontroller", :action => "index" The above allows you use url_for to get the "long" version of the url and still lets '''' map back to the correct controller/action. Charlie Bowman www.recentrambles.com> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060425/c20d0fa1/attachment.html
On Tue, Apr 25, 2006 at 03:00:20PM -0400, Charlie Bowman wrote:> > On Tue, 2006-04-25 at 19:47 +0100, Daniel Bye wrote: > > > > > > In config/routes.rb, put something like this: > > > > > > map.connect '''', :controller => "maincontroller", :action => > "index" > > > > > I usually put two lines in for this. It isn''t always needed but I had to have > the second line for my plugin to work (broomstick). The second line will allow > you to use url_for and have it map back to the correct controller/action > instead of just ''/''. Here''s what mine looks like. > > map.connect ''/maincontroller/index'', :controller => "maincontroller", :action > => "index" > map.connect '''', :controller => "maincontroller", :action => "index" > > The above allows you use url_for to get the "long" version of the url and still > lets '''' map back to the correct controller/action.Ah! That may well account for some heretofore unfathomed routing weirdness I have been seeing. Thanks, Charlie! Dan -- Daniel Bye PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc PGP Key fingerprint: D349 B109 0EB8 2554 4D75 B79A 8B17 F97C 1622 166A _ ASCII ribbon campaign ( ) - against HTML, vCards and X - proprietary attachments in e-mail / \ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060425/8819781c/attachment.bin