New to rails and I need to make a homepage for my website. I have 3 controllers that will be linked to from the homepage. I don't want to create another controller for the homepage. For example:
I want homepage to be: http://samplepage.com
The homepage will link to: http://samplepage.com/apples http://samplepage.com/bananas http://samplepage.com/carrots
How do I set up the root route? I already have functioning pages for /apples, /banana, /carrots.
Ok, you can use any of your controllers to setup the home page eg:
ApplesController
def home
# intialize instance variable for home page here
end
. . . . .
end
Create view file in app/views/apples/home.html.erb
In your routes
route "apples#home"
Take a look at high_voltage . You will still need to create single controller for your static pages but other than that looks like it what you look for.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.