Sure once I get the version issue on the gems worked out.  Just posted in 
another thread where you asked me to update to the latest gems from github 
and now am in version catch 22 on will_paginate.  Need to get some other 
work done today so this gives me an excuse to put my fun work aside for a 
bit and get to  that other, not so fun, pile of things.

Bob

On Wednesday, October 10, 2012 11:04:51 AM UTC-4, Bryan Larsen wrote:
>
> The new page uses the right path, but the edit page doesn't?   Sounds 
> like a bug alright, paths was the last major change to land in Hobo 
> 2.0, so it's probably a bug in Hobo.   Can you send the full back 
> trace? 
>
> thanks, 
> Bryan 
>
>
> On Wed, Oct 10, 2012 at 11:01 AM, Bob Sleys <[email protected]<javascript:>> 
> wrote: 
> > GRR I thought I had this all done but now I getting the following error 
> on 
> > an edit page, note prior to this I was playing around with creating a 
> new 
> > record 
> > 
> > NoMethodError in Machines#edit 
> > 
> > Showing controller: machines; dryml-tag: edit-page where line #1 raised: 
> > 
> > undefined method `complete_select_model_machine_path' for 
> > #<#<Class:0x00000005b071d8>:0x00000005b0e028> 
> > 
> > The path the auto completer in my mode is creating is 
> > 
> > complete_select_model_machines GET 
> > /machines/complete_select_model(.:format) 
> > machines#complete_select_model 
> > 
> > Note the plural on the machines but the edit form is looking for the 
> > singular form. 
> > 
> > My dryml is using the following 
> > 
> >        <machine-model-view:> 
> > <name-one complete-target="&@machine" completer="select_model"/> 
> >       </machine-model-view:> 
> > 
> > as part of the machine form tag. 
> > 
> > Bob 
> > 
> > On Wednesday, October 10, 2012 10:30:52 AM UTC-4, Bob Sleys wrote: 
> >> 
> >> Ok one more follow up on this for anyone else following this 
> >> 
> >> Since I'm returning a string that is a composite of two fields across 
> two 
> >> models and I'm overiding the name of the model to do the same there is 
> no 
> >> proper automatic find_by_name so I had to provide my own. 
> >> 
> >> That probably wasn't very clear so here are the details. 
> >> 
> >> In my model MachineModel I don't have an automatic name field.  Instead 
> I 
> >> provided my own 
> >> 
> >>   def name 
> >>     "#{manufacturer.name} - #{model_of_machine}" 
> >>   end 
> >> 
> >> since my name is comprised of both a field on the MachineModel and a 
> field 
> >> in the model Manufacturer an automatic find_by_name won't work so I had 
> to 
> >> create my own like so. 
> >> 
> >>   def self.find_by_name(query) 
> >>     query = query.split(' - ').map {|term| "%#{term}%" } 
> >>     sql = 
> >> 
> self.includes(:manufacturer).where(Manufacturer.arel_table[:name].matches(query[0]))
>  
>
> >>     sql = 
> >> sql.where(MachineModel.arel_table[:model_of_machine].matches(query[1])) 
> if 
> >> query[1] 
> >>     sql.first 
> >>   end 
> >> 
> >> Note I split on the - this time because my name uses it to separate the 
> >> two fields.  This will be a problem if a manufacturer name has a dash 
> in it. 
> >> (don't know a good way to avoid that. 
> >> 
> >> This was all required because of the name-one the Bryan helped me with. 
> >> 
> >> In my Machine form I have 
> >> <machine-model-view:> 
> >> <name-one complete-target="&@machine" completer="select_model"/> 
> >> </machine-model-view:> 
> >> 
> >> This create a text box with auto complete which calls the autocompleter 
> in 
> >> the machine controller 
> >> 
> >> autocomplete :select_model do 
> >>       hobo_completions :name, MachineModel.scoped() 
> >> end 
> >> 
> >> This in turn calls the name_contains in MachineModel 
> >> 
> >>   def self.name_contains(query) 
> >>     query = query.split.map {|term| "%#{term}%" } 
> >>     sql = 
> >> 
> self.includes(:manufacturer).where(Manufacturer.arel_table[:name].matches(query[0]))
>  
>
> >>     sql = 
> >> sql.where(MachineModel.arel_table[:model_of_machine].matches(query[1])) 
> if 
> >> query[1] 
> >>     sql 
> >>   end 
> >> 
> >> Note since the name was defined to return the manufacture - 
> machine_model 
> >> it's that string that is used to save the machine record.  When saving 
> the 
> >> new machine record it needs to find the corresponding machine_model 
> record 
> >> to get it's id.  Thus the need for the find_by_name I began with. 
> >> 
> >> Hope that name some sense, for when I try this again in 6 months and 
> >> forget all the details other than "I did that once before:. 
> >> 
> >> Bob 
> >> 
> >> On Wednesday, October 10, 2012 9:56:26 AM UTC-4, Bob Sleys wrote: 
> >>> 
> >>> Thank you very much. 
> >>> 
> >>> FYI though this could probably be improved this is what I ened up with 
> in 
> >>> my model 
> >>> 
> >>>   def self.manufacturer_model_contains(query) 
> >>>     query = query.split.map {|term| "%#{term}%" } 
> >>>     sql = 
> >>> 
> self.includes(:manufacturer).where(Manufacturer.arel_table[:name].matches(query[0]))
>  
>
> >>>     sql = 
> >>> 
> sql.where(MachineModel.arel_table[:model_of_machine].matches(query[1])) if 
> >>> query[1] 
> >>>     sql 
> >>>   end 
> >>> 
> >>> Bob 
> >>> 
> >>> On Wednesday, October 10, 2012 3:36:57 AM UTC-4, Bryan Larsen wrote: 
> >>>> 
> >>>> On Tue, Oct 9, 2012 at 3:09 PM, Bob Sleys <[email protected]> wrote: 
> >>>> > Ok getting closer 
> >>>> > 
> >>>> > Now I getting the following error 
> >>>> > 
> >>>> > undefined method `manufacturer_model_contains' for 
> >>>> > #<ActiveRecord::Relation:0x00000006c13350> 
> >>>> > 
> >>>> > 
> >>>> > Do I need to add a method to my model to handle it?  If so what 
> would 
> >>>> > it 
> >>>> > look like.  IE is it doing to search for the query string? 
> >>>> 
> >>>> That's right.  
> http://cookbook.hobocentral.net/manual/scopes#_contains 
> >>>> 
> >>>> You can do it with: 
> >>>> 
> >>>> def self.manufacturer_model_contains(query) 
> >>>> 
> >>>> 
> self.includes(:manufacturer).where(Manufactuer.arel_table[:name].matches(query))
>  
>
> >>>> + self.model_of_machine_contains(q) 
> >>>> end 
> >>>> 
> >>>> Note how I'm using AREL for the first clause.   That way it will 
> >>>> automatically switch to ILIKE in postgres. 
> >>>> 
> >>>> One thing the above doesn't do is split your query: if the user 
> >>>> supplies a search for both the model & manufacturer, it will fail. 
> >>>> This shows how to do that: 
> >>>> 
> >>>> 
> >>>> 
> http://stackoverflow.com/questions/4027276/help-with-rails-active-record-querying-like-clause
>  
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Hobo Users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/hobousers/-/nJZd8cpOMmsJ. 
> > 
> > To post to this group, send email to [email protected]<javascript:>. 
>
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:>. 
> > For more options, visit this group at 
> > http://groups.google.com/group/hobousers?hl=en. 
>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/hobousers/-/OeQJE9ER3IEJ.
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/hobousers?hl=en.

Reply via email to