Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with Simple Action Controller

I am new to Ruby on Rails and trying to set up a super simple database.

I am getting a

ActionController::UnknownFormat in ProfilesController#index

ProfilesController#index is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not… nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.

error and am unsure what is going on. I tried researching but I can not tell what I am doing wrong.

#profiles_controller.rb:

class ProfilesController < ApplicationController
  def index
    @profiles = Eprofiles.all
  end
end


#routes.rb:

Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  get 'welcome', to: 'pages#home'
  get 'profiles', to: 'profiles#index'
end

#eprofiles.rb

class Eprofiles < ApplicationRecord
end
like image 429
Dr Swerve Avatar asked Jan 01 '26 19:01

Dr Swerve


1 Answers

The error is self explanatory

ProfilesController#index is missing a template for this request format and variant. request.formats: ["text/html"]

This means you don't have file app/views/profiles/index.html.erb.

like image 188
dnsh Avatar answered Jan 03 '26 16:01

dnsh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!