我对 Rails 完全陌生,所以答案可能非常简单。开始了:
我的页面产生了这个错误
NoMethodError in Tasks#new Showing app/views/tasks/new.erb where line #3 raised: undefined method `tasks_path' for #
Here is the view:
<% 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 %>
Controller :
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
最佳答案
你有吗
map.resources :tasks
在你的 route ?
关于ruby-on-rails - Rails 错误 "NoMethodError"- 我的第一个 ruby 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/845315/