Help with rotues

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.

YOu dont have to update route. It just returns the json. YOu can see
it in the html.

must have to as doing http://localhost:3000/cities/for_provinceid/6
gives

Routing Error

No route matches “/cities/for_provinceid/6”

On 20 March 2011 06:06, Quee WM [email protected] wrote:

and in my zones controller I have
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

paste the result of rake commands

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

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, 6:06am, Quee WM [email protected] 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs