[Solved] form_for [@parent, @child] causes undefined method `parent_child_path’ in Child#new


The thing about form_for is that its URL is based on the model that you passed in. In your case, it’s:

<%= form_for [@user, @college] do |f| %>

Rails automatically looks for user_college_profiles_path because you assigned User to @user, and current_user.college_profile to @college.

Fortunately, Rails provides a way to override the default URL the form will go to on submit:

<%= form_for([@user, @college], :url => your_custom_route_path) do |f| %>

All you need to do is create your_custom_route in your routes.rb

Source: Ruby on Rails Guides: Rails Form Helpers

3

solved form_for [@parent, @child] causes undefined method `parent_child_path’ in Child#new