1

我有路线结构:

  namespace :admin do
    resources :currencies
  end

耙路线输出:

admin_currencies     GET /admin/currencies(.:format) admin/currencies#index
                     POST /admin/currencies(.:format) admin/currencies#create
new_admin_currency   GET /admin/currencies/new(.:format) admin/currencies#new
edit_admin_currency  GET /admin/currencies/:id/edit(.:format) admin/currencies#edit
      admin_currency GET /admin/currencies/:id(.:format) admin/currencies#show
                     PUT /admin/currencies/:id(.:format) admin/currencies#update
                     DELETE /admin/currencies/:id(.:format) admin/currencies#destroy

Admin 是一个命名空间。

脚手架生成的表单看起来像

= form_for @currency do |f|
  - if @currency.errors.any?
    #error_explanation
      %h2
        = pluralize(@currency.errors.count, "error")
        prohibited this currency from being saved:
      %ul
        - @currency.errors.full_messages.each do |msg|
          %li= msg
  .field
    = f.label :title
    %br/
    = f.text_field :title
  .field
    = f.label :iso_code
    %br/
    = f.text_field :iso_code
  .actions
    = f.submit

我已更改= form_for @currency为,= form_for admin_currencies_path(@currency)但由于表单的操作是 /admin/currencies/new 而不是 /admin/currencies,它仍然失败。

我做错了什么?

谢谢。

4

1 回答 1

3

试试form_for [:admin, @currency]

于 2012-06-27T15:31:37.790 回答