inline...
Jeff <[EMAIL PROTECTED]> writes:
> inline...
>
> On Oct 7, 3:10 pm, "Eric Schulte" <[EMAIL PROTECTED]> wrote:
>> 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
>> `----
>>
>
> What code do you have in your controller? It should be something like
> this:
>
> class ProcessingServiceLevelsController < ApplicationController
>
> def new
> @processing_service_level = ProcessingServiceLevel.new
> end
>
> end
>
the relevant methods in my processing_service_levels_controller.rb are
# GET /processing_service_levels/new
# GET /processing_service_levels/new.xml
def new
@processing_service_level = ProcessingServiceLevel.new
@version = ProcessingServiceVersion.find(params[:version])
@parent = @version.processing_service
respond_to do |format|
format.html # new.html.erb
format.xml { render :json => @level }
end
end
# 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.'
format.html { redirect_to(:controller => :processing_service_versions,
:action => :show,
:id => @version,
:parent => @parent,
:level => @level) }
format.xml { render :json => @service, :status => :created, :location
=> @level }
else
format.html { render(:action => "new",
:version => @level.processing_service_version,
:parent =>
@level.processing_service_version.processing_service) }
format.xml { render :json => @level.errors, :status =>
:unprocessable_entity }
end
end
end
not that the create method has ever successfully been called ;)
>
>> ,----[processing_service_levels/new.html.erb]
>> | <% form_for(:processing_service_levels, @level,
>> | :url => processing_service_level_path(@level),
>> | :html => { :method => :post}) do |f| %>
>> `----
>
> Given the above controller code, you can use this instead:
>
> <% form_for @processing_service_level do |f| %>
>
I switched to the form_for argument you suggested, which renders to the
following html
<form action="/processing_service_levels"
class="new_processing_service_level" id="new_processing_service_level"
method="post">
> >
> That should create a POST action to /processing_service_levels, which
> should call your create action.
Is there a way to inspect which method (put, post, get etc...) is being sent?
When I submit this form I am still directed to the
processing_service_controllers/new action. I'm really not clear on
what's going on, and why this one particular model has issues when all
of my other models are working fine. Also the
processing_service_levels/edit form is submitting to the edit actions
instead of update.
>
> Last resort, try restarting your web server (mongrel or webrick or
> whatever).
I've been restarting my web-server after almost every change.
Thanks for the advice, if you have any other ideas please let me know -- Eric
>
> Jeff
>
> purpleworkshops.coom
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---