with only a few omissions that some one new to rails might not know.
First setup the routes so that when entering http://127.0.0.1:3000/about it knows which controller to use.
config/routes.rb
map.root :controller => 'home'
map.home ':page', :controller => 'home', :action => 'show', \
:page => /about|contact/
Now setup the controller.
app/controllers/home_controller.rb
class HomeController < ApplicationController
def index
# render the landing page
end
def show
render :action => params[:page]
end
end
Now create the 'home' folder. so we have a apps/views/home to put about.html or about.html.erb in.
Linking to this page can now be don via:
link_to 'About', home_path('about')
This tutorial was very closely based on 'Has many :through simple pages'
No comments:
Post a Comment