Here are my routes:
Stynyl::Application.routes.draw do
resources :things
devise_for :users
get '/about', to: 'pages#about'
root 'things#index'
get 'users/:username' => "users#show"
end
Here is Users controller:
class UsersController < ApplicationController
def show
@user = User.find_by_name(params[:username])
end
end
Here is my users/show.html.erb
<p>
<strong><%= @user.username %></strong>
</p>
I know the view is basic, but I just want to see if it will print out the name of the user.
I created a user with the username 'delacram'. When I type localhost:3000/users/delacram, I get the error presented in the title.
What's the problem?
My User model
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :things
validates :name, presence: true
validates :username, presence: true
validates :email, presence: true
end