My first impression is that this is not directly possible in Radiant.

   You could access the send_data() method of ActionController indirectly
through an instance or class variable.   The problem is that Radiant will
try to render the page+layout and send it back to the user, so with the
"extra" send_data() you will get a double render error from Rails.

    A solution is to do the send_data() in Rails code and modify the routes
so the download request get routed to an action/controller outside Radiant.
You could do this with one of the existing rails-on-radiant extensions
available, or hack directly the Radiant code.

    Anyway, it would be nice to have this send-data functionality packed in
a Radiant extension.  It looks a nice feature to have.

    /AITOR

On 11/6/07, Enzo Ferro <[EMAIL PROTECTED]> wrote:
>
> Hy everybody,
> how can I use the "send_data" method in a radius tag?
>
> More details:
> in a RoR application I've used the method "send_data" to download e file
> stored in a database table in this way:
>
> rhtml code:
> <%= link_to 'Download', :action => 'download', :id => file_list.id %>
>
> controller code:
> def download
>    @file = FileList.find(params[:id])
>    @xml = @file.xmlfile #polymorphic associations
>    send_data(@xml.file, :type => "txt/xml", :filename =>
> "[EMAIL PROTECTED]")
> end
>
> It's work fine, but now in my radiant extension I need a tag that do the
> same thing. I've developed this tag:
>
> tag "download" do |tag|
>
>   @file_id = request.parameters[:file]
>   @file = FileList.find(:all, :conditions => [ "id = ?", @file_id ])
>   @ file.each do |file|
>      send_data("#{file.xmlfile.file}", :type => "txt/xml", :filename =>
> "#{file.filename}")
>   end
> end
>
> It returs me the error "undefined method send_data for #"
>
> Anyone can help me?
>
> Thanks and greatings
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Radiant mailing list
> Post:   [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to