0

Bootstrap モーダルを使用して、タスク モデルの taskpriority フィールドを更新しようとしています。

これは、機能していないモーダルの行です。

<%= simple_form_for :task, :url => url_for(:action => 'update', :controller => 'tasks'), :method => 'put' do |f| %>

タスク コントローラーには次のコードがあります。

# PUT /tasks/1
# PUT /tasks/1.json
def update
  @task = Task.find(params[:id])

  respond_to do |format|
    if @task.update_attributes(params[:task])
      format.html { redirect_to @task, notice: 'Task was successfully updated.' }
      format.json { render json: @task }
    else
       format.html { render action: "edit" }
      format.json { render json: @task.errors, status: :unprocessable_entity }
    end
  end
end

私が得るエラーは次のとおりです。

No route matches {:action=>"update", :controller=>"tasks"}

ありがとう !

PS - 1 つのフィールドを変更するポップアップを作成する簡単な方法はありますか?

更新 1

タスクのレーキ ルート

                 tasks GET    /tasks(.:format)                   tasks#index
                     POST   /tasks(.:format)                   tasks#create
            new_task GET    /tasks/new(.:format)               tasks#new
           edit_task GET    /tasks/:id/edit(.:format)          tasks#edit
                task GET    /tasks/:id(.:format)               tasks#show
                     PUT    /tasks/:id(.:format)               tasks#update
                     DELETE /tasks/:id(.:format)               tasks#destroy
4

3 に答える 3

0

これは実際には正しい答えではありません。ただし、何かがうまくいかない場合は、別のアプローチを試したほうがよい場合もあります。

代わりに x-editable を使用しました。

于 2013-08-13T20:13:41.563 に答える
0

:taskまたは@task変数が設定されていないと思われます。@sircapsalot の提案を試して、tasks_controller#editアクションを示してください。のようなことをしていることを確認してください@task = Task.find(params[:id])

于 2013-08-13T20:23:18.363 に答える
0

これを試して -

<%= simple_form_for @task, :url => tasks_path, :method => :post do |f| %>
于 2013-08-12T20:48:57.663 に答える