Created
November 2, 2012 06:38
-
-
Save olivierlacan/3999097 to your computer and use it in GitHub Desktop.
Associations in Rails 4 return a CollectionProxy instead of an Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article < ActiveRecord::Base | |
has_and_belongs_to_many :tags | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticlesController < ApplicationController | |
respond_to :json, :html | |
def show | |
respond_with @article = Article.find(params[:id]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tag < ActiveRecord::Base | |
has_and_belongs_to_many :articles | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment