Nested Resouces,not getting parent id(project_id) from form


#1

Hi
i am using nested resources,here project having has many relation with
defects.
Main problem here is i am not getting project_id from edit form.What’s a
problem if any one knows please help.

edit.html.erb
<% form_for(@defect,@project) do |f| %>
<%=f.text_field :name%>
<%end%>

routes.rb
map.resources :projects,:has_many=>:defects
map.resources :defects

defecs_controller.rb
before_filter :get_project
private
def get_project
@project = Project.find(params[:project_id])
end

def edit
code for update defects
end

Here problem is from edit form i am getting project id.


#2

babu nair wrote:

Hi
i am using nested resources,here project having has many relation with
defects.
Main problem here is i am not getting project_id from edit form.What’s a
problem if any one knows please help.

edit.html.erb
<% form_for(@defect,@project) do |f| %>

try this
<% form_for(@project,@defect) do |f| %>

<%=f.text_field :name%>
<%end%>