0

I'm trying to add a small part(callback for jsonp) to my /groups/1/clients.json file. But I don't know which method in groups(or clients) formats that json file for me.

I've tried editting my clients#show and clients#index and also my groups#show and groups#index methods; to no avail.

Thanks in advance

2
  • can you paste some of your code . your question is not clear Commented Dec 23, 2013 at 9:11
  • Because it's not a code related question. I want to add something to my json render for the nested resource. But I don't know where. Commented Dec 23, 2013 at 9:14

1 Answer 1

2

according to your url "/groups/1/clients", it call clients controller index method only because there are nested resources so groups is the parents of clients, so that means group 1's all clients show so it call index methods of clients. so put your json code inside clients controller's index methods

Sign up to request clarification or add additional context in comments.

7 Comments

What would be the variable used in my index(it's empty now because I didn't need it yet). Just @clients?
yup you must use @clients variable in index method according rails convention.
find their all clients of perticuler groups eg. @clients = Group.find(params[:id]).clients
Using only render :text => 123 in my index shows 123 on /clients.json/ but on /groups/1/clients.json I still see the clients json(without callback). So I'm assuming the index method of clients is not used.
then write below this line... <br> render json: @clients
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.