Thanks Conrad, I have removed the save call from the code, but it
continues to return an empty JSON on success case.
Any more clues?
On Mar 21, 3:37 pm, Conrad Taylor <conra...@gmail.com> wrote:
> On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch <fabi...@gmail.com> wrote:
> > Hi all!
>
> > I'm playing with Rails 3, and on one of my controllers I have the
> > following update method defined:
>
> > def update
> > @category = @user.categories.find(params[:id])
> > @category.update_attributes(params[:ecategory])
> > @category.save
> > respond_with @category
> > end
>
> Fabio, you should not be calling save within the update
> action because 'update_attributes' calls save implicitly.
> Thus, you should do something like the following:
>
> class CategoriesController < ApplicationController::Base
>
> respond_to :html, :json
>
> def update
>
> @category = @user.categories.find( params[:id] )
>
> if @category.update_attributes( params[:category] )
>
> flash[:notice] = 'Category was successfully created.'
>
> end
>
> respond_with( @category )
>
> end
>
> end
>
> Good luck,
>
> -Conrad
>
> I'm using Jquery to interact with the controllers, and when I do an
>
>
>
> > ajax PUT, the update action is correctly executed (the fields are
> > updated), but the action returns an empty JSON object, which causes
> > the Jquery ajax function to fall into an error.
>
> > I'm I doing something wrong?
>
> > Thank you all,
> > Fabio.
>
> > --
> > 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 rubyonrails-talk@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscrib e@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment