Polymorphic_path not getting generated


I am trying to use the Savage Beast plugin in a polymorphic way. I
have setup my model as below

Leaving out other details from models

class Forum < ActiveRecord::Base
has_one :recent_topic, :class_name => ‘Topic’, :order => ‘sticky
desc, replied_at desc’
belongs_to :forum_owner, :polymorphic => true # Helps keep track
of which entity owns this forum

class Topic < ActiveRecord::Base
belongs_to :forum

class School < ActiveRecord::Base
has_many :forums, :as => :forum_owner

Now in the index.html.erb for forum I had the following line
<%= link_to t(:view), forum_topic_path(:forum_id => forum, :id
=> forum.recent_post.topic_id, :page =>
forum.recent_post.topic.last_page, :anchor =>
forum.recent_post.dom_id) %>

This line generates “
page=1#posts-1” as the url. To make it polymorphic, I need the schools
in the url so the url needs to change to “
schools/1/forums/1/topics/1?page=1#posts-1”. So I replaced the above
line with

<%= link_to t(:view), polymorphic_path([@forum_owner, forum,
forum.recent_topic], :page =>
forum.recent_post.topic.last_page, :anchor =>
forum.recent_post.dom_id) %>

@forum_owner and other variables are properly initialized. But this
gives the error --> undefined method `school_forum_topic_path’ for

Apparently the school_forum_topic_path doesn’t get generated. How do I
make sure that school_forum_topic_path function call gets generated to
return the right path? In other words, how do you generate a
multilevel polymorphic path?

Savage Beast plugin adds the following to the routes.rb

Savage beast routes BEGIN

map.resources :posts, :name_prefix => ‘all_’, :collection =>
{ :search => :get }
map.resources :forums, :topics, :posts, :monitorship

%w(forum).each do |attr|
map.resources :posts, :name_prefix => “#{attr}_”, :path_prefix =>

map.resources :forums do |forum|
forum.resources :topics do |topic|
topic.resources :posts
topic.resource :monitorship, :controller => :monitorships

Savage beast routes END

map.resources :schools, :has_many => :forums # <------------ I
added this line

Thanks for your help,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs