Question

I have a rails app whose homepage is as follows:

www.person.com

I then have a model - Person who has an id attribute.

If I want to create a view based on that ID, and I want the URL to look like this:

www.person.com/{Person.id}, or www.person.com/1

where should I create my view and what should I name it? Should it just be Views/Person/index.html.erb?

Was it helpful?

Solution

Rather, create show.html.erb in views/person(s)/

You also need to create a controller method in persons_controller.rb:

def show
  # Insert options for person's page here
end

The magic happens in routes.rb, where you'll define the route for that show:

resources :persons, :path => '', :path_names => {:show => '/:id'}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top