Topic: Displaying children without a parent model

Funny as it is. These children never had a parent Model, and now I need to find them, to create a parent for them

In my case the children have a common class like
1004
1004
1004
1005
1005
1006
1007
And so on. Finding or displaying just the one class value in a group like
1004
1005
1006
1007 ...

I tried things like :first and :limit but both return one single value or Nothing
uniq in model did no good either

A very basic method

                    @infos = Info.find :all
                    @infosbat = Info.find :all, :include => :medialogs, :group => 'info_id'

View
    <div id="Layer1">   
    <% for info in @infos %> 
    <p> <%= info.id %>
    </p> 
    <% end %>
    </div>         
    <div id="Layer2">   
       
     <% for info in @infosbat %> 

    <% for medialog in info.medialogs %>
    <p>   
     <%= medialog.info_id %>   
    </p>
             <% end %>
                 <% end %>
       
</div>

Re: Displaying children without a parent model

select distinct info_id from medialogs; worked from Mysql terminal
But I cant find a Rails distinct equivalent.

tried @infosbat = Info.find_by_sql("select start, end from medialogs")

and

@infosbat = Info.find(:all, :include => :medialogs).uniq

@infosbat = Info.find(:all, :include => :medialogs, :conditions =>["select info_id from medialogs"]) 
Those last two seem to go into endless loops or just provide # signs

I thought it might go in model as well, Would that go under Self << ?

Re: Displaying children without a parent model

Please anyone ?
I figured the search idea out
sql subtract one result from another

So say I get a list of Parent numbers, and weed out all of those matching from the children numbers, That should do it, like a boolean in shapes

Last edited by tripdragon (2006-11-28 17:28:34)