I'm still not very good (although I'm getting better) at RoR. I'm trying
to create a friendship between a user and another user. After using the
"friendships/new.rhtml", fill in the user's name and hit the
create-button. Now it is suppose to move on to the method "create" but
it can't find the method "create" in the friendships controller.
The fault lies either in the "form" of my "new.rhtml" or in my
routes-file, I'm guessing (since it can't find a method which exists)...
But I can't understand WHY.
First, you may be having some issues because you've got friendships
defined twice in your routes (one 'top-level' and the other nested
under users). Just a guess, but url_for might be getting confused.
Better to used the named route to eliminate confusion.
<% form_for(:friendship, :url =>user_friendships_path(@current_user) )
do |f| %>
...
<% end %>
Okay, thanks for the input and suggestion both of you. I tried using the
snippet below, but I still recieve the same error "Unknown action, No
action responded to create"
<% form_for(:friendship, :url =>user_friendships_path(@current_user) )
do |f| %>
The first "map.resources :friendships" dosen't seem to confuse Create
part of the routes (i recieve the same result with or without), it only
gives me more possible routes for other stuff related to friendships.
I have a hard time understanding routes, so bare with me. What I could
understand (and which may be wrong) of the information recieved from the
"raked routes" is: that the route is incomplete (maybe?)
With my New method which is displayed with the New view (and I believe
to understand this)
a quick update...I tried to create a "home" for the Create in the routes
in the
"user.resources :friendships, :member => { :accept => :get}"
by adding the ", :create => :post" to the above. But no further
success...don't even know if this was right to do.
oh, I forgot...this is what raked routes showed after that.
create_user_friendship POST
/users/:user_id/friendships/:id/create
{:action=>"create", :controller=>"friendships"}
POST /users/:user_id/friendships/:id;create
{:action=>"create", :controller=>"friendships"}
POST /users/:user_id/friendships/:id.:format;create
{:action=>"create", :controller=>"friendships"}
formatted_create_user_friendship POST
/users/:user_id/friendships/:id/create.:format {:action=>"create",
:controller=>"friendships"}