I am trying to user a rails method called polymorphic_path but I am getting the wrong url. My polymorphic association is with Students and Landlords who are both Users through userable.
Here are my models:
class User < ActiveRecord::Base
belongs_to :userable, polymorphic: true
end
class Student < ActiveRecord::Base
has_one :user, :as => :userable
end
class Landlord < ActiveRecord::Base
has_one :user, :as => :userable
end
I have a variable called current_user holding the User object. The following line:
<%= link_to "Profile", polymorphic_path(current_user) %>
gives me the url "users/22" instead of returning the Student/Landlord url.
Here is my routes.rb file if that helps..
resources :users
resources :students
resources :landlords
Where am I going wrong? Thanks!