开发者

Rails mass assignment and Backbone.js

开发者 https://www.devze.com 2023-02-06 19:26 出处:网络
I have a Game model and I want to mass assign on create: def create game = Game.new(params[:game]) ... end

I have a Game model and I want to mass assign on create:

def create
game = Game.new(params[:game])
...
end

But Backbone sends model attributes without wrapping them in 'game' param, and I have to do this:

def creat开发者_JAVA技巧e
game = Game.new(:title=>params[:title], ... )
...
end

I want my controller clean, how to use mass assignment with Backbone.js?


Answer From Backbone creator: http://www.quora.com/How-well-does-backbone-js-work-with-rails


This might help you from what I understand: https://gist.github.com/719080 (Not my code, gist by @trydionel).

0

精彩评论

暂无评论...
验证码 换一张
取 消