Rails 错误“NoMethodError"- 我的第一个 ruby 应用 [英] Rails error "NoMethodError" - My first ruby app
本文介绍了Rails 错误“NoMethodError"- 我的第一个 ruby 应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 Rails 完全陌生,所以答案可能很简单.这是:
I am absolutely and totally new to rails, so the answer is probably very simple. Here goes:
我的页面出现此错误
NoMethodError in Tasks#new
Showing app/views/tasks/new.erb where line #3 raised:
undefined method `tasks_path' for #
这是视图:
<% 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)
和模型:
我看不出有什么问题,但就像我说的,到目前为止我一无所知.谢谢!
I can't see a problem, but like I said, I'm clueless so far. Thanks!
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
在您的路线中?
这篇关于Rails 错误“NoMethodError"- 我的第一个 ruby 应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文