trailblazer / roar-rails

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

Undefined method 'responder=' #105

Closed chadwtaylor closed 9 years ago

chadwtaylor commented 9 years ago

Followed your instructions to the T and tried all possible rendering options presented in your doc, I keep on getting this error:

undefined method 'responder=' for PeopleController:Class

Any ideas?

Here's my code:

class PeopleController < ApplicationController

  include Roar::Rails::ControllerAdditions
  include Roar::Rails::ControllerAdditions::Render

  # GET /people
  def index
    people = Person.find([8,18])
    render json: people
  end

end

PersonRepresenter.rb

class PersonRepresenter < Roar::Decorator
  include Roar::JSON

  property :id
  property :first_name
  property :last_name
  property :full_name
  property :avatar_url

end
apotonick commented 9 years ago

Do you have the responders gem bundled?

chadwtaylor commented 9 years ago

Thanks for the quick response! I'm going to add the gem from https://github.com/plataformatec/responders. Will keep you posted (trying to upgrade from Rails 4.1 to 4.2 since the latest responder works with 4.2+).

Be right back...

chadwtaylor commented 9 years ago

I can confirm that including gem 'responders' in my Gemfile did the trick. Might want to consider adding that gem as a dependency or include it in the README doc to make sure we have that installed.

I really appreciate your quick response to my situation. I came across your roar project while looking for JSON-API implementation.

apotonick commented 9 years ago

My pleasure! :wine_glass:

Are you sure you're on the latest gem? https://github.com/apotonick/roar-rails/blob/master/roar-rails.gemspec#L26

chadwtaylor commented 9 years ago

Yea, I'm using v1.0.1 and it's weird that the responders didn't get included in! I was doing a lot of things so it probably got lost in translation. :)