AnApprentice
AnApprentice

Reputation: 111070

Rails 3 - Help with a FORM_FOR tag

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

Upvotes: 1

Views: 656

Answers (2)

DGM
DGM

Reputation: 26979

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.

Upvotes: 1

Alessandra Pereyra
Alessandra Pereyra

Reputation: 2640

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

Upvotes: 0

Related Questions