我用向导观看了 Wicked 表格,我正在尝试制作自己的表格,我有以下内容:
员工控制器.rb
class EmployeesController < ApplicationController
def index
@employees = Employee.all
end
def show
@employee = Employee.find(params[:id])
end
def new
@employee = Employee.new
end
def create
@employee = Employee.new(params[:employee])
if @employee.save
flash[:notice] = 'An employee has been created.'
redirect_to employee_admission_steps_path(:employee_id => @employee.id)
else
flash[:error] = 'An error occurred please try again!'
redirect_to '/dashboard'
end
end
def edit
end
def update
end
def destroy
end
end
Employee_admission_steps_controller.rb
class EmployeeAdmissionStepsController < ApplicationController
include Wicked::Wizard
steps :employee_admission1 , :employee_admission2
def show
@employee = Employee.find(params[:employee_id])
render_wizard
end
def update
@employee = Employee.find(params[:employee_id])
@employee.update_attributes(params[:employee])
render_wizard(@employee)
end
private
def finish_wizard_path
users_path
end
end
employee_admission1.html.erb 和 employee_admission2.html.erb
这两个文件的开头都有以下行:
<%= simple_form_for @employee, url: wizard_path(employee_id: @employee.id), method: :put do |f| %>
最后是以下行:
<%= f.submit 'Next', :class => "btn btn-success" %>
<% end %>
路线.rb
resources :employees
scope 'employees/:employee_id' do
resources :employee_admission_steps
end
现在我的主要问题是在填写 employee_admission1.html.erb 并按 next 之后,它会完成向导。如何让它去 employee_admission2.html.erb ?