【发布时间】:2013-10-21 20:16:03
【问题描述】:
我正在制作一个 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
我收到以下对我来说毫无意义的错误:
# 的未定义方法 `information_index_path'
有谁知道如何解决这个问题?谢谢。
更新:
当我做 rake 路由时,对于 informations#create,这是表单应该去的,它有一个空白路径。还有informations#index,我猜这就是它现在的样子。如果路径为空白,我如何让它去 informations#create?
【问题讨论】:
-
ERB 的语法有问题。现在尝试摆脱 cmets。另外,您是否使用 IDE 来提醒您注意格式错误的 ERB?
-
我没有使用 IDE。我正在使用崇高。我摆脱了 cmets 并使用新错误编辑了问题。
标签: ruby-on-rails forms routes simple-form rails-routing