Hi Pat,

I know I tried your suggestion and it didn't work, but I just tried it now
and it all worked.

The original question was from the help document which stated:
has tags(:id), :as => :tag_ids

not that tags itself was an association from your first response, but that
:id is a reserved word. Seems that the help was correct for pre-rails 3, but
for rails 3 you would use
has :id, :as => :tag_ids

Thanks for your help, updating a big project to rails 3 is sort of daunting,

Scott


On Wed, Feb 2, 2011 at 9:16 PM, Pat Allan <[email protected]> wrote:

> Hi Scott
>
> Just to confirm - you want an attribute based on the primary key of the
> object with the index definition?
>
>  has :id, :as => :cdvd_id
>
> If it worked in previous versions, it's only because TS wasn't checking
> things out, and just treated the cdvds(:id) as :id.
>
> --
> Pat
>
> On 03/02/2011, at 4:12 PM, Scott Lenney wrote:
>
> > Hi Pat, No problem, here is the top part of the model:
> >
> > class Cdvd < ActiveRecord::Base
> > has_many :mydvds
> > has_many :listmovies
> > has_many :users, :through => :mydvds
> >
> > has_many :zjactors
> > has_many :zactors, :through => :zjactors
> >
> > has_attached_file    :dvdfront,
> >                 :styles => { :original => "640x640>", :medium =>
> "240x240>", :tiny => "90x90>" },
> >                 :default_style => :medium,
> >                 :path => ":attachment/:id/:style.:extension",
> >                 :storage => :s3,
> >                     :s3_credentials =>
> "#{RAILS_ROOT}/config/amazon_s3.yml",
> >                     :bucket => "lib-dvdfront"
> >
> > validates_attachment_content_type    :dvdfront,
> >                             :content_type => ['image/jpg', 'image/jpeg',
> 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png'],
> >                             :message => "Only image files are allowed -
> jpg, png, gif, jpeg"
> >
> > has_attached_file    :dvdback,
> >                 :styles => { :original => "640x640>", :medium =>
> "240x240>", :tiny => "90x90>" },
> >                 :default_style => :medium,
> >                 :path => ":attachment/:id/:style.:extension",
> >                 :storage => :s3,
> >                     :s3_credentials =>
> "#{RAILS_ROOT}/config/amazon_s3.yml",
> >                     :bucket => "lib-dvdback"
> > validates_attachment_content_type    :dvdback,
> >                             :content_type => ['image/jpg', 'image/jpeg',
> 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png'],
> >                             :message => "Only image files are allowed -
> jpg, png, gif, jpeg"
> >
> > attr_accessor  :imdbstr, :actors, :genre, :savepic
> >
> > define_index do
> >     set_property :delta => true
> >     indexes title, :sortable => true
> >     indexes alttitle, stitle
> >
> >     has cdvds(:id), :as => :cdvdid
> >     has [sgenre1, sgenre2, sgenre3], :as => :genres, :type => :multi
> >     has rating, :as => :mrating, :type => :integer
> >     has updated, :type => :boolean
> >     has "ORD(UPPER(title))", :as => :ord_int, :type => :integer
> >     has "IF(cdvds.quantity > 0, 1, 0)", :as => :owned, :type => :boolean
> >     has language, :type => :integer
> >     has "IF(LENGTH(title) < 8, 1, 0)", :as => :short, :type => :boolean
> >
> >     #If rating R or X or the genre is adult
> >     has "IF(rating = 10 OR rating = 14 or sgenre1 = 14 or sgenre2 = 14 or
> sgenre3 = 14, 1, 0)", :as => :adult, :type => :boolean
> >
> >     #If rating G or PG or the genre is children or family
> >     has "IF(rating = 0 OR rating = 8 or sgenre1 = 7 or sgenre2 = 7 or
> sgenre3 = 7 or sgenre1 = 16 or sgenre2 = 16 or sgenre3 = 16, 1, 0)", :as =>
> :child, :type => :boolean
> >
> >     set_property :enable_star => 1
> >     set_property :min_prefix_len => 2
> >
> >
> >     #set_property :delta => true
> > end
> >
> > I need to search on a group of id that are in another part of the
> application of the mydvds so I do need to also include the index of of the
> cdvd to be able to search on a reduces set. The above works fine pre rails
> 3, the has cdvds(:id), :as => :cdvdid indexes and starts TS fine, but when I
> try to update a cdvd record it gives the no method error.
> >
> > Thanks,
> > Scott
> >
> > On Wed, Feb 2, 2011 at 5:32 PM, Pat Allan <[email protected]>
> wrote:
> > Hi Scott
> >
> > Sorry, I'm not sure what's going on .. is cdvds an association? It will
> need to be, if you're going to use it in your define_index block. Can you
> share your define_index block and the associations in this model?
> >
> > Cheers
> >
> > --
> > Pat
> >
> > On 03/02/2011, at 5:30 AM, Scott Lenney wrote:
> >
> > > Hi Pat,
> > > Thanks for the reply.
> > > There isn't an association in this case. I am actually using dvds.
> > >
> > > define_index do
> > >    indexes title, :sortable => true
> > >    has cdvds(:id), :as => :cdvdid
> > > end
> > > In pre-rails 3 this works fine, but in rails 3 TS works fine, but when
> I update any record in cdvd (nothing to do with TS) I get the no method
> error for cdvds. Does TS automatically include the id for the records?
> Meaning I wouldn't need to include it in the indexing.
> > >
> > > Thanks,
> > > Scott
> > >
> > >
> > > On Tue, Feb 1, 2011 at 12:37 AM, Pat Allan <[email protected]>
> wrote:
> > > Hi Scott
> > >
> > > This is a known bug - TS/Rails 3 generation of joins doesn't take
> has-many :through's into account.
> > >
> > > Assuming the usual tag structure, try the following instead:
> > >  has taggings.tag(:id), :as => :tag_ids
> > >
> > > Essentially, you can't use has-many :through's as shortcuts - you need
> to go the long way around. I do need to fix this, but ARel is a tricky beast
> to master.
> > >
> > > Cheers
> > >
> > > --
> > > Pat
> > >
> > > On 01/02/2011, at 6:17 PM, Scott Lenney wrote:
> > >
> > > > Simple problem, after updating to rails 3 I get the following problem
> > > >
> > > > Looking at the example on attributes:
> > > > http://freelancing-god.github.com/ts/en/indexing.html
> > > >
> > > > I want to index the id as an attribute
> > > > has tags(:id), :as => :tag_ids
> > > >
> > > > That all works fine, but when I update a record I now get an
> undefined
> > > > method 'tags', if I remove the above line no problem. This started
> > > > after updating to rails 3.
> > > >
> > > > If anyone has any ideas or if already addressed please let me know
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups "Thinking Sphinx" group.
> > > > To post to this group, send email to
> [email protected].
> > > > To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> > > > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
> > > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Thinking Sphinx" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> > > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
> > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Thinking Sphinx" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> > > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" 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/thinking-sphinx?hl=en.

Reply via email to