Ruby on Rails Thursday, February 15, 2018

match '/', to: 'posts#index', constraints: { subdomain: /.+/ }, via: [:get, :post, :put, :patch, :delete]
Something like this is supposed to go into routes.rb My mounted engine has a posts controller and it's routes.rb looks like this:
Blogit::Engine.routes.draw do

  # Keep these above the posts resources block
  get "posts/page/:page" => "posts#index"
  get "posts/tagged/:tag" => 'posts#tagged', as: :tagged_blog_posts

  resources :posts do
    resources :comments, only: [:create, :destroy]
  end

#  get "/" => "posts#index", as: :blog_root
#  get "/:blogger" => "posts#index", as: 'blogger_posts'
end

And my main app routes.rb files has
  mount Blogit::Engine => "/blog", as: 'blog'

So then how do I route a subdomain to the root_path of the engine?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e90840d8-4b10-4817-b764-82773f998af1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment