0

I am trying to build a forum while nesting the routes and I keep running into this error:

undefined method `forum_threads_path' for

I have nested my routes as so in my routes.rb file

 resources :forum_subjects do
    resources :forum_threads, module: :forum_subjects do
      resources :forum_msgs, module: :forum_threads
    end
  end

I am trying to call this using form_for in a partial of the _form.html.erb

<%= form_for [@forum_subject, @forum_thread] do |f| %>

My view files are also located in folders within the one main one: forum_subjects/forum_threads/forum_posts where all the view files are also nested.

2
  • Your actual model name is Forum and Thread right? And also are they namespaced? Commented Aug 6, 2016 at 14:20
  • No they are not namespaced and it is forum_thread yeah Commented Aug 8, 2016 at 2:59

1 Answer 1

1

The error you are getting is correct. Since, your forums_threads is nested inside forum_subjects you will not be able to call the forum_threads_path. You will be able to find out the correct method to call if you run the rake routes in the terminal by changing directory to your project. Ideally there will be a method called forum_subject_forums_threads_path.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried using form_for the way i did. I try to access forum_subject_forums_threads_path with the [@forum_subjects, @forum_threads] part. I am not using any direct urls because I am using a partial form to be rendered in different files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.