私は本当に完全にレールに慣れているので、答えはおそらく非常に簡単です。ここに行く:Railsエラー "NoMethodError" - 私の最初のRubyアプリケーション
マイページはこちら
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)
とモデル:
私は問題を見ることができない、bu私が言ったように、私は今のところ無知だ。 ありがとう!
class Task < ActiveRecord::Base
validates_presence_of :description
belongs_to :priority
has_and_belongs_to_many :staff
has_and_belongs_to_many :catagory
end
ああ、あなたは右にしています。それを追加した後、私は@taskでform_forを使用することができました – doctororange
@task = Task.newがアクションにある場合、form_for(@task)は空のタスクオブジェクトを参照します。:タスクはフォームをRESTfulタスクの代わりにtasks/newに、method = 'post'を使って提出します。 – Jarrod