ActionController::RoutingError problem

Hi Everyone,

I've been teaching myself Ruby on Rails while trying to build a new
website I want to launch in the next few weeks. I've gotten pretty
far, but I've hit a wall this week and I can't seem to get around it.
I've been trying to implement a friends feature, allowing people to
add, edit and delete friends as they see fit. I've been following the
example set in the book "Practical Rails, Social Networking Sites" by
Alan Bradburne, and it's been a big help, but since the particulars of
my application are different, I've had to do some adjusting of the
code to make it fit.

Right now, I have no problem logging in as one user, and viewing other
users' profiles. From there, I can tag a user as a "friend". I can go
to my friends list, and choose to edit their information, which is
basically their XFN info. However, when I click on "Edit Friendship",
I get the above error, ActionController::RoutingError. I just can't
seem to get around it. This is the full error I'm receiving:

Here's my theory:

@friend = @friendship.friend if @friendship

prevents @friend from ever getting set because the @friendship
variable is nil. Then, when you try to create you form with:

6: <% form_for(:friendship,
7: :url => user_friend_path(:user_id =>
8: :friend_id
=> @friend),
9: :html => { :multipart => true, :method
=> :put}) do |f| %>

it pukes because :friend_id is being set to a nil value. Test it out
by hard-coding a valid friend id in (so you would have :friend_id => 1
instead of :friend_id => @friend). If it works with a valid friend id
there, then my theory was right.

Thanks for the fast idea, I tried changing the edit.rhtml file to
include :friend_id => 2, which is a valid id, but I still get the same
error as before.

I also tried changing the user_friend_path to user_friends_path, but I
still get the same error as above too.

Something that just popped into my mind, the error message above has
all the attributes of the user, not the friend properties. I would
think that since the form is trying to load the friend attributes, but
it has the user attributes that would fail as well. but I could be
wrong :slight_smile: