Belongs_to hackery

I have the following four files
MODEL

class FriendshipRequest < ActiveRecord::Base
belongs_to :user
belongs_to :requested_by, :class_name => :user, :foreign_key =>
:requested_by_user_id
end

MIGRATION

create_table :friendship_requests do |t|
t.references :user, :null => false
t.integer :requested_by_user_id, :null => false
t.timestamps
end

CONTROLLER

def index
@user = User.find(session[:user])
@friendship_requests = FriendshipRequest.find(:all, session[:user])
end

VIEW

<% @friendship_requests.each do |friendship_request| -%>
<%= friendship_request.requested_by.inspect %>
<% end -%>

And I am getting the following error:

can’t convert Symbol into String

Should I not be able to access the user through dot notation
using riendship_request.requested_by?

What am I doing wrong?

Thanks!


John K.
[email protected]

Blog: http://www.kopanas.com
Conference: http://www.cusec.net
Twits: http://www.twitter.com/kopanas

2007/12/26, John K. :

I have the following four files

MODEL

class FriendshipRequest < ActiveRecord::Base
belongs_to :user
belongs_to :requested_by, :class_name => :user, :foreign_key =>
:requested_by_user_id
end

:class_name => ‘User’

– Jean-François.

On 26 Dec 2007, at 19:13, John K. wrote:

I have the following four files

MODEL

class FriendshipRequest < ActiveRecord::Base
belongs_to :user
belongs_to :requested_by, :class_name => :user, :foreign_key
=> :requested_by_user_id
end

:class_name expects a String

Fred