On 2 October 2013 20:29, Jose Urquidi
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> I have this in my .html.erb code:
>
> $.ajax({
> url: "/timeMachineEdit",
> data: {editTimeMachine: newArray},
> type: ''POST'',
> success: function (res) {
> if (res.result === ''ok'') {
> alert(''Data saved'');
> } else {
> alert(''Save error'');
> }
> },
> error: function () {
> alert(''Save error.'');
> }
> });
>
>
> This in my datasets_controller.rb
>
> def timeMachineEdit
> @dataset = current_user.dataset
> @dataset.machine_time = params[:editTimeMachine]
> end
>
>
> And in my routes.rb:
>
> match "/timeMachineEdit", to:
"datasets#timeMachineEdit"
>
>
> But when is submited shows:
>
> POST http://localhost:3000/timeMachineEdit 500 (Internal Server Error)
>
>
> Where is the problem here? is the routes in the ajax url or something
> else?
rake routes will show you the routes that are valid. If you try that
I expect you will see that timeMachineEdit is only routed for GET.
You need to specify specifically if you want it to be valid for POST.
See the Rails Guide on Routing for more information.
Colin
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvBTv3D9DDKF685aOKqN71%2B8%2BoH0D1XKj1yWozDRdXBVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.