【发布时间】:2016-05-19 21:13:08
【问题描述】:
我使用的是 Rails 4.2.3。我无法让我的表单呈现。当我访问“http://localhost:3000/users”页面时,在“”行上收到错误“# 的未定义方法 `myobjects_path'”。下面的代码来自我的“app/views/users/_add.html.erb”文件……
<%= form_for @myobject do |f| %>
<% if @myobject.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@myobject.errors.count, "error") %> prohibited this hack from being saved:</h2>
<ul>
这是我的“app/controllers/users_controller.rb”中访问此页面的方法……
class UsersController < ApplicationController
def index
@myobject = Myobject.new
end
end
我需要做什么才能让我的表单呈现?
【问题讨论】:
-
你的config/routes.rb 中有
resources :useres
标签: ruby-on-rails forms ruby-on-rails-4