Custom Rest actions

I am trying to create a friendship and I created a custom action called accept. however i can't reach it. Everytime I call it i get the action show could not be found.

Here my route.rb file

  resources :friendships do
    collection do
      delete 'cancel'
      get 'accept'

Here how i call it

<%= link_to 'Accept', accept_friendships_path(:friend_id => f) %>

accept_friendships was taken from rake routes commands. And here how i define my accept controller

  #Accept friendships
  def accept
    if @customer.requested_friends.include?(@friend)
      Friendship.accept(@customer, @friend)
      flash[:notice] = "Friendship Accepted"
      flash[:notice] = "No Friendship request"
    redirect_to root_url

Here the error

Unknown action

The action 'show' could not be found for FriendshipsController


Maybe I am wrong, but why you want "accept" to be a collection? I guess you want it to be a member, since you are passing friend_id. If you change it to member and make the path accept_friendship_path(@friendship) [ note singular form of friendship ], you might have better luck. Beside an addition argument your case does not differ from example on Ruby on Rails Guides, that is why it is worth to try it

Need Your Help

User security stamp for Active Directory

c# active-directory ldap

I have a Multitenant MVC5 application which lets tenants specify their authentication &amp; authorisation method. They can choose between local account which uses ASPIdentity behind the scenes or u...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.