I am trying to construct a users model manually (without using \'resources :users\' in the routes.rb file). My routes.rb file looks like this:
match \'/users/:id
match '/users/:id', :to => 'users#show'
should be
match '/users/:id', :to => 'users#show', :as => :user
The :as
parameter tells the router what to name the route as (You can then add _path
or _url
to whatever the :as
parameter is).
Also, any time you link directly to an ActiveRecord model (e.g. link_to user.email, user
), it will try to turn user
into user_path
.
For everyone who using rails 4 in your routes.rb post '/users', :to => 'users#create', :as => :user
and you controller render json: @user, status: :created, location: @user_path