0
我想建立一個友誼系統sorta以下鏈接:如何在社交網絡應用程序的Rails 3中實現友誼模型?但缺乏一點。我能夠建立關係,但我不確定如何執行以下操作:取消,拒絕,接受。Rails友誼取消,拒絕
所以,可以說,我嘗試取消的關係,我不上掛起以下,叫我做後續動作:
<% @customer.pending_friends.each do |pf| %>
<%= link_to pf.incomplete_name, cancel_friendships_path(:friend_id => pf), :method => :post %><br />
<% end %>
這裏的控制器取消
def cancel
@customer = current_customer
@friend = Customer.find(params[:friend_id])
if @customer.pending_friends.include?(@friend)
Friendship.breakup(@customer, @friend)
flash[:notice] = "Friendship Canceled"
else
flash[:notice] = "No Friendship request"
end
redirect_to root_url
end
和這裏我的分手功能
# Delete a friendship or cancel a pending request.
def self.breakup(customer, friend)
transaction do
destroy(find_by_customer_id_and_friend_id(customer, friend))
destroy(find_by_customer_id_and_friend_id(friend, customer))
end
end
但是,當我點擊c ancel鏈接。我做錯了什麼?
這裏就要求
route.rb
resources :friendships do
collection do
get 'cancel'
get 'decline'
end
end
resources :friendships
耙路線
cancel_friendships GET /friendships/cancel(.:format) friendships#cancel
decline_friendships GET /friendships/decline(.:format) friendships#decline
GET /friendships(.:format) friendships#index
POST /friendships(.:format) friendships#create
GET /friendships/new(.:format) friendships#new
GET /friendships/:id/edit(.:format) friendships#edit
GET /friendships/:id(.:format) friendships#show
PUT /friendships/:id(.:format) friendships#update
DELETE /friendships/:id(.:format) friendships#destroy
/********************************************************/
friendships GET /friendships(.:format) friendships#index
POST /friendships(.:format) friendships#create
new_friendship GET /friendships/new(.:format) friendships#new
edit_friendship GET /friendships/:id/edit(.:format) friendships#edit
friendship GET /friendships/:id(.:format) friendships#show
PUT /friendships/:id(.:format) friendships#update
DELETE /friendships/:id(.:format) friendships#destroy
你可以發佈你的'routes.rb'和'rake routes'的輸出嗎? – Mischa
只需添加它! – Jseb