How would an action that sends a file (build dynamically using data from
model) to user work in REST application? Is it ok if I add “download”
action to my controller and routes.rb (:collection => {:download =>
:get})? Or should it be done differently?
How would an action that sends a file (build dynamically using data from
model) to user work in REST application? Is it ok if I add “download”
action to my controller and routes.rb (:collection => {:download =>
:get})? Or should it be done differently?
If you’re talking about resources, it makes more sense to make that
file it’s own resource.
map.resources :foos do |foo|
foo.resource :download # assuming there’s one ‘dynamic’ file per Foo
record
end
GET /foos/1/download # downloads/index action.
Part of the rails restful routing style was to stick to the core 7
actions (index, show, new, edit, update, create, destroy) by bringing
out the “inner resource”. This makes more sense if folks can also
update or destroy the extra resource. Then you wouldn’t need several
actions like show_download, create_download, etc.
Actually I don’t need to create a file for every resource item
(:foo),but thanks anyway - maybe I’ll add such functionality, now when I
know how to do it
I’d like to be able to access results of my resources index action
(http://localhost/foos) in 3 ways - html format - by viewing it in a
browser, plain text - by getting data using GET “Accept: text/plain”
(works fine) and a plain text file, which would contain exactly same
results as previous option, but could be downloaded from the index page
by clicking a button.
Hi, could you provide more info about your environment and the
webserver you’re trying to use?
Rails version? Webserver?
Sure. Thanks. I’m on Ubuntu Gutsy (like unstable in Debian perhaps)
recently installed:
root@radioflyer:~/chapter-1# rails -v
Rails 1.2.3
I have this code in chapter-1/scripts/server:
root@radioflyer:~/chapter-1# cat script/server;echo
#!/usr/bin/env ruby
require File.dirname(FILE) + ‘/…/config/boot’
require ‘commands/server’
root@radioflyer:~/chapter-1#
–snip–
which differs from what I see on page 7 of Up_and_Running. Presumably
things have been radically refactored since that publishing.
xc
The only sustainable organizing methods focus not on scale,
but on good design of the functional unit,
not on winning battles, but on preservation.
–
The only sustainable organizing methods focus not on scale,
but on good design of the functional unit,
not on winning battles, but on preservation.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.