RailsCasts Pro episodes are now free!

Learn more or hide this

Firfi's Profile

GitHub User: Firfi

Comments by

Avatar

1) Not be amiss to add csrf token in your backbone forms and turn it on in application controller:

ruby
def handle_unverified_request
  #TODO add here code to empty the session
  raise ActionController::InvalidAuthenticityToken
end
ruby
<input name="authenticity_token" type="hidden" value="<%= $('meta[name="csrf-token"]').attr('content') %>">

That works fine but I doubt that it is really necessary because browsers have ajax crossdomain restrictions anyway.

I am right or not?

2) I just found it handful when you have multiple fields in your forms use backbone-syphon-rails gem. It doing form serialisation for you and you can write something like that:

coffeescript
createNote: (event) ->
    event.preventDefault()
    data = Backbone.Syphon.serialize(this)
    @collection.create data