Backbone.js and Rails - How to handle params from Backbone models?

前端 未结 6 1972
灰色年华
灰色年华 2021-02-01 18:38

In a standard Rails controller, I\'d create a record like this:

@user = User.new(params[:user])

This assumes that the form parameters that come

6条回答
  •  逝去的感伤
    2021-02-01 18:51

    As of Rails 3.1 there's now a new initializer called wrap_parameters.rb which handles this problem by default. The code that handle this case is:

    # Disable root element in JSON by default.
    ActiveSupport.on_load(:active_record) do
      self.include_root_in_json = false
    end
    

    Bada bing!

提交回复
热议问题