I持って次未定義のメソッド `relationships_pathは」レール3.1
ルート:
.
.
.
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
私はスタックオーバーフローについて悩んでおり、答えを見つけられないようですが、自分のリソースを入れ子にすることと関係があります。
undefined method 'relationships_path' for #<#<Class:0x007ff45f15ff80>:0x007ff45f15bc78>
任意のアイデア:私は次のエラーを取得しますか?
あなたは、経路変更して 'relationship' ressourcesを入れ子になってきました。あなたの前の質問に従って、 'rake routes'を実行して解決策を得てください。 – apneadiving
@apneadivingなので、私はnew_user_relationshipを使う必要があるのを見ましたが、この行の問題ではありません:私のコントローラの '@relationship = Relationship.new'ですか?私は何が欠けていますか? –