Topic: Where to put things

I am new to rails and i am having problems where to put things

on my model i have

class Client
a JSON CALL

on my controller  i have

class ClientsController < ApplicationController
  expose(:clients){
    clients = Client.new
    clients = clients.all
  }
  expose(:oncs){
    c = Client.new
    c.find_oncall(params[:id])
  }


end

but if i wanted to check the data and only show something would i do that on the Controller  or the view ???

Re: Where to put things

I'm not sure what the expose method does, it's not something I have come across before
In general terms

a Model is used as a middle tier for your database. i.e. the role of a model is to retrieve data from and save data to the database ensuring any business logic rules are enforced and that is it.

A controllers job is to determine what to return to the client and if a particular page needs some data then it gets that data from an appropriate method in an appropriate model and render the correct template (html, json, xml or whatever)

The route's job is to determine which controller and action within that controller should respond to a url

e.g. if you had a table called cars and and you wanted to show a list of all cars in an html view you could use the automatic rails generator to scaffold a car
rails scaffold car name:string

This would generate CRUD route resources for cars, a controller called cars with actions to list all cars, create new cars, update existog cars and delete cars with appropriate html templates in the views/cars folder to support it all.

So the view contains the actual html and the controller supplies the data that the view needs in the form of instance variables (@something is accessible to the view) or th controller action can simply render text
Try it and see what you get, then have a look at the source code generated and you will get a pretty good idea of how Rails is put together

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)