Sunday, November 21, 2010

[Rails] Re: Equivalent to View Page Source; No AJAX

Frederick Cheung wrote in post #962809:
> On Nov 20, 4:19pm, Ralph Shnelvar <li...@ruby-forum.com> wrote:
>>
>> Is this possible and/or easy to do?
>>
>
> You could probably do that from an after_filter - you should be able
> to play around with response.body.
>
> Fred

Fred, this is _exactly_ what I wanted! Thanks.

- - -

For information about after_filer, see page 485 in *Agile Web
Development in Rails* by Dave Thomas.

For the clueless (me), here's a code snippet that works for me


class MarketingController < ApplicationController
include ApplicationHelper


after_filter :write_response_body

.
.
.

protected

@@prefix = 'f:/xxx/'
def write_response_body
puts "#{__FILE__} @ #{__LINE__}"
# puts response.body.length
html_file_name_to_save =
@@prefix + params['controller'] + '/' + params['action'] + '.html'
File.open(html_file_name_to_save,"w") { |f| f << response.body }
end

end

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate