1

I have routes structure:

  namespace :admin do
    resources :currencies
  end

rake routes output:

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 is a namespace.

The form generated by scaffold looks like

= 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

I've changed = form_for @currency to = form_for admin_currencies_path(@currency) but it still failing due to form`s action is /admin/currencies/new instead of /admin/currencies.

What I do wrong?

Thanks.

Mark Pegasov
  • 5,109
  • 9
  • 26
  • 30

1 Answers1

3

Try form_for [:admin, @currency].

John
  • 3,296
  • 2
  • 24
  • 36
  • 1
    It's usually considered proper to tick the green arrow for solutions people gave that answer your question. Glad it's working. :D – John Jun 27 '12 at 15:35