开发者

Rails and Sencha Nested JSON: Has Many through?

I want to process nested JSON data sent from rails in Sencha.

In rails, my model associations are:

class User < ActiveRecord::Base

has_many :codes
has_many :stores, :through => :codes, :uniq => true


class Store < ActiveRecord::Base

has_many :deals
has_many :orders
has_many :rewards
has_many :codes
has_many :users, :through => :codes, :uniq => true

class Code < ActiveRecord::Base
validates :unique_code, :uniqueness => true
belongs_to :stor开发者_StackOverflow社区e
belongs_to :order
belongs_to :user
belongs_to :earn

As you can see, the class Code stores all the relationship information between User and Store.

Now, I can send nested JSON to sencha using

@user.to_json(:include => :stores, :deals, :rewards) (not proper code)

However how can I process the nested structure in Sencha? My goal is basically to have a ListPanel that first list and displays Stores that Users are subscribed to, and when clicked, details of the relationship are loaded such as what deals and rewards that store is currently offering.

I don't see an option for a "has many through" relationship in Sencha.

Thanks for the help.


I'm afraid there isn't an equivalent in Sencha Touch right now, and, as you say, there is the network impact to think about. You may simply have to create your own custom proxy or data loading routine for now. Not a great answer, I'm afraid.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜