New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default root route helper #9419

Merged
merged 1 commit into from Feb 26, 2013

Conversation

Projects
None yet
6 participants
@banyan
Contributor

banyan commented Feb 25, 2013

Since this commit (2ee4dd8), it is allowed to use this root route syntax.

 root "welcome#index"

What about using this syntax as default in a simple and consistent way?

@timmillwood

This comment has been minimized.

timmillwood commented Feb 25, 2013

  • 1 Makes sense.
@frodsan

This comment has been minimized.

Contributor

frodsan commented Feb 26, 2013

👍 /cc @guilleiguaran

guilleiguaran added a commit that referenced this pull request Feb 26, 2013

@guilleiguaran guilleiguaran merged commit 30859a0 into rails:master Feb 26, 2013

@frodsan

This comment has been minimized.

Contributor

frodsan commented Feb 26, 2013

@banyan Thanks! ❤️

@guilleiguaran

This comment has been minimized.

Member

guilleiguaran commented Feb 26, 2013

Thanks!!!

@banyan

This comment has been minimized.

Contributor

banyan commented Feb 26, 2013

Thanks!

@rubys

This comment has been minimized.

Contributor

rubys commented Feb 26, 2013

I'm not a fan. Agile Development with Rails, I suggest adding "as: 'store'". As the root helper takes only one parameter, so you will need to add 'to:'. This is not obvious.

Perhaps the root helper could be modified to accept two parameters, and if the first is a string and the second is a hash will construct the proper hash? Example:

root 'store#index', as: 'store'
@banyan

This comment has been minimized.

Contributor

banyan commented Feb 26, 2013

@rubys

The root helper can be used only once for each application.
In case of root route, URL helpers root_path and root_url are defined by Rails.
So I haven't had the idea that second hash will be passed in.
Certainly it becomes not obvious in such cases. hmm...

@carlosantoniodasilva

This comment has been minimized.

Member

carlosantoniodasilva commented Feb 26, 2013

@banyan actually you can use root inside namespaces/scopes as well, generating different xxx_root_url helpers:

MasterApp::Application.routes.draw do
  namespace :admin do
    root to: "admin#index"
  end

  root to: "home#index"
end
$ rake routes
    Prefix Verb URI Pattern      Controller#Action
admin_root GET /admin(.:format) admin/admin#index
      root GET /                home#index
@banyan

This comment has been minimized.

Contributor

banyan commented Feb 26, 2013

oh, I didn't know that. Thank you for letting me know that. @carlosantoniodasilva

bemurphy added a commit to bemurphy/rails that referenced this pull request Feb 26, 2013

Add routing guide doc on root with namespaces.
I read rails#9419 and realized I didn't know you could have namespaced
roots, checked around, and a few friends didn't either.  Figured
this makes it guide worthy.

sgerrand pushed a commit to sgerrand/rails that referenced this pull request Nov 2, 2013

Merge pull request rails#9441 from rubys/master
This is a small thing, motivated by rails#9419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment