Can you try again? I think it's fixed now

On Viernes, 2 de Octubre de 2009 15:48:18 Gabriel Sobrinho escribió:
> I use the paperclip. Well, the class Attachment into models is from
> Paperclip.
>
> So, I specified the class name ::Attachment into associations. This
> works for Rails but is failing by AS:
>
>
>         uninitialized constant Attachment::Attachable
>
>        
> /opt/ruby1.8/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
>dependencies.rb:105:in `const_missing'
> /opt/ruby1.8/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ba
>se.rb:2199:in `compute_type'
> /opt/ruby1.8/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
>core_ext/kernel/reporting.rb:11:in `silence_warnings'
> /opt/ruby1.8/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ba
>se.rb:2195:in `compute_type'
> /opt/ruby1.8/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/re
>flection.rb:156:in `send'
> /opt/ruby1.8/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/re
>flection.rb:156:in `klass'
> /var/rails/tba/vendor/plugins/active_scaffold/lib/active_scaffold/data_stru
>ctures/column.rb:296:in `initialize_search_sql'
> /var/rails/tba/vendor/plugins/active_scaffold/lib/active_scaffold/data_stru
>ctures/column.rb:153:in `search_sql'
> /var/rails/tba/vendor/plugins/active_scaffold/lib/active_scaffold/data_stru
>ctures/column.rb:157:in `searchable?'
> /var/rails/tba/vendor/plugins/active_scaffold/lib/active_scaffold/config/se
>arch.rb:34:in `columns'
>
>
> Before the search patch this works fine. I don't find the problem... My
> model:
>
>
>         has_one :banner, :as => :attachable, :class_name =>
>         '::Attachment', :dependent => :destroy
>         has_one :image, :as => :attachable, :class_name =>
>         '::Attachment', :dependent => :destroy
>
>
> Em Qui, 2009-10-01 às 11:03 +0200, Sergio Cambra .:: entreCables
>
> S.L. ::. escreveu:
> > On Jueves, 1 de Octubre de 2009 07:41:43 Gabriel Sobrinho escribió:
> > > Thanks Sergio.
> > >
> > > But it's creating a scope class issue (my association have a
> > > :class_name => '::Attachment').
> > >
> > >
> > > You do it:
> > >
> > >         if association.nil?
> > >           self.search_sql = self.field.to_s
> > >         else
> > >           self.search_sql =
> > > "#{association.klass.table_name}.#{association.klass.primary_key}"
> > >         end
> > >
> > >
> > > But the self.field.to_s do the same thing. Well, it can be simplified
> > > to:
> > >
> > >           self.search_sql = self.field.to_s
> > >
> > >
> > > And using like that, avoid the scope problem.
> >
> > That only works for belongs_to associations, because you can search in
> > current table, but for other associations you have to search for a field
> > in association table.
> >
> > class Team
> >     has_many :players
> > end
> >
> > class Player
> >     belongs_to :team
> > end
> >
> > If I have a Team model which has many players, and I want to search for a
> > team with a player, config.columns[:players].field will return
> > 'teams.team_id' when it should be 'players.id'
> >
> > What error are you getting?
> >
> > > Em Qui, 2009-10-01 às 10:07 +0200, Sergio Cambra .:: entreCables
> > >
> > > S.L. ::. escreveu:
> > > > On Miércoles, 30 de Septiembre de 2009 18:31:34 G. Sobrinho escribió:
> > > > > I found it on lib/active_scaffold/data_structures/column.rb at line
> > > > > 292:
> > > > >
> > > > > *          # with associations we really don't know what to sort by
> > > > > without developer intervention. we could sort on the primary key
> > > > > ('id'), but that's hardly useful. previously ActiveScaffold would
> > > > > try and search using the same sql as from :sort, but we decided to
> > > > > just punt.
> > > > >           self.search_sql = nil*
> > > > >
> > > > >
> > > > > This make a little sense. User can search for a string or use a id.
> > > > > But I think that by default the search should use a select tag and
> > > > > AS set the search_sql to the primary key column.
> > > >
> > > > Really I think that comment is thinking in search action, instead of
> > > > field_search. I have put it by default and it's working for field
> > > > search, also search continues working like before.
> > > >
> > > > > I think that will be more used than searching by a string.
> > > > >
> > > > >
> > > > > If users want to search by string into associations, they will need
> > > > > to specify it. Actually the associations for field search doesn't
> > > > > do anything. I need to specify if I want this.
> > > > >
> > > > >
> > > > > What you think?
> > > > >
> > > > > 2009/9/30 G. Sobrinho <[email protected]>
> > > > >
> > > > > > Thanks Sergio, it's works. It should be default, not? Detect
> > > > > > associations and set this options for field search.
> > > > > >
> > > > > >
> > > > > > 2009/9/30 Sergio Cambra .:: entreCables S.L. ::.
> > > > > > <[email protected]>
> > > > > >
> > > > > >> On Miércoles, 30 de Septiembre de 2009 17:57:23 G. Sobrinho 
escribió:
> > > > > >> > But I want to use a select for association into fieldsearch.
> > > > > >> >
> > > > > >> > I can do it using a helper method and creating a select but I
> > > > > >> > will need
> > > > > >>
> > > > > >> to
> > > > > >>
> > > > > >> > do it for all association which I want to use the :select.
> > > > > >>
> > > > > >> If you want to use a select in search, set search_ui to :select,
> > > > > >> and search_sql to 'table.id'.
> > > > > >> config.columns[:association].search_sql = 'association_table.id'
> > > > > >> config.columns[:association].search_ui = :select
> > > > > >>
> > > > > >> > 2009/9/30 Sergio Cambra .:: entreCables S.L. ::. <
> > > > > >>
> > > > > >> [email protected]>
> > > > > >>
> > > > > >> > > On Martes, 29 de Septiembre de 2009 17:46:37 G. Sobrinho
> >
> > escribió:
> > > > > >> > > > But for all associations I will need to write a helper
> > > > > >> > > > method to do
> > > > > >>
> > > > > >> it,
> > > > > >>
> > > > > >> > > > that's not dry.
> > > > > >> > > >
> > > > > >> > > > I think a good choice is the FieldSearch make a select tag
> > > > > >> > > > for all associations sending the id for search like
> > > > > >> > > > search[seller_id]=1.
> > > > > >> > > >
> > > > > >> > > >
> > > > > >> > > > I remember when I started to use the AS I seed something
> > > > > >> > > > like this
> > > > > >>
> > > > > >> but
> > > > > >>
> > > > > >> > > > I don't remember if this was a plugin or what.
> > > > > >> > >
> > > > > >> > > You only need to set form_ui (or search_ui if you want crud
> > > > > >> > > subform in create/update forms) to :select.
> > > > > >> > >
> > > > > >> > > > 2009/9/25 Sergio Cambra .:: entreCables S.L. ::.
> > > > > >> > > > <[email protected]
> > > > > >> > > >
> > > > > >> > > > > On Viernes, 25 de Septiembre de 2009 14:17:31 Sergio
> > > > > >> > > > > Cambra .:: entreCables
> > > > > >> > > > >
> > > > > >> > > > > S.L. ::. escribió:
> > > > > >> > > > > > On Jueves, 24 de Septiembre de 2009 22:10:52 G.
> > > > > >> > > > > > Sobrinho
> > > > > >>
> > > > > >> escribió:
> > > > > >> > > > > > > Hello,
> > > > > >> > > > > > >
> > > > > >> > > > > > > I'm trying to use search to filter associations. I
> > > > > >> > > > > > > have Seller
> > > > > >> > >
> > > > > >> > > which
> > > > > >> > >
> > > > > >> > > > > > > has_many Announces.
> > > > > >> > > > > > >
> > > > > >> > > > > > > If I access the announces AS page and try to search
> > > > > >>
> > > > > >> 'webmotors'
> > > > > >>
> > > > > >> > > > > > > (it is
> > > > > >> > > > >
> > > > > >> > > > > a
> > > > > >> > > > >
> > > > > >> > > > > > > seller in my database) this doesn't find anything.
> > > > > >> > > > > > > Well, I
> > > > > >>
> > > > > >> tried
> > > > > >>
> > > > > >> > > > > > > to
> > > > > >> > > > >
> > > > > >> > > > > swap
> > > > > >> > > > >
> > > > > >> > > > > > > to FieldSearch but the associations aren't showed on
> > > > > >> > > > > > > search.
> > > > > >> > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > > > AS is missing this feature, I'm doing something
> > > > > >> > > > > > > wrong or what
> > > > > >>
> > > > > >> is
> > > > > >>
> > > > > >> > > > > > > happening?
> > > > > >> > > > > >
> > > > > >> > > > > > Search is enabled by default only for real columns.
> > > > > >> > > > > > You have to
> > > > > >>
> > > > > >> set
> > > > > >>
> > > > > >> > > > > > search_sql for associations in order to ActiveScaffold
> > > > > >> > > > > > knows
> > > > > >>
> > > > > >> which
> > > > > >>
> > > > > >> > > > > > field
> > > > > >> > > > >
> > > > > >> > > > > of
> > > > > >> > > > >
> > > > > >> > > > > > the association table use to search. You have examples
> > > > > >> > > > > > in API: column
> > > > > >>
> > > > > >> http://wiki.github.com/activescaffold/active_scaffold/api-column
> > > > > >>
> > > > > >> > > > > Also, you have to add the association to search columns
> > > > > >> > > > > http://wiki.github.com/activescaffold/active_scaffold/ap
> > > > > >> > > > >i-se arch With FieldSearch that's not needed.
> > > > > >> > > > >
> > > > > >> > > > > --
> > > > > >> > > > > Sergio Cambra .:: entreCables S.L. ::.
> > > > > >> > > > > Mariana Pineda 23, 50.018 Zaragoza
> > > > > >> > > > > T) 902 021 404 F) 976 52 98 07 E) [email protected]
> > > > > >> > >
> > > > > >> > > --
> > > > > >> > > Sergio Cambra .:: entreCables S.L. ::.
> > > > > >> > > Mariana Pineda 23, 50.018 Zaragoza
> > > > > >> > > T) 902 021 404 F) 976 52 98 07 E) [email protected]
> > > > > >>
> > > > > >> --
> > > > > >> Sergio Cambra .:: entreCables S.L. ::.
> > > > > >> Mariana Pineda 23, 50.018 Zaragoza
> > > > > >> T) 902 021 404 F) 976 52 98 07 E) [email protected]
> > > > > >
> > > > > > --
> > > > > > Cordialmente,
> > > > > >
> > > > > > Gabriel Sobrinho
> > > > > > Diretor de desenvolvimento
> > > > > >
> > > > > > Hite - Comunicação Digital e Mídia Interativa
> > > > > > http://www.hite.com.br/
> > > > > >
> > > > > > +55 31 8775 8378

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to