On 17 August 2012 17:01, Jean-Sébastien D. <[email protected]> wrote:
> Colin Law wrote in post #1072687:
>>
>> I doubt whether anyone has time to wade through all that code in order
>> to understand your problem (though I may be proved wrong).  You must
>> try to ask a more specific question.
>>
>> Colin
>
> I understand and didn't want at first because its a lot of code, but
> just wanted to make sure it was understood properly ( language barrier
> sometime). Anyway
>
> I am trying to create a relationship among the users, in my controller I
> have 2 function create and accept.
>
> When clicking in my view file I have link_to which create the
> friendship.
> <%= link_to "Request friendship with #{customer.first_name}",
>     { :controller => "friendships", :action => "create",
>   :id => customer.id },
>   :confirm =>
>   "Send friend request to #{customer.incomplete_name}?" %>

Are you using a GET request to create records in the database?  This
is generally considered a bad idea.

>
> However I do not see when refreshing that a friendship has really been
> created. In what ever states

So has it been created or not?  Look directly at the database if
necessary, to check.  If not then get that working first before
worrying about any views.  Run
rails console
then you can do things like
Friendship.all
and it will show them all.  In addition you can run any ruby code to
interrogate the db in the same way as you do in the app (using find
and so on).

>
> I believe the issue is here
>
>
>   has_many :requested_friends,
>      :through => :friendships,
>      :source => :friend,
>      :conditions => "status = 'requested'"
>
> I am just suppose to say @customer.requested_friends and this would
> allow me iterate through each of them??

Yes, but check first as I said above that you are creating the
friendships correctly first.  I am sure I have pointed you to the
Rails Guide on debugging already, but if not then have a look at it.

Colin

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to