Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use JBuilder templates when overriding rendering methods #801

Closed
Quintasan opened this issue Jan 3, 2017 · 1 comment
Closed

Can't use JBuilder templates when overriding rendering methods #801

Quintasan opened this issue Jan 3, 2017 · 1 comment

Comments

@Quintasan
Copy link

config/routes.rb

Rails.application.routes.draw do
  namespace :api, defaults: { format: :json } do
    namespace :v1 do
      mount_devise_token_auth_for 'User', at: 'user', controllers: {
        token_validations: "api/v1/user/token_validations"
      }
      end
    end
end

app/controllers/api/v1/user/token_validations_controller.rb

module Api::V1::User
  class TokenValidationsController < DeviseTokenAuth::TokenValidationsController
    def render_validate_token_success
      render "api/v1/user/success"
    end
  end
end

app/views/api/v1/user/success.json.jbuilder

json.data do
  json.extract! @resource, :id, :first_name, :last_name, :gender
  json.test "works"
end

doing a GET request on api/v1/user/validate_token yields

Started GET "/api/v1/user/validate_token" for 127.0.0.1 at 2017-01-03 17:50:52 +0100
Processing by Api::V1::User::TokenValidationsController#validate_token as HTML
  Parameters: {"token_validation"=>{}}
  User Load (0.7ms)  SELECT  "users".* FROM "users" WHERE "users"."uid" = $1 LIMIT $2  [["uid", "[email protected]"], ["LIMIT", 1]]
Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.7ms)



ActionView::MissingTemplate - Missing template api/v1/user/success with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :haml, :jbuilder]}. Searched in:
  * "/home/quintasan/Sauce/applover/harex/app/views"
  * "/home/quintasan/.rvm/gems/ruby-2.3.1@harex/gems/apipie-rails-0.3.7/app/views"
  * "/home/quintasan/.rvm/gems/ruby-2.3.1@harex/gems/devise_token_auth-0.1.39/app/views"
  * "/home/quintasan/.rvm/gems/ruby-2.3.1@harex/gems/devise-4.2.0/app/views"

What am I doing wrong.

@zachfeldman
Copy link
Contributor

Hi there @Quintasan ,

In an effort to cleanup this project and prioritize a bit, we're marking issues that haven't had any activity in a while with a "close-in-7-days" label. If we don't hear from you in about a week, we'll be closing this issue. Obviously feel free to re-open it at any time if it's the right time or this was done in error!

If you are still having the issue (especially if it's a bug report) please refer to our new Issue Template to provide some more details to help us solve it.

Hope all is well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants