Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/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 如何将url路由设置为其他子域_Ruby On Rails_Routing_Subdomain - Fatal编程技术网

Ruby on rails 如何将url路由设置为其他子域

Ruby on rails 如何将url路由设置为其他子域,ruby-on-rails,routing,subdomain,Ruby On Rails,Routing,Subdomain,我可以使用哪种路由路径从非子域页面链接到子域页面 我已经通过以下方式向我的站点添加了子域 我对我的站点所做的主要更改是将每个博客作者与一个唯一的子域相匹配 routes.rb match '', to: 'blogs#show', constraints: {subdomain: /.+/} def show @blog = Blog.find_by_subdomain!(request.subdomain) end <%= link_to blog.name, root_url(su

我可以使用哪种路由路径从非子域页面链接到子域页面

我已经通过以下方式向我的站点添加了子域

我对我的站点所做的主要更改是将每个博客作者与一个唯一的子域相匹配

routes.rb

match '', to: 'blogs#show', constraints: {subdomain: /.+/}
def show
@blog = Blog.find_by_subdomain!(request.subdomain)
end
<%= link_to blog.name, root_url(subdomain: blog.subdomain) %>
blogs\u controller.rb

match '', to: 'blogs#show', constraints: {subdomain: /.+/}
def show
@blog = Blog.find_by_subdomain!(request.subdomain)
end
<%= link_to blog.name, root_url(subdomain: blog.subdomain) %>
blogs/index.html.erb

match '', to: 'blogs#show', constraints: {subdomain: /.+/}
def show
@blog = Blog.find_by_subdomain!(request.subdomain)
end
<%= link_to blog.name, root_url(subdomain: blog.subdomain) %>
从忍者子域页面(这是我想要的),但是

从主页没有子域(不是我想要的)


有没有一种方法可以通过类似于,
article(subdomain:article.blog.subdomain)
的方式强制指向特定子域的路径?我希望每一篇文章的链接都能转到一个子域名页面

为了使文章的所有链接都具有作者博客的子域,我使用了

article\uURL(article,子域:article.blog.subdomain)

作为我的道路