Skip to content

Instantly share code, notes, and snippets.

@olivierlacan
Created November 2, 2012 06:38
Show Gist options
  • Save olivierlacan/3999097 to your computer and use it in GitHub Desktop.
Save olivierlacan/3999097 to your computer and use it in GitHub Desktop.
Associations in Rails 4 return a CollectionProxy instead of an Array
class Article < ActiveRecord::Base
has_and_belongs_to_many :tags
end
class ArticlesController < ApplicationController
respond_to :json, :html
def show
respond_with @article = Article.find(params[:id])
end
end
class Tag < ActiveRecord::Base
has_and_belongs_to_many :articles
end
class TagsController < ApplicationController
respond_to :json, :html
def index
@tags = Tag.all
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment