Hi,
I am using RESTFUL routes with the following setup with a form_for tag,
but instead of calling the :create action my form is calling the :new
action. I have read and re-read the resources documentation, and I am
confident that I have the right combination of paths, and posting
methods, please take a look at this setup and let me know if I’m doing
something stupid or if this is an error w/rails routing.
,----[environment.rb]
| # Specifies gem version of Rails to use when vendor/rails is not present
| RAILS_GEM_VERSION = ‘2.1.0’ unless defined? RAILS_GEM_VERSION
`----
,----[processing_service_levels/new.html.erb]
| <% form_for(:processing_service_levels, @level,
| :url => processing_service_level_path(@level),
| :html => { :method => :post}) do |f| %>
`----
,----[routes.rb]
| map.resources :processing_service_levels
`----
,----[processing_service_levels_controller.rb]
| # POST /processing_service_levels
| # POST /processing_service_levels.xml
| def create
| @level = ProcessingServiceLevel.new(params[:id])
| @level.process_hours = (Integer(params[:months]) * 30 * 24) +
| (Integer(params[:days]) * 24) + Integer(params[:hours])
| respond_to do |format|
| if @level.save
| flash[:notice] = ‘Service level was successfully created.’
| …
`----
,----[rendered html]
|
| … form stuff …
|
`----
I’ve restarted with web-server since adding the map.resources line to my
routes. I’ve tried specifying the path using the old style
:url => {:controller => :processing_service_levels, :action => :create,
:id => @level}
but with no success. I’ve googled, and searched the archives of this
list, but I have had no success in finding out what’s going wrong.
Please help me out!
Thanks – Eric