I have the following:
Routes:
.
.
.
resources :users do
resources :relationships
end
new.html.erb:
<section id="main">
<%= form_for @relationship do |f| %> #This is the line the error is on
<div class="field">
<%= f.label :name %>
<%= f.text_field :name %>
</div>
<div class="actions"><%= f.submit %></div>
<% end %>
</section>
relationships_controller.rb
class RelationshipsController < ApplicationController
def new
@id = params[:user_id]
@rel_user = User.find_by_id(params[:user_id])
@relationship = Relationship.new
end
def create
end
end
relationship.rb #model
class Relationship < ActiveRecord::Base
belongs_to :user
# TYPES = ['Family', 'Friend', 'Spouse']
end
I've hunted around on Stack Overflow and can't seem to find the answer, although, I think it has something to do with nesting my resources. I get the following error:
undefined method 'relationships_path' for #<#<Class:0x007ff45f15ff80>:0x007ff45f15bc78>
Any ideas?
relationshipressources so the path change. As per your previous question, runrake routesto get the solution.@relationship = Relationship.newin my controller? What am I missing?