Hi Folks,
My search fields,
Firstname*
Lastname*
MI - Middle initial
State*
ID
Birthday
when people will search John Bolton in any state for example AL (Alabama),
all John Bolton names in only AL will show up.
So if there are 3 John Bolton with different middle MIs, they will show,
for example
John A. Bolton
John W. Bolton
John O. Bolton and so on...
I used this code in my model, But it show an error,
*def
self.search_my_new_contact(first_name,last_name,initial,inimate_id,state,dob)
*
* find(:all, :include=>[:address_book], :conditions => ["'( LOWER
(address_books.first_name) LIKE ? AND LOWER (address_books.last_name) LIKE
? AND LOWER (address_books.state_name) LIKE ?)' AND '(LOWER
(address_books.initial) LIKE ? OR LOWER (address_books.inmate_id_number)
LIKE ? OR LOWER (address_books.birthday) LIKE ?)'",
"#{first_name.downcase}","#{last_name.downcase}","#{initial.downcase}",
"#{inimate_id.downcase}", "#{state.downcase}","#{dob.downcase}"])*
*end*
*
*
ActiveRecord::StatementInvalid in InimateLocatorsController#index
Mysql2::Error: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'.state_name) LIKE 'ar'))' at line 1: SELECT `contact_books`.`id` AS t0_r0,
`contact_books`.`user_id` AS t0_r1, `contact_books`.`created_at` AS t0_r2,
`contact_books`.`updated_at` AS t0_r3, `contact_books`.`prison_id` AS t0_r4,
`contact_books`.`active` AS t0_r5, `address_books`.`id` AS t1_r0,
`address_books`.`prison_name` AS t1_r1, `address_books`.`first_name` AS t1_r2,
`address_books`.`last_name` AS t1_r3, `address_books`.`inmate_id_number` AS
t1_r4, `address_books`.`birthday` AS t1_r5, `address_books`.`city` AS t1_r6,
`address_books`.`state_id` AS t1_r7, `address_books`.`zipcode` AS t1_r8,
`address_books`.`street` AS t1_r9, `address_books`.`user_id` AS t1_r10,
`address_books`.`created_at` AS t1_r11, `address_books`.`updated_at` AS t1_r12,
`address_books`.`addressable_id` AS t1_r13, `address_books`.`addressable_type`
AS t1_r14, `address_books`.`mobile_no` AS t1_r15,
`address_books`.`avatar_file_name` AS t1_r16,
`address_books`.`avatar_content_type` AS t1_r17,
`address_books`.`avatar_file_size` AS t1_r18,
`address_books`.`avatar_updated_at` AS t1_r19, `address_books`.`address` AS
t1_r20, `address_books`.`gender` AS t1_r21, `address_books`.`fullname` AS
t1_r22, `address_books`.`prison_id` AS t1_r23, `address_books`.`state_name` AS
t1_r24, `address_books`.`image` AS t1_r25, `address_books`.`registration_no` AS
t1_r26, `address_books`.`initial` AS t1_r27 FROM `contact_books` LEFT OUTER
JOIN `address_books` ON `address_books`.`addressable_id` = `contact_books`.`id`
AND `address_books`.`addressable_type` = 'ContactBook' WHERE ( ( LOWER
(address_books.first_name) LIKE 'remo' AND LOWER (address_books.last_name) LIKE
'nandi' AND LOWER (address_books..state_name) LIKE 'ar'))
Rails.root: /home/ashok/projects/textbehind
Application
Trace<http://localhost:3000/inimate_locators?utf8=%E2%9C%93&search_contact%5Bfirst_name%5D=remo&search_contact%5Binitial%5D=&search_contact%5Blast_name%5D=nandi&search_contact%5Binimate_id%5D=&search_contact%5Bstate%5D=AR&search_contact%5Bdob%5D=#>
| Framework
Trace<http://localhost:3000/inimate_locators?utf8=%E2%9C%93&search_contact%5Bfirst_name%5D=remo&search_contact%5Binitial%5D=&search_contact%5Blast_name%5D=nandi&search_contact%5Binimate_id%5D=&search_contact%5Bstate%5D=AR&search_contact%5Bdob%5D=#>
| Full
Trace<http://localhost:3000/inimate_locators?utf8=%E2%9C%93&search_contact%5Bfirst_name%5D=remo&search_contact%5Binitial%5D=&search_contact%5Blast_name%5D=nandi&search_contact%5Binimate_id%5D=&search_contact%5Bstate%5D=AR&search_contact%5Bdob%5D=#>
app/models/contact_book.rb:23:in `search_my_new_contact'
app/controllers/inimate_locators_controller.rb:15:in `index'
Request
*Parameters*:
{"utf8"=>"✓",
"search_contact"=>{"first_name"=>"remo",
"initial"=>"",
"last_name"=>"nandi",
"inimate_id"=>"",
"state"=>"AR",
"dob"=>""}}
Show session
dump<http://localhost:3000/inimate_locators?utf8=%E2%9C%93&search_contact%5Bfirst_name%5D=remo&search_contact%5Binitial%5D=&search_contact%5Blast_name%5D=nandi&search_contact%5Binimate_id%5D=&search_contact%5Bstate%5D=AR&search_contact%5Bdob%5D=#>
Show env
dump<http://localhost:3000/inimate_locators?utf8=%E2%9C%93&search_contact%5Bfirst_name%5D=remo&search_contact%5Binitial%5D=&search_contact%5Blast_name%5D=nandi&search_contact%5Binimate_id%5D=&search_contact%5Bstate%5D=AR&search_contact%5Bdob%5D=#>
Response
*Headers*:
None
*
*
Please Advise.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/EkqaP73324MJ.
For more options, visit https://groups.google.com/groups/opt_out.