0

Railsアプリケーションを作っています。ユーザーが登録した後 (devise で既にユーザー登録を作成しています)、プロファイル情報を含むこのフォームに入力できます。私はこれを数回行いましたが、何が間違っているのかわかりません。モデルは次のとおりです。

class Information < ActiveRecord::Base
    belongs_to :user
end

コントローラーは次のとおりです。

class InformationsController < ApplicationController

    def new
        @information = Information.new
    end
    def create
        @information = Information.create(params[:information])
        redirect_to student_path
    end
    def index
    end
end

そして、これが新しいアクションのビューです。

<div class="span6 offset3 text-center">
<h1>Edit your information</h1>

    <%= simple_form_for @information do |f| %>
        <%= f.input :skills %>
        <%= f.input :looking_for, :label => 'What help do you need?' %>
        <%= f.input :my_idea %>
        <%= submit_tag "Save", :class => "btn btn-primary btn-large" %>
    <% end %>
</div>

ルートファイルの行は次のとおりです。

resources :informations

私には意味のない次のエラーが表示されます。

#<#:0x007f9c00c7b3e0> の未定義のメソッド `information_index_path'

これを修正する方法を知っている人はいますか?ありがとう。

アップデート:

ルートをレーキしたとき、フォームが行くべきである情報#作成のために、空白のパスがあります。informations#index もありますが、これは私が推測しているものです。パスが空白の場合に informations#create に移動するにはどうすればよいですか?

4

3 に答える 3

0

試してみinformations_pathませんか?ここを参照してください。

于 2013-10-21T20:41:52.740 に答える
0

ビューの 6 行目と 9 行目のコメント (# 記号) をヤンクアウトしてみてください。彼らは ERB 処理を台無しにしている可能性があります。

于 2013-10-21T20:20:40.513 に答える