Forum: Ruby on Rails RESTful question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Digant K. (Guest)
on 2008-10-16 20:20
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?
Jeff C. (Guest)
on 2008-10-16 20:29
(Received via mailing list)
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
Brian H. (Guest)
on 2008-10-17 00:58
(Received via mailing list)
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
Jeff C. (Guest)
on 2008-10-20 18:02
(Received via mailing list)
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
This topic is locked and can not be replied to.