1

これはビュー内の私のコードで、編集提案パスを呼び出しているだけです

<%= link_to "Edit this Proposal", edit_idea_proposal_path %>

これは提案コントローラーの私のコードです。明らかに「編集」アクションがあるのに、編集のルート エラーが表示されるのはなぜですか?

def create
    @idea = Idea.find(params[:idea_id])
    @proposal = @idea.proposals.create(params[:proposal])

    if @proposal.save
        flash[:success] = "Thanks for the Proposal!"
        redirect_to idea_proposals_url(@idea)
    else
        render 'new'
    end
end 

def edit
    @idea = Idea.find(params[:idea_id])
    @proposal = @idea.proposals.find(params[:id])
end

def update
    @idea = Idea.find(params[:idea_id])
    @proposal = @idea.proposals.find(params[:id])

    if @proposal.update_attributes(params[:proposal])
        redirect_to idea_proposals_url(@idea)
    else
        render 'edit'
    end
end
4

1 に答える 1

1

それを理解したので、ビューのコードを次のように変更する必要がありました。

<%= link_to "Edit this Proposal", edit_idea_proposal_path %>

に:

<%= link_to "Edit this Proposal", edit_idea_proposal_path(@idea, proposal) %>
于 2012-07-11T22:55:40.763 に答える