[Rails] Friendship create action
I am trying to create a friendship system. There is a post at
http://stackoverflow.com/questions/5612736/how-to-implement-a-friendship-model-in-rails-3-for-a-social-networking-applicati
Which seem great but the create action doesn't work. How can it work
here what I have
Controller
#Send a friendship request
def create
Friendships.request(@customer, @friend)
end
Model
# Record a pending friend request.
def self.request(customer, friend)
unless customer == friend or Friendship.exists?(customer, friend)
transaction do
create(:customer => customer, :friend => friend, :status => 'pending')
create(:customer => friend, :friend => customer, :status =>
'requested')
end
end
end
Here how I call it in my view and i think this is where the issue is
<%= link_to "Request friendship with #{customer.first_name}",
{ :controller => "friendships", :action => "create",
:id => customer.id },
:confirm =>
"Send friend request to #{customer.incomplete_name}?" %>
<% end %>
Now the tutorial is old an i am wondering if the way i am calling it his
the proper way.
Thanks in advance
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home