Rails 5 No template found error

user6332345 picture user6332345 · Jan 28, 2017 · Viewed 10k times · Source

Error in terminal while running rails s:

Started POST "/users/confirm" for ::1 at 2017-01-28 15:12:30 -0600
Processing by UsersController#confirm as HTML
No template found for UsersController#confirm, rendering head :no_content

It seems that this is actually an Unknown Format error in rails that is passing as a 204 No Content error. I am really new to rails, and doing this for a course.

I have a controller with one def confirm action. It isn't repeated anywhere in my file. Unlike most of the posts previous there isn't a respond_to method located within this action.

Where does the error actually stem from? I don't know if I should be looking at config or re-working the controller

This is my gemfile:

source 'https://rubygems.org'

gem 'rails', github: 'rails/rails'
gem 'rails', '5.0.1'


group :production do
gem 'pg'
gem 'rails_12factor'
end


group :development do
gem 'sqlite3'
gem 'pry-rails'
end

group :development, :test do 
gem 'rspec-rails', '~> 3.0'
gem 'shoulda'
gem 'rails-controller-testing'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'listen'
gem 'bootstrap-sass'
gem 'bcrypt'

edit.html.erb

 <h1>Sign Up Confirmation</h1>`
 <div class="row">
 <div class='col-md-2'>
 <h3>Are you sure these values are correct?</h3>
 <h5>Name: <% @user.name %></h5>
 <h5>Email: <% @user.email %></h5>
 </div>
 </div>

 <div class="row">
 <div class="col-md-2",  style="width:  auto;">
 <%= button_to "Yes", {controller: "users", 
 action: "create", params:    params}, class: 'btn btn-success' %>        
 </div>

  <div class="col-md-2",  style="width:  auto;">
        <%= link_to "No", new_user_path, class: 'btn btn-default' %>
  </div>
  </div>

Answer

Hamza1510 picture Hamza1510 · Jan 29, 2017

It looks like you're missing a confirm.html.erb file in your views/users directory. Rails looks for a view file to render when a action is called, and it's looking for a file with the same name as the action.

If you haven't already, create that file, save and refresh the page. The error should be gone. The page will be blank unless you populate the file with some HTML, but from here you should be good to go.