0
我有名稱AdminController控制器,其中i有方法create_school_head:導軌3 - 在其他控制器的其他方法處理數據
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 %>
Routes.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中。我怎樣才能做到這一點?
我在控制器中創建了這個方法,試圖實現你的建議,現在我得到了:'NameError in Admins#create_school_head。未定義的局部變量或方法process_school_head_url爲#<#:0x007fce68a12230>' –
ExiRe
2012-03-09 17:54:37
我給了一個示例URL。您需要向我們展示您的routes.rb文件的外觀。你有沒有爲這一行動設置任何特殊路線? – 2012-03-09 17:59:39
我加了我的'routes.rb',請檢查我的文章! – ExiRe 2012-03-09 18:02:07