RESTful question


#1

I have a restful app which is laid out in true restful fashion. But I
need a way to dump all the info since the purpose of this app is to
generate a config file. Do I create a new model and have the index of
that do the dump? I don’t want to just iterate through the individual
records with Show bc I do need to run som logic over the sum of data.

So do I just scaffold something called dump and have index of /dump
output the config file?


#2

Oooh… I’m gonna throw my own spin on this and say tha it should not be
a
create… but instead a retrieve. While it’s true you might be
“creating” a
new dump, you actually want to “GET” the configuration from the system.
Just like when you request a resource that might be XML,. you don’t
“create
a new dump of the objects in xml” , you request them as xml, and you
call
@foos.to_xml, where Rails creates the XML on the fly and renders it.

So…

routes.rb

map.resource :configuration

configurations_controller.rb…

class ConfigurationsController < ApplicationController

def show
@some_model = SomeModel.build_configuration
# some rendering to the view, or send_file, or send_data or
whatever
end

end

That, to me, seems the appropriate method. UNLESS you really are letting
people create a configuration that you want to persist somewhere for
later
retrieval, then the create action might be appropriate. But it sounds
to me
like you really are doing a RETRIEVAL, so that sounds like GET
/configuration


#3

On Oct 16, 3:57 pm, “Brian H.” removed_email_address@domain.invalid wrote:

Oooh… I’m gonna throw my own spin on this and say tha it should not be a
create… but instead a retrieve. While it’s true you might be “creating” a
new dump, you actually want to “GET” the configuration from the system.

That’s another good way to look at it.

Jeff


#4

On Oct 16, 11:20 am, Digant Kasundra <rails-mailing-l…@andreas-
s.net> wrote:

I have a restful app which is laid out in true restful fashion. But I
need a way to dump all the info since the purpose of this app is to
generate a config file. Do I create a new model and have the index of
that do the dump? I don’t want to just iterate through the individual
records with Show bc I do need to run som logic over the sum of data.

So do I just scaffold something called dump and have index of /dump
output the config file?

Posted viahttp://www.ruby-forum.com/.

Sounds to me like you want a new controller with a create action to
generate the config file. That would be restful approach.

Jeff

purpleworkshops.com
softiesonrails.com