Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Routing the home page to another page

routing

  • Please log in to reply
3 replies to this topic

#1 dharani

dharani

    Passenger

  • Members
  • 1 posts

Posted 04 November 2013 - 10:32 AM

I generated a controller with name "welcome" and an action with name "index"...I have changed the content of index to "hello Rails"....Now, I wish to make this the home page, rather than the default home page...

Im trying to route it by editing the config/routes.rb but it is not happening...The code in my config/routes.rb is:

 

Blog::Application.routes.draw do
  get "welcome/index"
  root to: 'welcome#index'
end
 
Thats all...I dont know why it is'nt working.Please do help.Im new to RoR.I'm using Ruby 1.9.3 and Rails version 4.0.1.


#2 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 04 November 2013 - 05:01 PM

Have you restarted your Rails server afterwards?

 

The 

get "welcome/index"

part doesn't make sense. What you probably mean is something like

resource :welcome, only: [:index]

to only make the index-method available on the welcome-controller.


Blog: http://ohm.sh | Twitter: madsohm


#3 gorrillamcd

gorrillamcd

    Passenger

  • Members
  • 4 posts
  • LocationGuadalajara, Mexico

Posted 08 November 2013 - 10:09 PM

get "welcome/index"

 is a route that's used in the Rails 4 Getting Started guide. Dharani, you don't need the `to:` on root. Try it without like this:

root "welcome#index"

  • Jamie likes this

#4 Jamie

Jamie

    Controller

  • Moderators
  • 114 posts
  • LocationThe UK

Posted 12 November 2013 - 08:30 AM

get "welcome/index"

 is a route that's used in the Rails 4 Getting Started guide. Dharani, you don't need the `to:` on root. Try it without like this:

root "welcome#index"

 

I'd agree. Don't forget the / and # do different things in that context dharani.


Rails developer based in Newcastle, UK.
Web app owner - Twitter lover





Also tagged with one or more of these keywords: routing

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users