hello all,
I’m trying to get my feet wet with a small webapp but it’s getting
frustrating to put together all the pieces of the REST/CRUD/restful
controllers/composite views (composite meaning with more than 1
resources in the view).
So to make the problem concrete I have the following models
- class Deal < ActiveRecord::Base
- belongs_to :Restaurant
- belongs_to :Location
- …
- end
- class Location < ActiveRecord::Base
- belongs_to :Restaurant
- end
- class Restaurant < ActiveRecord::Base
- has_many :Location
- has_many :Deal
- …
- end
In my mind each of these models corresponds to a resource, so each
model come with its controller and its 7 CRUD controller actions, and
the route mappings in routes.rb.
Up till now restful design is adhered (I think). What buffles me is
how to present information from these 3 models (or any number of
models, for that matter) in a single (composite) view and still remain
RESTful? Use of partials and a dedicated controller with 1 action
(without an underlying model) in order to present these resources in a
single view doesn’t seem very restful to me. Regardless of REST, is
the above solution (partials and dedicated controller) a valid RoR
approach?
I read somewhere that REST makes more sense in a web services scenario
than a UI webapp. How much of this is true?
Regarding the resource generator: it scaffolds a model and an empty
controller. Does this make any sense when the Rails take on REST tends
to associate a resource with an ActiveRecord model, or a model/
controller stack? I mean, where are the CRUD actions? The scaffold
generator scaffolds a restful controller and the views, which I do not
want since I need composite screens.
sigh and thank you