Mohit Sindhwani
2013-May-09 09:08 UTC
Rails ActiveResource URLs for searches including habtm relationships
Hi! I''m trying to build a small client that connects to Redmine to get the list of users attached to a project. Following the AR/ Rails conventions, I can get back all projects as: > http://redmine/projects.xml > http://redmine/users.xml and do searches such as: http://redmine/issues.xml?limit=10&project_id=3 This works when it involves an attribute or belongs_to criteria. Can someone help me understand the URL that should be used when trying to search on a HABTM criteria? For example, I want to know all the users on a project. But that relationship is achieved through a HABTM table. Is there some default Rails routing that covers this scenario? I tried searching online but I''m just not being able to formulate a query that returns useful results. Thanks & Best Regards, Mohit. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-May-09 12:31 UTC
Re: Rails ActiveResource URLs for searches including habtm relationships
On 9 May 2013 10:08, Mohit Sindhwani <mo_mail-RxrYI66vbj0AvxtiuMwx3w@public.gmane.org> wrote:> Hi! I''m trying to build a small client that connects to Redmine to get the > list of users attached to a project. > > Following the AR/ Rails conventions, I can get back all projects as: >> http://redmine/projects.xml >> http://redmine/users.xml > > and do searches such as: > http://redmine/issues.xml?limit=10&project_id=3 > > This works when it involves an attribute or belongs_to criteria. > > Can someone help me understand the URL that should be used when trying to > search on a HABTM criteria? > > For example, I want to know all the users on a project. But that > relationship is achieved through a HABTM table. Is there some default Rails > routing that covers this scenario?It is not clear to me what your question is. Can you give a specific example (including the relationships between models) of exactly what you are trying to do? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Mohit Sindhwani
2013-May-09 14:15 UTC
Re: Rails ActiveResource URLs for searches including habtm relationships
Hi Colin, Thanks for trying to help. Answer further down. On 9/5/2013 8:31 PM, Colin Law wrote:> On 9 May 2013 10:08, Mohit Sindhwani <mo_mail-RxrYI66vbj0AvxtiuMwx3w@public.gmane.org> wrote: >> Hi! I''m trying to build a small client that connects to Redmine to get the >> list of users attached to a project. >> >> Following the AR/ Rails conventions, I can get back all projects as: >>> http://redmine/projects.xml >>> http://redmine/users.xml >> >> It is not clear to me what your question is. Can you give a specific >> example (including the relationships between models) of exactly what >> you are trying to do? >> >> ColinI''m actually writing a C++ client that accesses information using HTTP from a Rails ActiveResource application (Redmine). I can use URLs like "http://redmine/projects.xml" and "http://redmine/users.xml" to get full lists of projects and users. The relationship between these 2 resources is a HABTM. I''m trying to figure out if there is a default URL (i.e., Rails convention) at which I could GET the relationships so that I can figure out which users belong to which projects... or figure out which users belong to a specific project. Since I''m doing this from C++ and not from a Ruby client, I am trying to figure out the URL, method and parameters that I need to provide to get this information. Hope it''s clearer now? Given how much trouble I''m having explaining this, maybe, I should stop searching and start reading the source for Redmine.. Best Regards, Mohit. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-May-09 20:43 UTC
Re: Rails ActiveResource URLs for searches including habtm relationships
On 9 May 2013 15:15, Mohit Sindhwani <mo_mail-RxrYI66vbj0AvxtiuMwx3w@public.gmane.org> wrote:> .. > I''m actually writing a C++ client that accesses information using HTTP from > a Rails ActiveResource application (Redmine). I can use URLs like > "http://redmine/projects.xml" and "http://redmine/users.xml" to get full > lists of projects and users. The relationship between these 2 resources is a > HABTM. I''m trying to figure out if there is a default URL (i.e., Rails > convention) at which I could GET the relationships so that I can figure out > which users belong to which projects... or figure out which users belong to > a specific project. Since I''m doing this from C++ and not from a Ruby > client, I am trying to figure out the URL, method and parameters that I need > to provide to get this information. > > Hope it''s clearer now? > > Given how much trouble I''m having explaining this, maybe, I should stop > searching and start reading the source for Redmine..I think you will have to look at the Redmine docs, unless someone here knows the answer. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Mohit Sindhwani
2013-May-10 03:22 UTC
Re: Rails ActiveResource URLs for searches including habtm relationships
Thanks Colin. On 10/5/2013 4:43 AM, Colin Law wrote:> > I think you will have to look at the Redmine docs, unless someone here > knows the answer. > > ColinI''m reading the source now to see if I can find what I need. Thanks for helping. Best Regards, Mohit. 10/5/2013 | 11:22 AM. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.