How to change the default “opening file” in Ruby on Rails

So you delete public\index.html file,

then in
config/routes.rb
map.connect '', :controller => "welcome"

Well… that tell it to connect the default page to the welcome controller’s default action, which is the “index” action:

….app/controllers/whatever.rb
def index
list
render :action => ‘list’
end

So if you so desire and do not have a “welcome” class
then
ruby script\generate controller welcome
then create (through some means) app/views/welcome/index.rhtml and voila you have a Ruby Index page now.

Said differently
If you don’t have a controller “welcome” (already generated) then you can either list a controller that you do have, or create the “welcome” controller thus:

ruby script\generate controller welcome

now you can (if you so desire) edit controllers\welcome_controller.rb

now create make index.rhtml (possibly move public.html there) in
app\views\welcome

and done!

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.