in my cities controller I have def for_provinceid @cities = City.where("active = true && province_id = ?", params[:id]).sort_by{ |k| k[''name''] } respond_to do |format| format.json { render :json => @cities } end end and in my zones controller I have def for_cityid @zones = Zone.where("active = true && city_id = ?", params[:id]).sort_by{ |k| k[''name''] } respond_to do |format| format.json { render :json => @zones } end end how do i update my routes file that i can access the jason returned by these two actions. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
YOu dont have to update route. It just returns the json. YOu can see it in the html. On Sun, Mar 20, 2011 at 12:06 AM, Quee WM <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> in my cities controller I have > > def for_provinceid > @cities = City.where("active = true && province_id = ?", > params[:id]).sort_by{ |k| k[''name''] } > respond_to do |format| > format.json { render :json => @cities } > end > end > > and in my zones controller I have > > def for_cityid > @zones = Zone.where("active = true && city_id = ?", > params[:id]).sort_by{ |k| k[''name''] } > respond_to do |format| > format.json { render :json => @zones } > end > end > > how do i update my routes file that i can access the jason returned by > these two actions. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
must have to as doing http://localhost:3000//cities/for_provinceid/6 gives Routing Error No route matches "/cities/for_provinceid/6" -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 March 2011 06:06, Quee WM <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> in my cities controller I have > > def for_provinceid > @cities = City.where("active = true && province_id = ?", > params[:id]).sort_by{ |k| k[''name''] } > respond_to do |format| > format.json { render :json => @cities } > end > end > > and in my zones controller I have > > def for_cityid > @zones = Zone.where("active = true && city_id = ?", > params[:id]).sort_by{ |k| k[''name''] } > respond_to do |format| > format.json { render :json => @zones } > end > end > > how do i update my routes file that i can access the jason returned by > these two actions.I think the question would be better put ''How do I update my routes file to allow me to invoke these actions'' (unless I misunderstand). The Rails Guide on routing should point you in the right direction. If you still can''t get it to work come back with what you have tried and what the result was. First, though I suggest reading up on RESTful routes to make sure that what you are doing is really what you want. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sunday, March 20, 2011 8:12:44 AM UTC+1, Ruby-Forum.com User wrote:> > must have to as doing http://localhost:3000//cities/for_provinceid/6 > gives > > Routing Error > > No route matches "/cities/for_provinceid/6" >You have not set your routes properly. Take a look at http://guides.rubyonrails.org/routing.html. If you need more information, you can take a look at the link in my signature (articles 2, 3 and 5). Markus -- http://www.communityguides.eu -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
paste the result of rake commands On Sun, Mar 20, 2011 at 3:31 AM, Markus Proske <markus.proske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sunday, March 20, 2011 8:12:44 AM UTC+1, Ruby-Forum.com User wrote: >> >> must have to as doing http://localhost:3000//cities/for_provinceid/6 >> gives >> >> Routing Error >> >> No route matches "/cities/for_provinceid/6" > > You have not set your routes properly. Take a look at > http://guides.rubyonrails.org/routing.html. If you need more information, > you can take a look at the link in my signature (articles 2, 3 and 5). > > Markus > > -- > http://www.communityguides.eu > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 20, 6:06 am, Quee WM <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> def for_cityid > @zones = Zone.where("active = true && city_id = ?", > params[:id]).sort_by{ |k| k[''name''] } > respond_to do |format| > format.json { render :json => @zones } > end > end > > how do i update my routes file that i can access the jason returned by > these two actions.Have you add them to your routes.rb file (like any other action) ? Katie -- http://www.coderstack.co.uk/ruby-developer-jobs -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I don''t think you are on the right path here. First of all, create a has_many and belongs to relationship. That will solve a lot if problems for you. On Mar 20, 7:06 am, Quee WM <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> in my cities controller I have > > def for_provinceid > @cities = City.where("active = true && province_id = ?", > params[:id]).sort_by{ |k| k[''name''] } > respond_to do |format| > format.json { render :json => @cities } > end > end > > and in my zones controller I have > > def for_cityid > @zones = Zone.where("active = true && city_id = ?", > params[:id]).sort_by{ |k| k[''name''] } > respond_to do |format| > format.json { render :json => @zones } > end > end > > how do i update my routes file that i can access the jason returned by > these two actions. > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.