Of course !

Look at the end:

"
class Shopcategory0 < ActiveRecord::Base
  set_table_name "shopcategories_0"

  has_many   :shopcategory1s, :foreign_key => :parentcategory_id
end

class Shopcategory1 < ActiveRecord::Base
  set_table_name "shopcategories_1"

  belongs_to :shopcategory0, :foreign_key => :shopcategory_id
end

class Shopcategory0sController < ApplicationController
  def show
    @shopcategory = Shopcategory0.all (:joins
=>  :shopcategory1s)
  end
end

---------------------
That's the SQL result:
---------------------

Shopcategory0 Load (0.1ms)   SELECT `shopcategories_0`.* FROM
`shopcategories_0` INNER JOIN `shopcategories_1` ON
shopcategories_1.parentcategory_id = shopcategories_0.id

---------------------
And this is what I search (notice the end):
---------------------

Shopcategory0 Load (0.1ms)   SELECT `shopcategories_0`.* FROM
`shopcategories_0` INNER JOIN `shopcategories_1` ON
shopcategories_1.parentcategory_id = shopcategories_0.shopcategory_id
"

On Jul 28, 8:05 pm, Eric <[email protected]> wrote:
> On Jul 28, 10:34 am, cocozz <[email protected]> wrote:
>
>
>
> > class Shopcategory0 < ActiveRecord::Base
> >   set_table_name "shopcategories_0"
>
> >   has_many   :shopcategory1s, :foreign_key => :parentcategory_id
> > end
>
> > class Shopcategory1 < ActiveRecord::Base
> >   set_table_name "shopcategories_1"
>
> >   belongs_to :shopcategory0, :foreign_key => :shopcategory_id
> > end
>
> > class Shopcategory0sController < ApplicationController
> >   def show
> >     @shopcategory = Shopcategory0.all (:joins
> > =>  :shopcategory1s)
> >   end
> > end
>
> > ---------------------
> > That's the SQL result:
> > ---------------------
>
> > Shopcategory0 Load (0.1ms)   SELECT `shopcategories_0`.* FROM
> > `shopcategories_0` INNER JOIN `shopcategories_1` ON
> > shopcategories_1.parentcategory_id = shopcategories_0.id
>
> > ---------------------
> > And this is what I search (notice the end):
> > ---------------------
>
> > Shopcategory0 Load (0.1ms)   SELECT `shopcategories_0`.* FROM
> > `shopcategories_0` INNER JOIN `shopcategories_1` ON
> > shopcategories_1.parentcategory_id = shopcategories_0.shopcategory_id
>
> > I suppose there is a way to do that...I'll appreciate your help !!!
>
> Is there a question in there?
>
> -e
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to