Skip to content

Commit

Permalink
Combined patches and linked to a PR in awesome_nested_set where passi…
Browse files Browse the repository at this point in the history
…ng a relation *will* work.
  • Loading branch information
parndt committed May 12, 2012
1 parent 21d0adc commit e4c0aae
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pages/app/helpers/refinery/admin/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ module Refinery
module Admin
module PagesHelper
def parent_id_nested_set_options(current_page)
all_pages = []
pages = []
options = nested_set_options(::Refinery::Page, current_page) do |page|
all_pages << page
pages << page
page
end
# page.title needs the :translations association, doing something like
# nested_set_options(::Refinery::Page.includes(:translations), page) doesn't work
ActiveRecord::Associations::Preloader.new(all_pages, :translations).run
options.map! {|page, id| ["#{'-' * page.level} #{page.title}", id]}
options
# nested_set_options(::Refinery::Page.includes(:translations), page) doesn't work, yet.
# See https://github.com/collectiveidea/awesome_nested_set/pull/123
ActiveRecord::Associations::Preloader.new(pages, :translations).run
options.map {|page, id| ["#{'-' * page.level} #{page.title}", id]}
end
end
end
Expand Down

0 comments on commit e4c0aae

Please sign in to comment.