Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
I got the solution and I would like to thank my PM(Mr.Rahul) for this solution..
Here what we have done..
Instead of assigning scope by using with acts_as_list ,
like:
model file
class RelatedItem < ActiveRecord::Base acts_as_list belongs_to :relater, :polymorphic=>true
def scope_condition "relater_id = #{relater_id} and relater_type = '#{relater_type}'" end
end
I hope it would be helpful for other Rails people also.!!!!!!! :)
-Ganesh K
In that till I've tried following way to assign scope for relater:
1 - acts_as_list :scope => :relater
2 - acts_as_list :scope => [:relater_id, :relater_type]
3 - acts_as_list :scope => 'relater_id=#{relater_id} and relater_type = \'#{relater_type}\''
But showing same result position 1,2,3 for RelatedFeed and 1,2,3 for RelatedLink.. not generating position number with the scope on Relater(i.e 1,2,3,4,5,6....etc)..
Hello Rails experts,
Need your help in following issue with the acts_as_list and single table inheritence
Code details : http://pastie.org/1214846
In the above case while creating new record for RelatedLink or RelatedFeed it generating position number with scope of RelatedLink or RelatedFeed.. like
@clip = Clip.find(10)
when creating records in RelatedLink (i,e @related_item = RelatedLink.new(:relater_id=>@clip.id, :relater_type=>'#{@clip.class.name}') }
output showing like rec 1 -> position=1 ,relater_id=10, relater_type="Clip", type="RelatedLink" rec 2 -> position=2 ,relater_id=10, relater_type="Clip", type="RelatedLink" rec 3 -> position=3 ,relater_id=10, relater_type="Clip", type="RelatedLink"
AND when creating records in RelatedFeed (i,e @related_item = RelatedFeed.new(:relater_id=>@clip.id, :relater_type=>'#{@clip.class.name}') )
with RelatedFeed output: records 1 -> position=1 ,relater_id=10, relater_type="Clip", type="RelatedFeed" records 2 -> position=2 ,relater_id=10, relater_type="Clip", type="RelatedFeed" records 3 -> position=3 ,relater_id=10, relater_type="Clip", type="RelatedFeed"
#
But here I need create those entries with the scope on Relater only and not on RelaterFeed or RelatedLink I mean do not want to repeat these Position number 1,2,3 then 1,2,3 for same clip(i.e Relater). Currently it generating those positioning individually for RelatedFeed and for RelatedLink of same Relater(i.e clip)
Here I need something like when I'll assign Relater to RelatedLink or RelatedFeed it auto create positioning on the basis of Relater only like
RelatedLink : rec 1 -> position =1, relater_id=10, relater_type="Clip", type="RelatedFeed" rec 2 -> position =2, relater_id=10, relater_type="Clip", type="RelatedFeed" rec 3 -> position =3, relater_id=10, relater_type="Clip", type="RelatedFeed"
Then for RelatedFeed rec 1 -> position =4, relater_id=10, relater_type="Clip", type="RelatedFeed" rec 2 -> position =5, relater_id=10, relater_type="Clip", type="RelatedFeed" rec 3 -> position =6, relater_id=10, relater_type="Clip", type="RelatedFeed"
position will be like 1,2,3,5,6.. etc
Any Idea..?? How is to be done..?
Thank you :)
-Ganesh K
