简体   繁体   中英

Rails routing issue

Hi I've just started learning rails and been going through some tutorials from learning rails (http://www.buildingwebapps.com/podcasts/79335-putting-the-page-contents-into-the)

The tutorials appear to be Rails v2 and I'm on Rails v3

There is a line in the routes file which appears to be causing a problem

map.view_page ':name', :controller => 'viewer', :action => 'show'

The line works for the front end view ie my viewer controller but not for the back end

I get the error

NoMethodError in Viewer#show 

I think this has something to do with the view I am using and the line

<%= @page.body %>

I know it's difficult without the full code but if anyone can help that would be awesome

导轨3的正确路线应为

match ':name' => 'viewer#show', :as => :view_page

Any tutorials for Rails 2 will likely not fully work in Rails 3. I think you're setting yourself up to be very confused.

For instance, the line you pasted from routes.rb is not Rails 3 compatible. It should be:

match ':name' => 'viewer#show', :as => :view_page

I recommend you start with one of these tutorials, all of which use Rails 3:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM