By 'view' here I mean different combinations of properties of the model, not the view of the traditional MVC. For example, I have the following model:
class Game < ActiveRecord::Base
has_many :players
belongs_to :status
has_one :deck
has_many :turns
has_one :current_turn, :class_name => 'Turn', :conditions => ['turn_num = ?', '#{self.turn_num}']
end
I've written a full_xml
method for Game that I use for the 'normal' get operation, so that I can include certain properties of players and current_turn, and then I don't have to do GETs on every player all the time. I also don't want to include ALL the properties and children and children's properties of the Game model on every GET
Now, however, I want to GET a game history, which is all the turns (and their properties/children). Initially I thought of a new model w/out a corresponding table, and then realized that wasn't necessary because the data and relationships are already there in the game and turns models. I also thought about writing a new action, but I thought I read somewhere that in the RESTful world, you shouldn't be writing any actions other than the core 7.
BTW, I'm thinking here of returning xml, because I'm using a Flex front end instead of rails views.