Search code examples
ruby-on-railsrubyrefinerycms

Routes in Ruby On Rails and RefineryCMS


I usually work with Java or Clojure and I have not done much Ruby programming, so I am grateful for your patience. I have just created a new site, with Ruby 2.1.5, Rails 4.1.8 and the latest version of RefineryCMS.

If I do:

bundle exec rake routes

then I see:

new_signup GET    /refinery/users/register(.:format) refinery/users#new

signup POST   /refinery/users/register(.:format) refinery/users#create

but if I point my browser at:

0.0.0.0:3000/new_signup

or:

0.0.0.0:3000/refinery/new_signup

I get 404.

Where should I point my browser to reach these routes?

If I point my browser directly at:

http://0.0.0.0:3000/refinery/users/register

I get redirected to:

http://0.0.0.0:3000/refinery/login

I can guess a few places where I might need to change the settings to fix that, but if you could suggest a place to look, I would be grateful.


Solution

  • When you type bundle exec rake routes the output is in the format:

    route_name  HTTP_VERB  path/to/access/this/route   controller#action
    

    When you look at:

    new_signup GET    /refinery/users/register(.:format) refinery/users#new
    signup     POST   /refinery/users/register(.:format) refinery/users#create
    

    ...this is showing you two routes, one named "new_signup" and the other "signup", both which are accessed via /refinery/users/register.html (where .html is the format and is optional because it is in parenthesis). If it's a GET request it will route to the new action in the refinery/users controller, and if it's a POST request then its routed to the create action.

    Given what @manfergo25 said, I think since you already have a user in your database, the new_signup action is now redirecting you to the login route to prevent other users from signing up to gain access to your admin.

    Source: http://guides.rubyonrails.org/routing.html