user852610
user852610

Reputation: 2265

Use member in rails

Hi everyone I am new with rails 3,I have a app where I want to associate a idea with a comment.

When I show an idea, in the bottom of the view I show a form to put new comment for this idea, and when a click to save a comment, I have to pass the idea_id, I create my model commment

  belongs_to :user
  belongs_to :idea
  attr_accessible :description, :likes, :name, :user_id, :idea_id 

in the view of show idea a put this

= render :partial => "comments/index", :collection => @idea.comments
= render :partial => "comments/form",  :locals => {:comment=> @comment}

in the _form of the comment I include idea to obtain idea_id to save

= form_for [@idea, @comment] do |f|

and in my router I put this

  resources :ideas do
    member do
      resources :comments
    end
  end

and now I obtain this error

undefined method `idea_comments_path'

any idea, anyone knows a document to explain better how to use member in rails!

Upvotes: 0

Views: 32

Answers (1)

NARKOZ
NARKOZ

Reputation: 27931

You don't need member for nested resources:

  resources :ideas do
    resources :comments
  end

http://guides.rubyonrails.org/routing.html

Upvotes: 2

Related Questions