On 5/12/10 6:08 PM, Rick DeNatale wrote:
On Wed, May 12, 2010 at 4:47 PM, Jesse wrote:
Sure thing:
class Portal< ActiveRecord::Base
has_many :users, :through => :programs
end
class Program< ActiveRecord::Base
has_many :users, :through => :program_memberships
end
class User< Acti
On Wed, May 12, 2010 at 4:47 PM, Jesse wrote:
> Sure thing:
>
> class Portal < ActiveRecord::Base
> has_many :users, :through => :programs
> end
>
> class Program < ActiveRecord::Base
> has_many :users, :through => :program_memberships
> end
>
> class User < ActiveRecord::Base
> has_many :progr
Sure thing:
class Portal < ActiveRecord::Base
has_many :programs
has_many :users, :through => :programs
end
class Program < ActiveRecord::Base
belongs_to :portal
has_many :program_memberships, :dependent => :destroy
has_many :users, :through => :program_memberships
end
class ProgramMe
On 12 May 2010 21:05, Jesse wrote:
> Hi All, I am trying to do something similar and am running into an issue on
> it
>
> I have a setup where
> Portal has many Programs
> program has many users through program_memberships
> user has many portals through program_memberships
Can you provide the fu
Hi All, I am trying to do something similar and am running into an issue
on it
I have a setup where
Portal has many Programs
program has many users through program_memberships
user has many portals through program_memberships
I am trying to get it so that portal has many users through programs
David Zhu wrote:
>> This seems like a good use case for has_many :through.
>
>
> It sounds like an excellent case for has_many :through!
>
> haha i just did it using that method, it works great. thanks guys
You're welcome!
>
> (Oh, am i posting right?)
Yup.
Best,
--
Marnen Laibow-Koser
http
> This seems like a good use case for has_many :through.
It sounds like an excellent case for has_many :through!
haha i just did it using that method, it works great. thanks guys
(Oh, am i posting right?)
--
You received this message because you are subscribed to the Google Groups "Ruby
on
David Zhu wrote:
> OK,
>
>
> But right now, i have--
>
> Schools has many subjects, subjects has many teachers
>
> So instead of-- @totalcount = @school.subjects.count (that just
> cuonts how many subjects are in the school)
>
> how can i count the teachers in that school? maybe something sim
Hi well there is no School.subjects.teachers in your case.
You should do something like this :
count = 0
@school.subjects.each {|s| count += s.teachers.count}
It is possible that you could use inject above to shorten it a bit, but not
sure about that in this case.
On Tue, May 11, 2010 at 07:38,
OK,
But right now, i have--
Schools has many subjects, subjects has many teachers
So instead of-- @totalcount = @school.subjects.count (that just
cuonts how many subjects are in the school)
how can i count the teachers in that school? maybe something similar
to @totalcount = @school.subjects.
10 matches
Mail list logo