加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails错误“NoMethodError” – 我的第一个rub

发布时间:2020-12-17 03:57:31 所属栏目:百科 来源:网络整理
导读:我绝对是全新的rails,所以答案可能非常简单.开始: 我的页面正在生成此错误 NoMethodError in Tasks#newShowing app/views/tasks/new.erb where line #3 raised:undefined method `tasks_path' for # 这是观点: % form_for(@task) do |f| % %= f.error_mess
我绝对是全新的rails,所以答案可能非常简单.开始:

我的页面正在生成此错误

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)

和模型:

我看不出有什么问题,但就像我说的那样,到目前为止我还是一无所知.
谢谢!

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

在你的路线?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读