max pleaner
max pleaner

Reputation: 26768

linking to html file in /public

I have a file 'maps.html' located in /public. I am loading up an index page with contents as follows: <%= link_to 'redirect_click_here', 'maps.html' %>. Application.html.erb takes care of the other necessary html elements for the page. The result of clicking that link is that I am sent to /map/maps.html.

This is slightly logical: the page hosting the link was in the 'map' controller. Still, I want to 'escape' the controller and access the public html file.

I realize that this is a kind of pointless request because I could just put the html file in app/views, but it's just for completion's sake that I put forth this request.


edit

One reason I want to include this file from the /public/ directory is that I don't want it to go through the asset pipeline and inherit the html document structure from application.html.erb. I am going to be including HTML files which include custom heads and I don't want to have to replace the contents of application.html.erb every time.

Upvotes: 0

Views: 250

Answers (2)

sevenseacat
sevenseacat

Reputation: 25029

You should use '/maps.html' in your link, so that it knows it is in the root public folder.

Upvotes: 2

Rajdeep Singh
Rajdeep Singh

Reputation: 17834

You can access it by

<%= link_to "Maps", "/your_project/maps.html" %>

Upvotes: 1

Related Questions