Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Dario Hunt
2,245 PointsNo route matches [GET] User following error
Ok I'm stuck. I'm trying to implement user following through the gem acts_as_follower and I've followed the instructions up to the tee but I can't get the actual follow action to take place. I get this error everytime:
*No route matches [GET] "/1/follows"*
So I know it's a routing error but I have no idea and can't find the answer on how to get it from
/1(member_id)/follows
to
/"profile_name"/follows
because that's how I have my profile routes are set up.
get '/:id', to: 'profiles#show'
There are no routes to the member ids.
I have my follow and unfollow button set up like this:
<%= link_to("Follow", member_follows_path(member.to_param), :remote => true, :class => "btn") %>
<%= link_to("Following", member_follow_path(member.to_param, current_member.get_follow(member).id), :method => :delete, :remote => true, :class => "btn btn-follow") %>
and the route looks like this:
resources :members, :only => [:show], :path => '/' do
resources :follows, :only => [:create, :destroy]
end
You can see how the whole thing is set by going here: [https://gist.github.com/tcocca/863091]
I hope someone can help me with this.
1 Answer
Dario Hunt
2,245 PointsOk I've fixed my no_route error by adding a post method to my follow button, for some reason they didn't have it in the example I followed.
<%= link_to("Follow", member_follows_path(member.to_param), :method => :post, :class => "btn") %>