views:

20

answers:

2

Hello,

I have the following form_for tag:

<%=form_for [:project, @permission], :remote => true do |f| %>


<form method="post" id="edit_permission_52" data-remote="true" class="edit_permission" action="/projects/52/permissions/useronspace" accept-charset="UTF-8">

The ID looks right = edit_permissions_52

But the action path is all messed up...

It should be /projects/#PROJECTID#/permissions/useronproject

but instead Rails is making it

/projects/#PERMISSIONID#/

which is breaking everything.

Does this make sense to you? thanks

A: 

Is @permission nested on projects? If so, maybe try something like

= form_for [@permission.project, @permission]

It looks like it's trying to use the @permission id as the project_id. If not, you'd just need to sent it the @permission object (seems likely this is what you want).

= form_for @permission, :remote => true
Yaraher
+1  A: 

If you want a specific project id, you need to use @project in the array, not :projects. :projects is for a collection, not a specific one.

DGM