I can''t understand where it fails. I can add a friend to my friendship
table, but I want to view my friends which I have after that. Rendering
the view of this (index) fails.
I understand that I somewhere refer to my friendship wrongly, but it
seems to find everything else. I can only find a referance in this log
in the last row, but that tells me (like the noob I am) nothing. Someone
got a suggestion (preferably a solution)?
############################################
statement invalidin FriendsController#index
############################################
ActiveRecord::StatementInvalid (Mysql::Error: #42S22Unknown column
''friendships.id'' in ''field list'': SELECT
users.`id` AS t0_r0,
users.`login` AS t0_r1, users.`email` AS t0_r2, users.`crypted_password`
AS t0_r3, users.`salt` AS t0_r4, users.`created_at` AS t0_r5,
users.`updated_at` AS t0_r6, users.`remember_token` AS t0_r7,
users.`remember_token_expires_at` AS t0_r8, users.`l_name` AS t0_r9,
users.`f_name` AS t0_r10, users.`last_activity` AS t0_r11,
users.`last_activity_at` AS t0_r12, friendships.`id` AS t1_r0,
friendships.`user_id` AS t1_r1, friendships.`friend_id` AS t1_r2,
friendships.`xfn_friend` AS t1_r3, friendships.`xfn_acquaintance` AS
t1_r4, friendships.`xfn_contact` AS t1_r5, friendships.`xfn_met` AS
t1_r6, friendships.`xfn_coworker` AS t1_r7, friendships.`xfn_colleague`
AS t1_r8, friendships.`xfn_classmate` AS t1_r9,
friendships.`xfn_neighbor` AS t1_r10, friendships.`xfn_roomie` AS
t1_r11, friendships.`xfn_child` AS t1_r12, friendships.`xfn_sibling` AS
t1_r13, friendships.`xfn_spouse` AS t1_r14, friendships.`xfn_parent` AS
t1_r15, friendships.`xfn_muse` AS t1_r16, friendships.`xfn_crush` AS
t1_r17, friendships.`xfn_date` AS t1_r18, friendships.`xfn_sweetheart`
AS t1_r19, friends_friendships.`id` AS t2_r0,
friends_friendships.`login` AS t2_r1, friends_friendships.`email` AS
t2_r2, friends_friendships.`crypted_password` AS t2_r3,
friends_friendships.`salt` AS t2_r4, friends_friendships.`created_at` AS
t2_r5, friends_friendships.`updated_at` AS t2_r6,
friends_friendships.`remember_token` AS t2_r7,
friends_friendships.`remember_token_expires_at` AS t2_r8,
friends_friendships.`l_name` AS t2_r9, friends_friendships.`f_name` AS
t2_r10, friends_friendships.`last_activity` AS t2_r11,
friends_friendships.`last_activity_at` AS t2_r12
FROM users LEFT OUTER JOIN friendships ON friendships.user_id users.id LEFT
OUTER JOIN users friends_friendships ON
friends_friendships.id = friendships.friend_id WHERE (users.`id` = 1) ):
########################################
my method states:
########################################
def index
#retrieves all friendships and friends for the specified user_id
@user = User.find(params[:user_id], :include => [:friendships =>
:friend])
end
#######################################
and the index view states:
#######################################
<table>
<% if logged_in? and current_user == @user %>
<%= render :partial => ''friendship_with_edit'',
:collection =>
@user.friendships %>
<% else %>
<%= render :partial => ''friendship'', :collection =>
@user.friendships
%>
<% end %>
</table>
######################################
and finally the partial...friendship_with_edit
######################################
<tr class= "<%= cycle(''odd'',
''even'') %>">
<td id="friendname">
<%= link_to friendship_with_edit.friend.login,
user_path(friendship_with_edit.friend),
:class => ''xfnRelationship'',
:rel => xfn_rel_tag(@user, friendship_with_edit),
:id => "friend-#{friendship_with_edit.friend.id}" %>
</td>
<td id="activity">
<% if friendship_with_edit.friend.last_activity_at %>
<%= friendship_with_edit.friend.last_activity %>
<%= time_ago_in_words(friendship_with_edit.friend.last_activity_at)
%> ago
<% end %>
</td>
<td id="editfriendship" >
[<%= link_to ''edit friendship'',
edit_friend_url(:user_id => @user,
:id => friendship_with_edit.friend) %>]
</td>
</tr>
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---