RailsCasts Pro episodes are now free!

Learn more or hide this

Victor Rodrigues's Profile

GitHub User: victorrodrigues

Site: http://victor.tc

Comments by Victor Rodrigues

Avatar

Why you no create a task to run the whenever --write-crontab?

Avatar

Instead using <%= hidden_field_tag "product[category_ids][]", nil %> i used in my controller update action something like this:

ruby
params[:product] ||= {}
params[:product][:category_ids] ||= []

This works fine too! :)

Avatar

Sorry! It's:

ruby
update: ->
        $.ajax({
                type: 'post'
                data: $(this).sortable('serialize')
                headers: {'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')}
                url: $(this).data("update-url")
        })
Avatar

Im using Ruby 1.8.7 and Rails 3.1 and i was getting this error WARNING: Can't verify CSRF token authenticity when released the drag.

So i google it and I had to do a modification of Coffee Script:

ruby
update: ->
                        $.ajax({
                                type: 'post'
                                data: $('#banners').sortable('serialize')
                                dataType: 'script'
                                headers: 'X-CSRF-Token': '<%= form_authenticity_token.to_s %>'
                                complete: (request) -> 
                                        $('#banners').effect('highlight')
                                url: $(this).data("update-url")
                                })

I hope to help someone else who has this problem!

Avatar

Adolfo,

I had this same problem, but, my mistake. (i'm leaning Rails, lol)
On the "if else statements" in Rails 3 need to be:

ruby
respond_to do |format|
      if @user.save
        if params[:user][:avatar].blank?
          format.html { redirect_to @user, :notice => 'User was successfully created.' }
          format.json { render :json => @user, :status => :created, :location => @user }
        else
          format.html { render :action => "crop" }
        end
      else
        format.html { render :action => "new" }
        format.json { render :json => @user.errors, :status => :unprocessable_entity }
      end
    end

And not only just render :action => "crop".
I do not know if that was your problem, but it was mine...