Can't get Heroku to serve public index.html page
I've been trying to launch my project https://github.com/robdrosenberg/news-hunt on Heroku the last couple days and heroku won't serve my public/index.html page.
Here is the error I'm currently getting:
ActionController::RoutingError (No route matches [GET] "/")
This error has been brought up all over StackOverflow and I've tried as many of those solutions as I could.
For example, routing to the file directly through a welcome controller gives me an error as well
Routes
Rails.application.routes.draw do
post 'user_token' => 'user_token#create'
post 'users' => 'users#create'
namespace :api do
get 'reddit' => 'posts#reddit'
get 'producthunt' => 'posts#producthunt'
get 'medium' => 'posts#medium'
get 'hackernews' => 'posts#hackernews'
get 'githubtrending' => 'posts#githubtrending'
get 'all' => 'posts#all'
get 'bookmarks' => 'bookmarks#index'
post 'bookmarks' => 'bookmarks#create'
delete 'bookmarks' => 'bookmarks#destroy'
end
root 'welcome#index'
end
Controller
class WelcomeController < ApplicationController
def index
render file: Rails.root.join('public','index.html')
end
end
Error
ActionView::MissingTemplate (Missing template public/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: app/app/views
Changing config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
to = true hasn't made a difference.
I've tried using redirects which result in the app crashing from too many redirects.
What I find odd is when I try to render the file directly it searches in the app/views folder. Everything works fine locally, so it has to be something with the production environment and Heroku.
I'm using Rails in API mode and using Vue through CDN in my index.html file.
I deployed a different project the same way and had no issues. You can find that codebase here: https://github.com/robdrosenberg/commitment-ledger.
Any help is greatly appreciated!
ruby-on-rails heroku deployment
add a comment |
I've been trying to launch my project https://github.com/robdrosenberg/news-hunt on Heroku the last couple days and heroku won't serve my public/index.html page.
Here is the error I'm currently getting:
ActionController::RoutingError (No route matches [GET] "/")
This error has been brought up all over StackOverflow and I've tried as many of those solutions as I could.
For example, routing to the file directly through a welcome controller gives me an error as well
Routes
Rails.application.routes.draw do
post 'user_token' => 'user_token#create'
post 'users' => 'users#create'
namespace :api do
get 'reddit' => 'posts#reddit'
get 'producthunt' => 'posts#producthunt'
get 'medium' => 'posts#medium'
get 'hackernews' => 'posts#hackernews'
get 'githubtrending' => 'posts#githubtrending'
get 'all' => 'posts#all'
get 'bookmarks' => 'bookmarks#index'
post 'bookmarks' => 'bookmarks#create'
delete 'bookmarks' => 'bookmarks#destroy'
end
root 'welcome#index'
end
Controller
class WelcomeController < ApplicationController
def index
render file: Rails.root.join('public','index.html')
end
end
Error
ActionView::MissingTemplate (Missing template public/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: app/app/views
Changing config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
to = true hasn't made a difference.
I've tried using redirects which result in the app crashing from too many redirects.
What I find odd is when I try to render the file directly it searches in the app/views folder. Everything works fine locally, so it has to be something with the production environment and Heroku.
I'm using Rails in API mode and using Vue through CDN in my index.html file.
I deployed a different project the same way and had no issues. You can find that codebase here: https://github.com/robdrosenberg/commitment-ledger.
Any help is greatly appreciated!
ruby-on-rails heroku deployment
By default Rails will look in the app views directory. Specifically it will look for a folder calledwelcome
, soapp/views/welcome
that has a file calledindex.html.erb
, the end result beingapp/views/welcome/index.html.erb
is what Rails expects. if you look at the route it will make senseroot 'welcome#index'
, sowelcome
is the folder inside the views directory, andindex.html.erb
is the file it will look for.
– Rockwell Rice
Nov 16 '18 at 1:42
Have you tried/index
?
– Simon L. Brazell
Nov 16 '18 at 4:16
@RockwellRice Wouldn't root 'welcome#index' route to the index method in my welcome controller? I have that pointing to a file it should render.
– RobDRosenberg
Nov 16 '18 at 18:17
@SimonBrazell where should I try putting /index? Not sure what you mean sorry!
– RobDRosenberg
Nov 16 '18 at 18:17
add a comment |
I've been trying to launch my project https://github.com/robdrosenberg/news-hunt on Heroku the last couple days and heroku won't serve my public/index.html page.
Here is the error I'm currently getting:
ActionController::RoutingError (No route matches [GET] "/")
This error has been brought up all over StackOverflow and I've tried as many of those solutions as I could.
For example, routing to the file directly through a welcome controller gives me an error as well
Routes
Rails.application.routes.draw do
post 'user_token' => 'user_token#create'
post 'users' => 'users#create'
namespace :api do
get 'reddit' => 'posts#reddit'
get 'producthunt' => 'posts#producthunt'
get 'medium' => 'posts#medium'
get 'hackernews' => 'posts#hackernews'
get 'githubtrending' => 'posts#githubtrending'
get 'all' => 'posts#all'
get 'bookmarks' => 'bookmarks#index'
post 'bookmarks' => 'bookmarks#create'
delete 'bookmarks' => 'bookmarks#destroy'
end
root 'welcome#index'
end
Controller
class WelcomeController < ApplicationController
def index
render file: Rails.root.join('public','index.html')
end
end
Error
ActionView::MissingTemplate (Missing template public/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: app/app/views
Changing config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
to = true hasn't made a difference.
I've tried using redirects which result in the app crashing from too many redirects.
What I find odd is when I try to render the file directly it searches in the app/views folder. Everything works fine locally, so it has to be something with the production environment and Heroku.
I'm using Rails in API mode and using Vue through CDN in my index.html file.
I deployed a different project the same way and had no issues. You can find that codebase here: https://github.com/robdrosenberg/commitment-ledger.
Any help is greatly appreciated!
ruby-on-rails heroku deployment
I've been trying to launch my project https://github.com/robdrosenberg/news-hunt on Heroku the last couple days and heroku won't serve my public/index.html page.
Here is the error I'm currently getting:
ActionController::RoutingError (No route matches [GET] "/")
This error has been brought up all over StackOverflow and I've tried as many of those solutions as I could.
For example, routing to the file directly through a welcome controller gives me an error as well
Routes
Rails.application.routes.draw do
post 'user_token' => 'user_token#create'
post 'users' => 'users#create'
namespace :api do
get 'reddit' => 'posts#reddit'
get 'producthunt' => 'posts#producthunt'
get 'medium' => 'posts#medium'
get 'hackernews' => 'posts#hackernews'
get 'githubtrending' => 'posts#githubtrending'
get 'all' => 'posts#all'
get 'bookmarks' => 'bookmarks#index'
post 'bookmarks' => 'bookmarks#create'
delete 'bookmarks' => 'bookmarks#destroy'
end
root 'welcome#index'
end
Controller
class WelcomeController < ApplicationController
def index
render file: Rails.root.join('public','index.html')
end
end
Error
ActionView::MissingTemplate (Missing template public/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: app/app/views
Changing config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
to = true hasn't made a difference.
I've tried using redirects which result in the app crashing from too many redirects.
What I find odd is when I try to render the file directly it searches in the app/views folder. Everything works fine locally, so it has to be something with the production environment and Heroku.
I'm using Rails in API mode and using Vue through CDN in my index.html file.
I deployed a different project the same way and had no issues. You can find that codebase here: https://github.com/robdrosenberg/commitment-ledger.
Any help is greatly appreciated!
ruby-on-rails heroku deployment
ruby-on-rails heroku deployment
edited Nov 16 '18 at 20:07
RobDRosenberg
asked Nov 16 '18 at 1:21
RobDRosenbergRobDRosenberg
314
314
By default Rails will look in the app views directory. Specifically it will look for a folder calledwelcome
, soapp/views/welcome
that has a file calledindex.html.erb
, the end result beingapp/views/welcome/index.html.erb
is what Rails expects. if you look at the route it will make senseroot 'welcome#index'
, sowelcome
is the folder inside the views directory, andindex.html.erb
is the file it will look for.
– Rockwell Rice
Nov 16 '18 at 1:42
Have you tried/index
?
– Simon L. Brazell
Nov 16 '18 at 4:16
@RockwellRice Wouldn't root 'welcome#index' route to the index method in my welcome controller? I have that pointing to a file it should render.
– RobDRosenberg
Nov 16 '18 at 18:17
@SimonBrazell where should I try putting /index? Not sure what you mean sorry!
– RobDRosenberg
Nov 16 '18 at 18:17
add a comment |
By default Rails will look in the app views directory. Specifically it will look for a folder calledwelcome
, soapp/views/welcome
that has a file calledindex.html.erb
, the end result beingapp/views/welcome/index.html.erb
is what Rails expects. if you look at the route it will make senseroot 'welcome#index'
, sowelcome
is the folder inside the views directory, andindex.html.erb
is the file it will look for.
– Rockwell Rice
Nov 16 '18 at 1:42
Have you tried/index
?
– Simon L. Brazell
Nov 16 '18 at 4:16
@RockwellRice Wouldn't root 'welcome#index' route to the index method in my welcome controller? I have that pointing to a file it should render.
– RobDRosenberg
Nov 16 '18 at 18:17
@SimonBrazell where should I try putting /index? Not sure what you mean sorry!
– RobDRosenberg
Nov 16 '18 at 18:17
By default Rails will look in the app views directory. Specifically it will look for a folder called
welcome
, so app/views/welcome
that has a file called index.html.erb
, the end result being app/views/welcome/index.html.erb
is what Rails expects. if you look at the route it will make sense root 'welcome#index'
, so welcome
is the folder inside the views directory, and index.html.erb
is the file it will look for.– Rockwell Rice
Nov 16 '18 at 1:42
By default Rails will look in the app views directory. Specifically it will look for a folder called
welcome
, so app/views/welcome
that has a file called index.html.erb
, the end result being app/views/welcome/index.html.erb
is what Rails expects. if you look at the route it will make sense root 'welcome#index'
, so welcome
is the folder inside the views directory, and index.html.erb
is the file it will look for.– Rockwell Rice
Nov 16 '18 at 1:42
Have you tried
/index
?– Simon L. Brazell
Nov 16 '18 at 4:16
Have you tried
/index
?– Simon L. Brazell
Nov 16 '18 at 4:16
@RockwellRice Wouldn't root 'welcome#index' route to the index method in my welcome controller? I have that pointing to a file it should render.
– RobDRosenberg
Nov 16 '18 at 18:17
@RockwellRice Wouldn't root 'welcome#index' route to the index method in my welcome controller? I have that pointing to a file it should render.
– RobDRosenberg
Nov 16 '18 at 18:17
@SimonBrazell where should I try putting /index? Not sure what you mean sorry!
– RobDRosenberg
Nov 16 '18 at 18:17
@SimonBrazell where should I try putting /index? Not sure what you mean sorry!
– RobDRosenberg
Nov 16 '18 at 18:17
add a comment |
3 Answers
3
active
oldest
votes
You don’t actually have a public/index.html
page in that repo, but rather a public/Index.html
(note the case of the ‘i’ and ‘I’). This won’t make much difference if you’re developing on Windows or Mac, but on Linux (which is used on Heroku) they will be treated as different files.
Rename the file to index.html
(use git mv
and don’t forget to commit) and it should work.
So this was the issue. I checked for it but I did not use git mv. I officially feel dumb but I’m still learning. Thank you for your help!
– RobDRosenberg
Nov 17 '18 at 20:00
add a comment |
Is there a reason you want to redirect to public/index? Of course, I don't know your application, so this may not be helpful. Have you considered moving your index.html file to the views/welcome directory? This is the default location that the welcome#index method will render a file from.
I don't want to redirect to that file, but I've tried it based on other peoples solutions throughout Stack Overflow. I haven't tried moving my index.html file to a views folder. Does it need to be an index.html.erb file for it to work in there?
– RobDRosenberg
Nov 16 '18 at 18:19
I tried moving the index file to the welcome views folder and routing to it. I got this error:Missing template Users/robertrosenberg/news-hunt/views/welcome/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: * "/Users/robertrosenberg/news-hunt/app/views" * "/Users/robertrosenberg/news-hunt" * "/"
– RobDRosenberg
Nov 16 '18 at 20:06
It sounds like @matt may have found the problem with both of these errors in that filenames are case-sensitive in Linux.
– Rick
Nov 16 '18 at 22:42
add a comment |
Try adding this to your config/routes.rb
file:
get '', to: redirect('/Index.html')
That way the requests to the application root will redirect to the index file in the public folder.
As mentioned below you have named the file with a capital ‘I’, you will need to use the same case when referencing it in the redirect above, as updated.
This is the error I get when trying your solution.ActionController::RoutingError (No route matches [GET] "/public/index.html"):
the index.html file does exist in the public file when I check for it in heroku bash.
– RobDRosenberg
Nov 16 '18 at 18:32
That’s pretty strange, to be honest I only tried it with the files already present in the public folder in my local environment e.g. 404.html etc. maybe try renaming the file to something other than index?
– Simon L. Brazell
Nov 16 '18 at 22:22
Updated to include the correct file name, please try again with the updated redirect.
– Simon L. Brazell
Nov 16 '18 at 22:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330141%2fcant-get-heroku-to-serve-public-index-html-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don’t actually have a public/index.html
page in that repo, but rather a public/Index.html
(note the case of the ‘i’ and ‘I’). This won’t make much difference if you’re developing on Windows or Mac, but on Linux (which is used on Heroku) they will be treated as different files.
Rename the file to index.html
(use git mv
and don’t forget to commit) and it should work.
So this was the issue. I checked for it but I did not use git mv. I officially feel dumb but I’m still learning. Thank you for your help!
– RobDRosenberg
Nov 17 '18 at 20:00
add a comment |
You don’t actually have a public/index.html
page in that repo, but rather a public/Index.html
(note the case of the ‘i’ and ‘I’). This won’t make much difference if you’re developing on Windows or Mac, but on Linux (which is used on Heroku) they will be treated as different files.
Rename the file to index.html
(use git mv
and don’t forget to commit) and it should work.
So this was the issue. I checked for it but I did not use git mv. I officially feel dumb but I’m still learning. Thank you for your help!
– RobDRosenberg
Nov 17 '18 at 20:00
add a comment |
You don’t actually have a public/index.html
page in that repo, but rather a public/Index.html
(note the case of the ‘i’ and ‘I’). This won’t make much difference if you’re developing on Windows or Mac, but on Linux (which is used on Heroku) they will be treated as different files.
Rename the file to index.html
(use git mv
and don’t forget to commit) and it should work.
You don’t actually have a public/index.html
page in that repo, but rather a public/Index.html
(note the case of the ‘i’ and ‘I’). This won’t make much difference if you’re developing on Windows or Mac, but on Linux (which is used on Heroku) they will be treated as different files.
Rename the file to index.html
(use git mv
and don’t forget to commit) and it should work.
edited Nov 17 '18 at 20:00
answered Nov 16 '18 at 20:25
mattmatt
66.9k6128170
66.9k6128170
So this was the issue. I checked for it but I did not use git mv. I officially feel dumb but I’m still learning. Thank you for your help!
– RobDRosenberg
Nov 17 '18 at 20:00
add a comment |
So this was the issue. I checked for it but I did not use git mv. I officially feel dumb but I’m still learning. Thank you for your help!
– RobDRosenberg
Nov 17 '18 at 20:00
So this was the issue. I checked for it but I did not use git mv. I officially feel dumb but I’m still learning. Thank you for your help!
– RobDRosenberg
Nov 17 '18 at 20:00
So this was the issue. I checked for it but I did not use git mv. I officially feel dumb but I’m still learning. Thank you for your help!
– RobDRosenberg
Nov 17 '18 at 20:00
add a comment |
Is there a reason you want to redirect to public/index? Of course, I don't know your application, so this may not be helpful. Have you considered moving your index.html file to the views/welcome directory? This is the default location that the welcome#index method will render a file from.
I don't want to redirect to that file, but I've tried it based on other peoples solutions throughout Stack Overflow. I haven't tried moving my index.html file to a views folder. Does it need to be an index.html.erb file for it to work in there?
– RobDRosenberg
Nov 16 '18 at 18:19
I tried moving the index file to the welcome views folder and routing to it. I got this error:Missing template Users/robertrosenberg/news-hunt/views/welcome/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: * "/Users/robertrosenberg/news-hunt/app/views" * "/Users/robertrosenberg/news-hunt" * "/"
– RobDRosenberg
Nov 16 '18 at 20:06
It sounds like @matt may have found the problem with both of these errors in that filenames are case-sensitive in Linux.
– Rick
Nov 16 '18 at 22:42
add a comment |
Is there a reason you want to redirect to public/index? Of course, I don't know your application, so this may not be helpful. Have you considered moving your index.html file to the views/welcome directory? This is the default location that the welcome#index method will render a file from.
I don't want to redirect to that file, but I've tried it based on other peoples solutions throughout Stack Overflow. I haven't tried moving my index.html file to a views folder. Does it need to be an index.html.erb file for it to work in there?
– RobDRosenberg
Nov 16 '18 at 18:19
I tried moving the index file to the welcome views folder and routing to it. I got this error:Missing template Users/robertrosenberg/news-hunt/views/welcome/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: * "/Users/robertrosenberg/news-hunt/app/views" * "/Users/robertrosenberg/news-hunt" * "/"
– RobDRosenberg
Nov 16 '18 at 20:06
It sounds like @matt may have found the problem with both of these errors in that filenames are case-sensitive in Linux.
– Rick
Nov 16 '18 at 22:42
add a comment |
Is there a reason you want to redirect to public/index? Of course, I don't know your application, so this may not be helpful. Have you considered moving your index.html file to the views/welcome directory? This is the default location that the welcome#index method will render a file from.
Is there a reason you want to redirect to public/index? Of course, I don't know your application, so this may not be helpful. Have you considered moving your index.html file to the views/welcome directory? This is the default location that the welcome#index method will render a file from.
answered Nov 16 '18 at 6:02
RickRick
2015
2015
I don't want to redirect to that file, but I've tried it based on other peoples solutions throughout Stack Overflow. I haven't tried moving my index.html file to a views folder. Does it need to be an index.html.erb file for it to work in there?
– RobDRosenberg
Nov 16 '18 at 18:19
I tried moving the index file to the welcome views folder and routing to it. I got this error:Missing template Users/robertrosenberg/news-hunt/views/welcome/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: * "/Users/robertrosenberg/news-hunt/app/views" * "/Users/robertrosenberg/news-hunt" * "/"
– RobDRosenberg
Nov 16 '18 at 20:06
It sounds like @matt may have found the problem with both of these errors in that filenames are case-sensitive in Linux.
– Rick
Nov 16 '18 at 22:42
add a comment |
I don't want to redirect to that file, but I've tried it based on other peoples solutions throughout Stack Overflow. I haven't tried moving my index.html file to a views folder. Does it need to be an index.html.erb file for it to work in there?
– RobDRosenberg
Nov 16 '18 at 18:19
I tried moving the index file to the welcome views folder and routing to it. I got this error:Missing template Users/robertrosenberg/news-hunt/views/welcome/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: * "/Users/robertrosenberg/news-hunt/app/views" * "/Users/robertrosenberg/news-hunt" * "/"
– RobDRosenberg
Nov 16 '18 at 20:06
It sounds like @matt may have found the problem with both of these errors in that filenames are case-sensitive in Linux.
– Rick
Nov 16 '18 at 22:42
I don't want to redirect to that file, but I've tried it based on other peoples solutions throughout Stack Overflow. I haven't tried moving my index.html file to a views folder. Does it need to be an index.html.erb file for it to work in there?
– RobDRosenberg
Nov 16 '18 at 18:19
I don't want to redirect to that file, but I've tried it based on other peoples solutions throughout Stack Overflow. I haven't tried moving my index.html file to a views folder. Does it need to be an index.html.erb file for it to work in there?
– RobDRosenberg
Nov 16 '18 at 18:19
I tried moving the index file to the welcome views folder and routing to it. I got this error:
Missing template Users/robertrosenberg/news-hunt/views/welcome/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: * "/Users/robertrosenberg/news-hunt/app/views" * "/Users/robertrosenberg/news-hunt" * "/"
– RobDRosenberg
Nov 16 '18 at 20:06
I tried moving the index file to the welcome views folder and routing to it. I got this error:
Missing template Users/robertrosenberg/news-hunt/views/welcome/index.html with :locale=>[:en], :formats=>[:html], :variants=>, :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]. Searched in: * "/Users/robertrosenberg/news-hunt/app/views" * "/Users/robertrosenberg/news-hunt" * "/"
– RobDRosenberg
Nov 16 '18 at 20:06
It sounds like @matt may have found the problem with both of these errors in that filenames are case-sensitive in Linux.
– Rick
Nov 16 '18 at 22:42
It sounds like @matt may have found the problem with both of these errors in that filenames are case-sensitive in Linux.
– Rick
Nov 16 '18 at 22:42
add a comment |
Try adding this to your config/routes.rb
file:
get '', to: redirect('/Index.html')
That way the requests to the application root will redirect to the index file in the public folder.
As mentioned below you have named the file with a capital ‘I’, you will need to use the same case when referencing it in the redirect above, as updated.
This is the error I get when trying your solution.ActionController::RoutingError (No route matches [GET] "/public/index.html"):
the index.html file does exist in the public file when I check for it in heroku bash.
– RobDRosenberg
Nov 16 '18 at 18:32
That’s pretty strange, to be honest I only tried it with the files already present in the public folder in my local environment e.g. 404.html etc. maybe try renaming the file to something other than index?
– Simon L. Brazell
Nov 16 '18 at 22:22
Updated to include the correct file name, please try again with the updated redirect.
– Simon L. Brazell
Nov 16 '18 at 22:26
add a comment |
Try adding this to your config/routes.rb
file:
get '', to: redirect('/Index.html')
That way the requests to the application root will redirect to the index file in the public folder.
As mentioned below you have named the file with a capital ‘I’, you will need to use the same case when referencing it in the redirect above, as updated.
This is the error I get when trying your solution.ActionController::RoutingError (No route matches [GET] "/public/index.html"):
the index.html file does exist in the public file when I check for it in heroku bash.
– RobDRosenberg
Nov 16 '18 at 18:32
That’s pretty strange, to be honest I only tried it with the files already present in the public folder in my local environment e.g. 404.html etc. maybe try renaming the file to something other than index?
– Simon L. Brazell
Nov 16 '18 at 22:22
Updated to include the correct file name, please try again with the updated redirect.
– Simon L. Brazell
Nov 16 '18 at 22:26
add a comment |
Try adding this to your config/routes.rb
file:
get '', to: redirect('/Index.html')
That way the requests to the application root will redirect to the index file in the public folder.
As mentioned below you have named the file with a capital ‘I’, you will need to use the same case when referencing it in the redirect above, as updated.
Try adding this to your config/routes.rb
file:
get '', to: redirect('/Index.html')
That way the requests to the application root will redirect to the index file in the public folder.
As mentioned below you have named the file with a capital ‘I’, you will need to use the same case when referencing it in the redirect above, as updated.
edited Nov 16 '18 at 22:25
answered Nov 16 '18 at 4:20
Simon L. BrazellSimon L. Brazell
51639
51639
This is the error I get when trying your solution.ActionController::RoutingError (No route matches [GET] "/public/index.html"):
the index.html file does exist in the public file when I check for it in heroku bash.
– RobDRosenberg
Nov 16 '18 at 18:32
That’s pretty strange, to be honest I only tried it with the files already present in the public folder in my local environment e.g. 404.html etc. maybe try renaming the file to something other than index?
– Simon L. Brazell
Nov 16 '18 at 22:22
Updated to include the correct file name, please try again with the updated redirect.
– Simon L. Brazell
Nov 16 '18 at 22:26
add a comment |
This is the error I get when trying your solution.ActionController::RoutingError (No route matches [GET] "/public/index.html"):
the index.html file does exist in the public file when I check for it in heroku bash.
– RobDRosenberg
Nov 16 '18 at 18:32
That’s pretty strange, to be honest I only tried it with the files already present in the public folder in my local environment e.g. 404.html etc. maybe try renaming the file to something other than index?
– Simon L. Brazell
Nov 16 '18 at 22:22
Updated to include the correct file name, please try again with the updated redirect.
– Simon L. Brazell
Nov 16 '18 at 22:26
This is the error I get when trying your solution.
ActionController::RoutingError (No route matches [GET] "/public/index.html"):
the index.html file does exist in the public file when I check for it in heroku bash.– RobDRosenberg
Nov 16 '18 at 18:32
This is the error I get when trying your solution.
ActionController::RoutingError (No route matches [GET] "/public/index.html"):
the index.html file does exist in the public file when I check for it in heroku bash.– RobDRosenberg
Nov 16 '18 at 18:32
That’s pretty strange, to be honest I only tried it with the files already present in the public folder in my local environment e.g. 404.html etc. maybe try renaming the file to something other than index?
– Simon L. Brazell
Nov 16 '18 at 22:22
That’s pretty strange, to be honest I only tried it with the files already present in the public folder in my local environment e.g. 404.html etc. maybe try renaming the file to something other than index?
– Simon L. Brazell
Nov 16 '18 at 22:22
Updated to include the correct file name, please try again with the updated redirect.
– Simon L. Brazell
Nov 16 '18 at 22:26
Updated to include the correct file name, please try again with the updated redirect.
– Simon L. Brazell
Nov 16 '18 at 22:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330141%2fcant-get-heroku-to-serve-public-index-html-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
By default Rails will look in the app views directory. Specifically it will look for a folder called
welcome
, soapp/views/welcome
that has a file calledindex.html.erb
, the end result beingapp/views/welcome/index.html.erb
is what Rails expects. if you look at the route it will make senseroot 'welcome#index'
, sowelcome
is the folder inside the views directory, andindex.html.erb
is the file it will look for.– Rockwell Rice
Nov 16 '18 at 1:42
Have you tried
/index
?– Simon L. Brazell
Nov 16 '18 at 4:16
@RockwellRice Wouldn't root 'welcome#index' route to the index method in my welcome controller? I have that pointing to a file it should render.
– RobDRosenberg
Nov 16 '18 at 18:17
@SimonBrazell where should I try putting /index? Not sure what you mean sorry!
– RobDRosenberg
Nov 16 '18 at 18:17