Anton,

You were close. 'a' will be an array of PagePart instances.  Try:

a.map(&:page).uniq

There's a way to do this query in the database but my brain is way 
outside SQL lately, so maybe someone on the mailing list can help.

Sean

On 2/8/10 9:13 PM, Anton Aylward wrote:
> I'm not a programmer, though I have these flights of fancy!
>
> I'm trying to find what parts of a radiant site haven't been written.
> My idea was to look for the page-parts that are blank and what pages
> they belong to.
>
> I figured out
>
> a = PagePart.find( :all,
>                     :conditions =>   { :content =>  "", :name =>  "body" } )
>
> that gives me the list of empty part.
>
> Now I thought I could have done a join ..
>
>    ..... ).Page.name
>
> or at very least
>
>    ..... ).page_id
>
> to get the array and then
>
>   a.each { |p| Page.find(:all, :conditions =>  { :id =>  p.page_id } ) }
>
>
> but it seems not.
>
> I've tried
>
> a = PagePart.find( :all,
>                     :conditions =>   { :content =>  "",
>                                       :name =>  "body" } ) do |p|
>              Page.find(p.page_id).title
> end
>
> Which struck me as logical, but it returned the same array
>
>
> I even tried the other way round but wasn't sure how to "go forward"
> So I ended up with
>
> b = []
> a = PagePart.find( :all, :conditions =>   {
>                              :content =>  "",
>                              :name =>  "body" } ).each do |p|
>        b<<  Page.find( p.page_id).title
> end
>
> Which gives me "b", but seems awkward
>
> An how do I get that lsited?
>
>
>
>
>
>
>
>    

_______________________________________________
Radiant mailing list
Post: Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
List Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Radiant: http://radiantcms.org
Extensions: http://ext.radiantcms.org

Reply via email to