I''ve been trying to use the ez_where plugin to create a dynamic finder. The structure looks somehing like this.. === controller == def list attribute_filter = params[:filter] @filter = Caboose::EZ::Condition.new :table do attribute <=> attribute_filter if attribute_filter end # ... do the find with the @filter # end === view ==.... <%= link_to ''Add filter'', {:filter=>value}.merge(params) %> this works fine, but there are some weird things here. Notice that the structure of the ''list'' function is odd. I first tried this.. def list @filter = Caboose::EZ::Condition.new :table do attribute <=> params[:filter] if params[:filter] end end But this doesn''t work. It doesn''t throw an error, but it adds a clause to the @filter like this... - !ruby/object:Caboose::EZ::Clause name: params table_prefix: table. test: :[] value: :filter and otherwise doesn''t behave as you might expect. Sooo... if want to use the ez_where plugin with conditions, be careful. There''s probably a way around this, hopefully Ezra has some nifty trick for making this work as expected. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.
On Aug 2, 2006, at 10:00 AM, Kevin Olbrich wrote:> I''ve been trying to use the ez_where plugin to create a dynamic > finder. > The structure looks somehing like this.. > > === controller ==> > def list > attribute_filter = params[:filter] > @filter = Caboose::EZ::Condition.new :table do > attribute <=> attribute_filter if attribute_filter > end > # > ... do the find with the @filter > # > end > > === view ==> .... > <%= link_to ''Add filter'', {:filter=>value}.merge(params) %> > > this works fine, but there are some weird things here. > Notice that the structure of the ''list'' function is odd. I first > tried > this.. > > def list > @filter = Caboose::EZ::Condition.new :table do > attribute <=> params[:filter] if params[:filter] > end > end > > But this doesn''t work. It doesn''t throw an error, but it adds a > clause > to the @filter like this... > > - !ruby/object:Caboose::EZ::Clause > name: params > table_prefix: table. > test: :[] > value: :filter > > and otherwise doesn''t behave as you might expect. > > Sooo... if want to use the ez_where plugin with conditions, be > careful. > > There''s probably a way around this, hopefully Ezra has some nifty > trick > for making this work as expected. > > _Kevin > www.sciwerks.comKevin- This was a problem in an older version of the plugin. It is fixed in the new version. I can tell you are using the old one because what used to be this: Caboose::EZ::Condition.new ids now EZ::Where::Condition.new. Anyways grab the latest version where this is fixed. Also note that you do not have to do params[:filter] if params[:filter]. You can drop the if params[:filter] and the plugin will exclude that condition if params[:filter] is nil. That way you don''t have to do all those ugly if''s or unless''s. Grab the latest version form here: $ script/plugin install svn://rubyforge.org//var/svn/ez-where Cheers- -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/77381f1b/attachment.html
On Wednesday, August 02, 2006, at 10:06 AM, Ezra Zygmuntowicz wrote:> >On Aug 2, 2006, at 10:00 AM, Kevin Olbrich wrote: > >> I''ve been trying to use the ez_where plugin to create a dynamic > finder. >> The structure looks somehing like this.. >> >> === controller ==>> >> def list >> attribute_filter = params[:filter] >> @filter = Caboose::EZ::Condition.new :table do >> attribute <=> attribute_filter if attribute_filter >> end >> # >> ... do the find with the @filter >> # >> end >> >> === view ==>> .... >> <%= link_to ''Add filter'', {:filter=>value}.merge(params) %> >> >> this works fine, but there are some weird things here. >> Notice that the structure of the ''list'' function is odd. I first > tried >> this.. >> >> def list >> @filter = Caboose::EZ::Condition.new :table do >> attribute <=> params[:filter] if params[:filter] >> end >> end >> >> But this doesn''t work. It doesn''t throw an error, but it adds a > clause >> to the @filter like this... >> >> - !ruby/object:Caboose::EZ::Clause >> name: params >> table_prefix: table. >> test: :[] >> value: :filter >> >> and otherwise doesn''t behave as you might expect. >> >> Sooo... if want to use the ez_where plugin with conditions, be > careful. >> >> There''s probably a way around this, hopefully Ezra has some nifty > trick >> for making this work as expected. >> >> _Kevin >> www.sciwerks.com > > > >Kevin- > > This was a problem in an older version of the plugin. It is fixed >in the new version. I can tell you are using the old one because >what used to be this: Caboose::EZ::Condition.new ids now >EZ::Where::Condition.new. Anyways grab the latest version where this >is fixed. Also note that you do not have to do params[:filter] if >params[:filter]. You can drop the if params[:filter] and the plugin >will exclude that condition if params[:filter] is nil. That way you >don''t have to do all those ugly if''s or unless''s. Grab the latest >version form here: > >$ script/plugin install svn://rubyforge.org//var/svn/ez-where > > >Cheers- >-Ezra > > > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >Great Ezra! One other question... if you call .to_sql on an empty Condition, does it return something like ''1'' now. The older version doesn''t. FWIW, I used rapt to download it. I''m not sure where it got it from. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.
On Wednesday, August 02, 2006, at 5:14 PM, Kevin Olbrich wrote:> >On Wednesday, August 02, 2006, at 10:06 AM, Ezra Zygmuntowicz wrote: >> >>On Aug 2, 2006, at 10:00 AM, Kevin Olbrich wrote: >> >>> I''ve been trying to use the ez_where plugin to create a dynamic > >>>finder. >>> The structure looks somehing like this.. >>> >>> === controller ==>>> >>> def list >>> attribute_filter = params[:filter] >>> @filter = Caboose::EZ::Condition.new :table do >>> attribute <=> attribute_filter if attribute_filter >>> end >>> # >>> ... do the find with the @filter >>> # >>> end >>> >>> === view ==>>> .... >>> <%= link_to ''Add filter'', {:filter=>value}.merge(params) %> >>> >>> this works fine, but there are some weird things here. >>> Notice that the structure of the ''list'' function is odd. I first >>>> tried >>> this.. >>> >>> def list >>> @filter = Caboose::EZ::Condition.new :table do >>> attribute <=> params[:filter] if params[:filter] >>> end >>> end >>> >>> But this doesn''t work. It doesn''t throw an error, but it adds a >>>> clause >>> to the @filter like this... >>> >>> - !ruby/object:Caboose::EZ::Clause >>> name: params >>> table_prefix: table. >>> test: :[] >>> value: :filter >>> >>> and otherwise doesn''t behave as you might expect. >>> >>> Sooo... if want to use the ez_where plugin with conditions, be > >>>careful. >>> >>> There''s probably a way around this, hopefully Ezra has some nifty >>>> trick >>> for making this work as expected. >>> >>> _Kevin >>> www.sciwerks.com >> >> >> >>Kevin- >> >> This was a problem in an older version of the plugin. It is fixed >>in the new version. I can tell you are using the old one because >>what used to be this: Caboose::EZ::Condition.new ids now >>EZ::Where::Condition.new. Anyways grab the latest version where this >>is fixed. Also note that you do not have to do params[:filter] if >>params[:filter]. You can drop the if params[:filter] and the plugin >>will exclude that condition if params[:filter] is nil. That way you >>don''t have to do all those ugly if''s or unless''s. Grab the latest >>version form here: >> >>$ script/plugin install svn://rubyforge.org//var/svn/ez-where >> >> >>Cheers- >>-Ezra >> >> >> >>_______________________________________________ >>Rails mailing list >>Rails@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > >Great Ezra! > >One other question... if you call .to_sql on an empty Condition, does it >return something like ''1'' now. The older version doesn''t. > >FWIW, I used rapt to download it. I''m not sure where it got it from. > >_Kevin >www.sciwerks.com > >-- >Posted with http://DevLists.com. Sign up and save your mailbox. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsBTW: the Readme file in the new version still uses the Caboose::EZ::Condition notation _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.
> > BTW: the Readme file in the new version still uses the > Caboose::EZ::Condition notation > > _Kevin > www.sciwerks.com > > -- > Posted with http://DevLists.com. Sign up and save your mailbox. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsThanks, fixed now. -Ezra
Hi Ezra, ez-where rocks! I recently started using it with Ajax scaffold and it works great and keeps my controller code sparkling clean. Thanks! On 8/3/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:> > > > > BTW: the Readme file in the new version still uses the > > Caboose::EZ::Condition notation > > > > _Kevin > > www.sciwerks.com > > > > -- > > Posted with http://DevLists.com. Sign up and save your mailbox. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > Thanks, fixed now. > > -Ezra > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060803/afc0253f/attachment.html