Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 将index.html添加到公用文件夹时如何设置根路由?_Ruby On Rails_Heroku - Fatal编程技术网

Ruby on rails 将index.html添加到公用文件夹时如何设置根路由?

Ruby on rails 将index.html添加到公用文件夹时如何设置根路由?,ruby-on-rails,heroku,Ruby On Rails,Heroku,我在heroku上有一个rails 4应用程序,并已将index.html文件放入公用文件夹(我尝试将ionic应用程序用作移动网站)。现在根地址服务于这个index.html文件,而不是routes.rb中的根集。我怎么把它换回来?那么如何链接到index.html呢?根据您的web服务器(而不是app server),在将请求传递到app server之前,默认情况下,它可能会被配置为在public目录中查找。如果是这种情况,您需要在继续之前进行调整 创建一个控制器,例如PublicCont

我在heroku上有一个rails 4应用程序,并已将index.html文件放入公用文件夹(我尝试将ionic应用程序用作移动网站)。现在根地址服务于这个index.html文件,而不是routes.rb中的根集。我怎么把它换回来?那么如何链接到index.html呢?

根据您的web服务器(而不是app server),在将请求传递到app server之前,默认情况下,它可能会被配置为在
public
目录中查找。如果是这种情况,您需要在继续之前进行调整

创建一个控制器,例如
PublicController
,并添加一个
索引
操作。然后将您的
index.html
文件复制到
app/views/public
目录,如果您希望添加erb文件扩展名。您可能希望跳过使用默认为
application.html.erb
的布局,如果在
PublicController
中出现这种情况,您可以添加
layout false,仅::index
跳过使用文件布局


在routes中,将
root设置为:'public#index
,当点击根url时,默认情况下它将为您的文件提供服务。

谢谢,这是一个有效的答案,但最后我已将我放入public/的所有文件移动到public/www/(www文件夹js、css、html等),然后仅链接到host/www/移动网站。