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!