What Bryan suggested would only work for loaded models, not for a db call. You would need to include the user table and that will probably take a custom finder or named_scope. Your search would need to check if there is a search parameter because a blank means return all usually. Otherwise it's a :condition => ['users.name = ?', searchparam].
On Jul 2, 1:34 pm, hobo_hippy <[email protected]> wrote: > So I tried out the > > def name > user.try.name > end > > in the model after removing the name field from fields do. So far it's > a no go, but I was wondering what the following line from the > controller should look like? > > @timesheets = Timesheet.apply_scopes(:search => [params > [:search], :name], :order_by => parse_sort_param > (:user, :client, :project, :hours, :date)) > > I should mention it just drops the name field after I remove it from > fields do (doesn't ask if I want to rename) since I removed the name > field, migrated, added the def name bit, and migrated again. On the > last migration (after adding def name...) it says models match, no > need to migrate. Does this suggest that def name user.try.name end > isn't doing anything? How can I tell if it's working since I obviously > can't access it like I'd expect? > > what I have there doesn't work. I get: > > Mysql::Error: Unknown column 'timesheets.name' in 'where clause': > SELECT `timesheets`.`id` AS t0_r0, `timesheets`.`created_at` AS t0_r1, > `timesheets`.`updated_at` AS t0_r2, `timesheets`.`hours` AS t0_r3, > `timesheets`.`user_id` AS t0_r4, `timesheets`.`date` AS t0_r5, > `timesheets`.`project_id` AS t0_r6, `timesheets`.`client_id` AS t0_r7, > `clients`.`id` AS t1_r0, `clients`.`name` AS t1_r1, `clients`.`info` > AS t1_r2, `clients`.`created_at` AS t1_r3, `clients`.`updated_at` AS > t1_r4, `clients`.`user_id` AS t1_r5 FROM `timesheets` LEFT OUTER JOIN > `clients` ON `clients`.id = `timesheets`.client_id WHERE > (((timesheets.name like '%Continuum%'))) ORDER BY clients.name ASC > > RAILS_ROOT: /home/domani08/home/domani08/Domanitech > Application Trace | Framework Trace | Full Trace > > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract_adapter.rb:188:in `log' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/mysql_adapter.rb:309:in `execute' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/mysql_adapter.rb:563:in `select' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/database_statements.rb:7:in > `select_all_without_query_cache' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/query_cache.rb:60:in `select_all' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/query_cache.rb:81:in `cache_sql' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/query_cache.rb:60:in `select_all' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1644:in `select_all_rows' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1426:in `find_with_associations' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1424:in `catch' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1424:in `find_with_associations' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > base.rb:1488:in `find_every' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > base.rb:589:in `find' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/model.rb:286:in `find' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:20:in `send' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:20:in `method_missing' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > base.rb:2003:in `with_scope' > (__DELEGATION__):2:in `__send__' > (__DELEGATION__):2:in `with_scope' > (__DELEGATION__):2:in `__send__' > (__DELEGATION__):2:in `with_scope' > (__DELEGATION__):2:in `__send__' > (__DELEGATION__):2:in `with_scope' > (__DELEGATION__):2:in `is_a?' > app/controllers/timesheets_controller.rb:11:in `index' > > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract_adapter.rb:188:in `log' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/mysql_adapter.rb:309:in `execute' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/mysql_adapter.rb:563:in `select' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/database_statements.rb:7:in > `select_all_without_query_cache' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/query_cache.rb:60:in `select_all' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/query_cache.rb:81:in `cache_sql' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/query_cache.rb:60:in `select_all' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1644:in `select_all_rows' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1426:in `find_with_associations' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1424:in `catch' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > associations.rb:1424:in `find_with_associations' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > base.rb:1488:in `find_every' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > base.rb:589:in `find' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/model.rb:286:in `find' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:20:in `send' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:20:in `method_missing' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > base.rb:2003:in `with_scope' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:19:in `method_missing' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:20:in `send' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:20:in `method_missing' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > base.rb:2003:in `with_scope' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/scopes/ > named_scope_extensions.rb:19:in `method_missing' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > named_scope.rb:177:in `load_found' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > named_scope.rb:161:in `proxy_found' > /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ > core_ext/array/extract_options.rb:15:in `extract_options!' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/model_controller.rb: > 460:in `hobo_index' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > base.rb:1253:in `send' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > base.rb:1253:in `perform_action_without_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > filters.rb:617:in `call_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > filters.rb:638:in `run_before_filters' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/controller.rb:22:in > `call' > /usr/lib/ruby/gems/1.8/gems/hobo-0.8.7/lib/hobo/controller.rb:22:in > `included_in_class' > /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ > callbacks.rb:182:in `call' > /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ > callbacks.rb:182:in `evaluate_method' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > filters.rb:184:in `call' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > filters.rb:635:in `run_before_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > filters.rb:615:in `call_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > filters.rb:610:in `perform_action_without_benchmark' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > benchmarking.rb:68:in `perform_action_without_rescue' > /usr/lib/ruby/1.8/benchmark.rb:293:in `measure' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > benchmarking.rb:68:in `perform_action_without_rescue' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > rescue.rb:136:in `perform_action_without_caching' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > caching/sql_cache.rb:13:in `perform_action' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > connection_adapters/abstract/query_cache.rb:34:in `cache' > /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ > query_cache.rb:8:in `cache' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > caching/sql_cache.rb:12:in `perform_action' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > base.rb:524:in `send' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > base.rb:524:in `process_without_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > filters.rb:606:in `process_without_session_management_support' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > session_management.rb:134:in `process' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > base.rb:392:in `process' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > dispatcher.rb:183:in `handle_request' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > dispatcher.rb:110:in `dispatch_unlocked' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > dispatcher.rb:123:in `dispatch' > /usr/lib/ruby/1.8/thread.rb:135:in `synchronize' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > dispatcher.rb:122:in `dispatch' > /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > dispatcher.rb:132:in `dispatch_cgi' ... > > read more » --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Hobo Users" 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/hobousers?hl=en -~----------~----~----~----~------~----~------~--~---
