RoutingError inside an iFrame

2019-03-04 12:00发布

问题:

I scaffolded a test app and got a Routing error when I put an iFrame inside my view:

This is the show template where I added the iFrame:

views/bars/show.html.erb:

<p>
  <b>Body:</b>
  <%=h @bar.body %>
</p>

<iframe src=“http://www.yahoo.com” style=“width:500px; height:500px;” frameborder=“0?></iframe>


<%= link_to 'Edit', edit_bar_path(@bar) %> |
<%= link_to 'Back', bars_path %>

I'm calling the page like this:

http://localhost:3000/bars/1

The page displays correctly. But the iFrame inside the page says this:

Routing Error

No route matches "/bars/%E2%80%9Chttp://www.yahoo.com%E2%80%9D" 
with {:method=>:get}

I didn't make any changes to routes.rb from the defaults:

ActionController::Routing::Routes.draw do |map|
  map.resources :bars
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

回答1:

You're not using the right double quote character, which is "