开发者

Rails mass assignment and Backbone.js

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜