我有名称为AdminController的控制器,其中我有方法create_school_head:
class AdminsController < ApplicationController
...
def create_school_head
@user = User.new
end
...
end
我也有视图create_school_head:
<%= form_for @user, :html => {:class => "form-horizontal"} do |f| %>
<fieldset>
<div class="control-group">
<%= f.label :user_login, "Login", :class => "control-label" %>
<div class="controls">
<%= f.text_field :user_login %>
</div>
</div>
<div class="control-group">
<%= f.label :password, "Password", :class => "control-label" %>
<div class="controls">
<%= f.text_field :password %>
</div>
</div>
</fieldset>
<%= f.submit "Create", :class => "btn btn-success" %>
<% end %>
路由.rb
ElSchool::Application.routes.draw do
resources :users, :only => [ :new, :create, :show ]
resources :sessions, :only => [ :new, :create, :destroy ]
get "sessions/new"
match 'pages/wrong_page', :to => 'pages#wrong_page'
match '/signin', :to => 'sessions#new'
match '/signout', :to => 'sessions#destroy'
match '/admins/backups', :controller => 'admins',
:action => 'backups'
match '/admins/users_of_system', :controller => 'admins',
:action => 'users_of_system'
match '/admins/create_school_head', :controller => 'admins',
:action => 'create_school_head'
match '/admins/create_teacher', :controller => 'admins',
:action => 'create_teacher'
root :to => 'sessions#new' #Home
end
现在它传递数据来创建用户控制器的方法。我想在AdminController的其他方法中提交按钮后从这个表单发送数据,例如在方法process_school_head中。我怎样才能做到这一点?