Render an external html page as body in your RoR project:
Encoding::CompatibilityError
I want an external webpage rates.appiclife.com to be rendered in the
applications <%=yield%>.
I tried this:
I placed the following method in pages_controller.rb
def fetch_url(url)
r = Net::HTTP.get_response( URI.parse( url ) )
if r.is_a? Net::HTTPSuccess
r.body
else
nil
end
end
In the same file:
def showexternal
@snippet = fetch_url "http://rates.appiclife.com/"
end
And in the showexternal.html.erb view/pages:
<%= @snippet %>
I get the following error: incompatible character encodings: UTF-8 and
ASCII-8BIT
Is it even possible to do this? The thing is that those prices are updated
and received in an excel file, so a lot of work to adapt them if I just
place them in a html-table.
No comments:
Post a Comment