Reputation: 652
My app is calling a resource trougth a path helper show_popular_hashtags_path
, but Rails seems to not recognize it. This is my partial:
.col-xs-12.no-padding.blue-title{style: "page-break-inside: avoid !important;"}
.col-xs-12.text-center.global-map.no-padding
%h1
= t('uniq.hashtag.title')
.js-column-chart-hashtags{data: {url: show_popular_hashtags_path(id: @project.id, provider: provider), provider: provider}}
.column-chart-hashtags.statistics-chart{class: "#{provider}", style: "width: 100%"}
%h2.empty-message.column-chart-hashtags{class: "#{provider}", style: "padding-top: 15px; padding-bottom: 30px; display: none;"}
= t('unique.there_is_no_info')
this is my routes.rb
:
namespace :user do
resources :projects, except: [:delete] do
member do
get :show_users, to: 'projects#js_show_users_data', as: :show_users_data
get :show_popular_hashtags, to: 'projects#js_show_popular_hashtags', as: :show_popular_hashtags
get :show_activity_data, to: 'projects#js_show_activity_data', as: :show_activity_data
For the another routes everything goes very well, even when I run rake routes | grep show_popular_hashtags
, the output is:
$ rake routes | grep show_popular_hashtags
show_popular_hashtags_user_project GET /user/projects/:id/show_popular_hashtags(.:format) user/projects#js_show_popular_hashtags
So, this looks like the route is well, but when I visit the view which contains the partial this error appears:
undefined method `show_popular_hashtags_path' for #<#<Class:0x007fa20d865d10>:0x007fa20dc5a6f0>
I already restarted the server, but it did not work.
Upvotes: 2
Views: 195
Reputation: 8042
The name of your routes helper is actually show_popular_hashtags_user_project
, not show_popular_hashtags
. You can see it in the first column of the rake routes
output:
$ rake routes | grep show_popular_hashtags
show_popular_hashtags_user_project GET /user/projects/:id/show_popular_hashtags(.:format) user/projects#js_show_popular_hashtags
Just change the name of the show_popular_hashtags
routes helper to show_popular_hashtags_user_project
in your view, and it will work.
Upvotes: 2