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.
qaswm
March 20, 2011, 7:38am
2
YOu dont have to update route. It just returns the json. YOu can see
it in the html.
qaswm
March 20, 2011, 8:12am
3
must have to as doing http://localhost:3000/cities/for_provinceid/6
gives
Routing Error
No route matches “/cities/for_provinceid/6”
qaswm
March 20, 2011, 10:05am
4
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
qaswm
March 20, 2011, 3:03pm
5
paste the result of rake commands
qaswm
March 20, 2011, 10:33am
6
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
Rails Routing from the Outside In — Ruby on Rails Guides . 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
qaswm
March 22, 2011, 9:50am
7
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.
qaswm
March 22, 2011, 3:11am
8
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