为什么我会得到一个未初始化的常量“控制器”?

时间:2013-08-06 02:17:16

标签: ruby-on-rails ruby

我收到了这个错误:

ActionController::RoutingError at /bankacct/new

uninitialized constant BankacctController

我觉得这个错误是因为我说错了。有什么想法吗?

bankaccts_controller.rb:

class BankacctsController < ApplicationController

  def new 
  end

  def create
    # some code
  end

end

应用程序/视图/ bankaccts / new.html.haml:

%form
  = label_tag :bank_name, "Account Holder's Name"
  = text_field_tag :bank_name, nil, name: nil, :value => "John Q. TaxPayer", class: "ba-name"
  %br
  = label_tag :acct_num, "Account Number"
  = text_field_tag :acct_num, nil, name: nil, :value => "9900000001", class: "ba-an"
  %p
  %button{:type => "submit"}
    tokenize

routes.rb中:

resources :bankacct

rake routes:

bankacct_index GET   /bankacct(.:format)          bankacct#index
               POST  /bankacct(.:format)          bankacct#create
  new_bankacct GET   /bankacct/new(.:format)      bankacct#new
 edit_bankacct GET   /bankacct/:id/edit(.:format) bankacct#edit
      bankacct GET   /bankacct/:id(.:format)      bankacct#show

2 个答案:

答案 0 :(得分:2)

应该是resources :bankaccts

答案 1 :(得分:2)

routes.rb应该有:

resources :bankaccts