trailblazer / roar-rails

Use Roar's representers in Rails.
http://roar.apotomo.de
MIT License
235 stars 62 forks source link

errors when "Rendering from render" #85

Open ak47 opened 10 years ago

ak47 commented 10 years ago

the issue appears with the includes in the controller


class Api::V2::AppointmentsController < ApplicationController
  include ::Roar::Rails::ControllerAdditions
  include ::Roar::Rails::ControllerAdditions::Render

  # GET /api/v2/appointments/:id
  def show
    @appointment = Appointment.first
    if @appointment
      # render json: AppointmentRepresenter.new(@appointment).to_json, status: :ok
      render @appointment, status: :ok
in my rspecs, I consistently get:

Failure/Error: get "/api/v2/appointments/123"
     ActionController::RoutingError:
       undefined method `responder=' for Api::V2::AppointmentsController:Class
     # ./app/controllers/api/v2/appointments_controller.rb:2:in`include'
AND

 Failure/Error: get "/api/v2/appointments/#{@appointment.id}"
     AbstractController::ActionNotFound:
       The action 'show' could not be found for Api::V2::AppointmentsController
When remove those includes and use the alternative:

render json: AppointmentRepresenter.new(@appointment).to_json, status: :ok'
this works out as expected Am I doing something wrong? Ruby 2.1.2 Rails 4.1.5 Rspec 3.1.0 thanks
apotonick commented 10 years ago

I remember this problem from a while ago (undefined method responder=') but thought we had it fixed. Can you find out where in Rails 4.1 the #responder= method is defined?

apotonick commented 10 years ago

Does that help? https://github.com/apotonick/roar-rails/issues/87