ruby on rails - Resource not generating helper method for create -
i have model called package, has controller package created under name space admin.
so resource in routes declared below
namespace :admin resources :package end when run rake routes
admin_package_index /admin/package(.:format) admin/package#index post /admin/package(.:format) admin/package#create new_admin_package /admin/package/new(.:format) admin/package#new edit_admin_package /admin/package/:id/edit(.:format) admin/package#edit admin_package /admin/package/:id(.:format) admin/package#show put /admin/package/:id(.:format) admin/package#update delete /admin/package/:id(.:format) admin/package#destroy if see there no helper method generated create, should have been admin_packages_path
controller
@newpackage = package.new
view.html.erb
form_for [:admin,@newpackage] |f| end is reporting not able find admin_packages_path. can please explain how should declare in routes generate proper helper method create ?
your routes named incorrectly, you're pairing plural (resources) singular (:package).
if working multiple packages, should declare resources :packages - generate correctly named routes 7 restful actions (index, show, new, create, edit, update, destroy).
if working single package, need specify url option form manually, eg.
form_for [:admin, @newpackage], url: admin_package_path |f|
Comments
Post a Comment