开发者

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 i.e. 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


The proper route for rails 3 should be

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:

  • Ruby on Rails Official Guides
  • Ruby on Rails Tutorial: Learn Rails by Example
  • Rails for Zombies
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜