【发布时间】:2012-10-01 17:45:50
【问题描述】:
我对 Rails 完全陌生,所以答案可能很简单。如下:
我的页面出现此错误
任务中的 NoMethodError#new 显示第 3 行引发的 app/views/tasks/new.erb: 未定义的方法 `tasks_path' 用于#
这里是视图:
<% form_for(@task) do |f| %>
<%= f.error_messages %>
<%= f.label :description %>:
<%= f.text_field :description %><br />
<%= f.label :priority %>:
<%= collection_select(:news, :priority_id, Priority.find(:all), :id, :description) %><br />
<%= f.submit "Add Task" %>
<% end %>
控制器:
class TasksController < ApplicationController
def index
@all_tasks = Task.find(:all, :order => :id)
end
def new
@task = Task.new
end ...(more)
和模型:
我看不出有什么问题,但就像我说的,到目前为止我一无所知。 谢谢!
class Task < ActiveRecord::Base
validates_presence_of :description
belongs_to :priority
has_and_belongs_to_many :staff
has_and_belongs_to_many :catagory
end
【问题讨论】:
标签: ruby-on-rails ruby