Rails has nested resources for a while, and it has been heavily used (or overused). Say we have two models, an article and a comment.
class Article < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :article end
Define a nested resource in routes.rb
resources :articles do resources :comments end
So, now we can list the comments for a specific article: http: // localhost: 3000 / articles / 1 / comments
But Spine can only make the url for the mail request to create an article and comment as follows:
/articles /comments
How to make a Spine URL for an Ajax request as follows?
/articles/1/comments
I know that I can override url () in the comment model for comments, but what about creating a new post?
I am also looking at the source code, I found that the create () method in the Spine Ajax module does not care about the user-defined url () function in the Comment instance. I want to just pass the article_id and use it with my custom url () function to generate the url, after which I can send to the server to create.
Is this possible without fork and a modified version of Spine for mine?
btw: sorry for my english, wish all of you guys to understand what I want to say :-)
Thanks and best regards,
Daniel Lv
source share