Add new action to route

routes, ruby, ruby-on-rails

Solution

in your config/routes.rb file do this

resources :users do
  collection do
    get 'another_new'
    post 'another_create'
  end
end

Also have a look HERE for clear understanding of concepts.

Hope this helps you dude :)

Problem

I got these actions in users controller ``` class UsersController < ApplicationController def index #default action ... end def new #default action ... end def another_new ... end def create ... end def another_create ... end end ``` I want to be able to `/users/another_new` and call from some sort of link `:method => :another_create` to make `/users/another_new` I got the following config/routes.rb ``` get '/users/another_new' :to => 'users#another_new' resources :users ``` my question is if this is the correct way to add the `get` and how I add the another_create method.

Original source