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.
Try form_for [:admin, @currency]
.