Skip to content
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

banyan
Copy link
Contributor

@banyan 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
Copy link

  • 1 Makes sense.

@frodsan
Copy link
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
Copy link
Contributor

frodsan commented Feb 26, 2013

@banyan Thanks! ❤️

@guilleiguaran
Copy link
Member

Thanks!!!

@banyan
Copy link
Contributor Author

banyan commented Feb 26, 2013

Thanks!

@rubys
Copy link
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
Copy link
Contributor Author

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
Copy link
Member

@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
Copy link
Contributor Author

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
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
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants