So a user has many colleges (that they have attended), and a college belongs to a user. I call these colleges, college_profile as they are the college attribute of a user's profile.
I am running into the problem when trying to generate a new college. My controller for the college at the moment is very simple:
def new
@user = User.find(params[:id])
@college = current_user.college_profile.build if signed_in?
end
And the view equally as simple: (views/college_profiles/new.html.erb)
<%= form_for [@user, @college] do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :name %>
<% end %>
And yet, for some reason I get the following error:
NoMethodError in College_profiles#new
Showing .../app/views/college_profiles/new.html.erb where line #4 raised:
undefined method `user_college_profiles_path' for #<#<Class:0x5bf1b68>:0x673aef8>
As I am still learning Rails, I really don't even understand what this error is exactly referring to. A fair amount of Google-ing has given me no luck, or if the answer is out there I simply don't know enough to realize I was looking at it. Any help would be greatly appreciated!
If it is relevant, seeing as we're talking about paths, here's an excerpt from my routes file:
resources :users, :only => [:index, :new, :create, :destroy, :update, :edit] do
resources :college_profiles, :only => [:new, :create]
end
If any more info is needed, just let me know. Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…