このフォーム (views/workers/_form.html.erb) は、'create tasksadmin' ボタンを押すと、taskadmins のインデックスにリダイレクトします。
「ワーカー/インデックス」にリダイレクトし、ボタンを「タスクの更新」に変更したい。
どうすればそれができますか?
<%= form_for(@tasksadmin) do |f| %>
<% if @tasksadmin.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@tasksadmin.errors.count, "error") %> prohibited this tasksadmin from being saved:</h2>
<ul>
<% @tasksadmin.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.hidden_field :admin_mail, :value => @tasksadmin.admin_mail %>
<%= f.hidden_field :worker_mail, :value => @worker_mail %>
<%= f.hidden_field :task, :value => @tasksadmin.task %>
<div class="field">
<%= f.label :done %><br />
<%= f.check_box :done %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
これは私のworkers_controllerです:
class WorkersController < ApplicationController
# GET /workers
# GET /workers.json
def index
@tasks_worker = Tasksadmin.where(:worker_mail => "alon.shmiel@gmail.com")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @workers }
end
end
# GET /workers/1
# GET /workers/1.json
def show
@task_worker = Tasksadmin.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @worker }
end
end
# GET /workers/new
# GET /workers/new.json
def new
@worker = Worker.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @worker }
end
end
# GET /workers/1/edit
def edit
@tasksadmin = Tasksadmin.find(params[:id])
@worker_mail = "alon.shmiel@gmail.com"
end
# POST /workers
# POST /workers.json
def create
@worker = Worker.new(params[:worker])
respond_to do |format|
if @worker.save
format.html { redirect_to "@worker", notice: 'Worker was successfully created.' }
format.json { render json: @worker, status: :created, location: @worker }
else
format.html { render action: "new" }
format.json { render json: @worker.errors, status: :unprocessable_entity }
end
end
end
# PUT /workers/1
# PUT /workers/1.json
def update
@worker = Tasksadmin.find(params[:id])
respond_to do |format|
if @worker.update_attributes(params[:worker])
format.html { render action: "index", notice: 'Worker was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @worker.errors, status: :unprocessable_entity }
end
end
end
# DELETE /workers/1
# DELETE /workers/1.json
def destroy
@worker = Tasksadmin.find(params[:id])
@worker.destroy
respond_to do |format|
format.html { render action: "index" }
format.json { render json: @worker }
end
end
end