Skip to content

Instantly share code, notes, and snippets.

@takuyan
Created November 18, 2011 02:17
Show Gist options
  • Save takuyan/1375371 to your computer and use it in GitHub Desktop.
Save takuyan/1375371 to your computer and use it in GitHub Desktop.
kaminari Array issue
# app/models/medium.rb
has_many :stories
# app/models/stories.rb
belongs_to :medium
scope :newer, order("created_at desc")
scope :entries, where("entry = ?", true)
# app/controllers/stories_controller.rb
def index
@medium = Medium.find params[:id]
@stories = @medium.stories.newer.entries.page params[:page]
# => undefined method `page' for #<Array…>
@stories2 = @medium.stories.newer.entries # => Dir::entries ???
@entries2.class # => Array
end
@takuyan
Copy link
Author

takuyan commented Nov 18, 2011

MacBook-Pro@takuyan:kami $ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.0.0]
MacBook-Pro@takuyan:kami $ rails -v
Rails 3.0.10

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