leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
545 stars 214 forks source link

Missing partial kaminari/wice_grid/paginator #75

Closed vishakhasawant closed 12 years ago

vishakhasawant commented 12 years ago

Hi, I am trying to use wice_grid 3.2.0.pre3 with rails 3.2. But I am facing the below issue. When I added the wice_grid configuration to my view file, I am getting below error.

ActionView::Template::Error (Missing partial kaminari/wice_grid/paginator with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
  * "/mnt/hgfs/nuscentralbilling/app/views"
  * "/usr/local/rvm/gems/ruby-1.9.2-p290/gems/wice_grid-3.2.0.pre3/app/views"
  * "/usr/local/rvm/gems/ruby-1.9.2-p290/gems/kaminari-0.13.0/app/views"
):
    38: 
    39: 
    40: 
    41: <%= grid(@export_results) do |g|
    42: g.column :name => 'id',:attribute => 'id' do |export_result| 
    43:                             export_result.id
    44:                           end
  app/views/exports/view_export.html.erb:41:in `block in _app_views_exports_view_export_html_erb___737694310__613676508'
  app/views/exports/view_export.html.erb:10:in `_app_views_exports_view_export_html_erb___737694310__613676508'

  Rendered /usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (7.8ms)
  Rendered /usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms)
  Rendered /usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (11.6ms)

Would you please help me to resolve this issue.

Regards,

Vishakha

leikind commented 12 years ago

Would you please attach or paste Gemfile.lock?

Also, on the crash page there must be a link to the full stacktrace. By default what you see is the application code, the full stacktrace shows it all. Please submit the full stacktrace.

Also, when pasting in code, could you please use Github Markdown for formatting so that it looks good.

   like
      this

Otherwise my eyes hurt. Thanks.

vishakhasawant commented 12 years ago

Hi leikind,

Yeah sure. I will paste the full stack trace and attach the file too. But as a newbie to GitHub I don't know how to use github flavored markdown. I tried to use the cheat sheet but I didn't find the suitable markdown for formatting exception stack trace. And where can I find the option to attach the file? Would you please guide me for the same?

Regards,

Vishakha

leikind commented 12 years ago

there is link right above the comment text area https://img.skitch.com/20120822-jhfnwsetsuc1xd4dn7cgrd2jfi.jpg

here is how to add any code https://img.skitch.com/20120822-8gxpea37rm62usxatk9ui4t31k.jpg instead of javascript you can add "ruby" or just omit it.

vishakhasawant commented 12 years ago

Thanks a lot Yuri Leikind. Here is the stacktrace and gemfile.lock ....

actionpack (3.2.0) lib/action_view/path_set.rb:58:in `find'
actionpack (3.2.0) lib/action_view/lookup_context.rb:109:in `find'
actionpack (3.2.0) lib/action_view/renderer/partial_renderer.rb:331:in `find_template'
actionpack (3.2.0) lib/action_view/renderer/partial_renderer.rb:325:in `find_partial'
actionpack (3.2.0) lib/action_view/renderer/partial_renderer.rb:222:in `render'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:41:in `render_partial'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:15:in `render'
actionpack (3.2.0) lib/action_view/helpers/rendering_helper.rb:24:in `render'
kaminari (0.13.0) lib/kaminari/helpers/tags.rb:24:in `to_s'
kaminari (0.13.0) lib/kaminari/helpers/paginator.rb:83:in `to_s'
kaminari (0.13.0) lib/kaminari/helpers/action_view_extension.rb:19:in `paginate'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:587:in `pagination_panel_content'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:339:in `block in grid_html'
wice_grid (3.2.0.pre3) lib/grid_renderer.rb:99:in `pagination_panel'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:334:in `grid_html'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:126:in `define_grid'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:76:in `grid'
app/views/exports/view_export.html.erb:41:in `block in _app_views_exports_view_export_html_erb___737694310__613676508'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.2.0) lib/action_view/helpers/form_tag_helper.rb:643:in `form_tag_in_block'
actionpack (3.2.0) lib/action_view/helpers/form_tag_helper.rb:62:in `form_tag'
app/views/exports/view_export.html.erb:10:in `_app_views_exports_view_export_html_erb___737694310__613676508'
actionpack (3.2.0) lib/action_view/template.rb:143:in `block in render'
activesupport (3.2.0) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.0) lib/action_view/template.rb:141:in `render'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:41:in `block (2 levels) in render_template'
actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:40:in `block in render_template'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:48:in `render_with_layout'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:39:in `render_template'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:12:in `render'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:109:in `_render_template'
actionpack (3.2.0) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.0) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.0) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.0) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
activesupport (3.2.0) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.0) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.0) lib/active_support/callbacks.rb:414:in `_run__204654694__process_action__981786992__callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.0) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.0) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.0) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.0) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.0) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:in `call'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.0) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `_run__846922771__call__387472343__callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.0) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.0) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.0) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.0) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.2.0) lib/rails/engine.rb:479:in `call'
railties (3.2.0) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.0) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (3.2.0)
      actionpack (= 3.2.0)
      mail (~> 2.4.0)
    actionpack (3.2.0)
      activemodel (= 3.2.0)
      activesupport (= 3.2.0)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.0)
      rack (~> 1.4.0)
      rack-cache (~> 1.1)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.2)
    activemodel (3.2.0)
      activesupport (= 3.2.0)
      builder (~> 3.0.0)
    activerecord (3.2.0)
      activemodel (= 3.2.0)
      activesupport (= 3.2.0)
      arel (~> 3.0.0)
      tzinfo (~> 0.3.29)
    activerecord-sqlserver-adapter (3.2.9)
      activerecord (~> 3.2.0)
    activeresource (3.2.0)
      activemodel (= 3.2.0)
      activesupport (= 3.2.0)
    activesupport (3.2.0)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    ansi (1.4.3)
    arel (3.0.2)
    builder (3.0.0)
    erubis (2.7.0)
    hike (1.2.1)
    i18n (0.6.0)
    journey (1.0.4)
    jquery-rails (2.1.1)
      railties (>= 3.1.0, < 5.0)
      thor (~> 0.14)
    json (1.7.5)
    kaminari (0.13.0)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
      railties (>= 3.0.0)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.19)
    multi_json (1.3.6)
    mysql2 (0.3.11)
    polyglot (0.3.3)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.2.0)
      actionmailer (= 3.2.0)
      actionpack (= 3.2.0)
      activerecord (= 3.2.0)
      activeresource (= 3.2.0)
      activesupport (= 3.2.0)
      bundler (~> 1.0)
      railties (= 3.2.0)
    railties (3.2.0)
      actionpack (= 3.2.0)
      activesupport (= 3.2.0)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    simple-navigation (3.6.0)
      activesupport (>= 2.3.2)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    thor (0.14.6)
    tilt (1.3.3)
    tiny_tds (0.5.1)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    turn (0.8.2)
      ansi (>= 1.2.2)
    tzinfo (0.3.33)
    wice_grid (3.2.0.pre3)
      kaminari (>= 0.13.0)

PLATFORMS
  ruby

DEPENDENCIES
  activerecord-sqlserver-adapter (~> 3.2)
  jquery-rails
  mysql2
  rails (= 3.2)
  simple-navigation (= 3.6.0)
  tiny_tds
  turn (= 0.8.2)
  wice_grid (= 3.2.0.pre3)

Regards, Vishakha

leikind commented 12 years ago

I found the error. I wrote partials for the Kaminari plugin using HAML, not ERB, having forgotten that HAML is not the default in Rails :)

So your application does not recognize these files as views.

Version 3.2.0.pre4 will fix this. Right not you can just add gem 'haml' to your Gemfile and run bundle, this should fix the problem.

Thank you very much for this feedback, this is very much appreciated!

vishakhasawant commented 12 years ago

Thanks a lot Leikind. It resolved my issue. But now I am facing two more issues. Though I included wice_grid.js in application.js, I am getting below error.

wice_grid.js not loaded, WiceGrid cannot proceed!
Make sure that you have loaded wice_grid.js.
Add line
//= require wice_grid.js
to app/assets/javascripts/application.js

And the second one is about the database connections. I am using two databases. one is sql server and other one is mysql. I defined mysql as default one. And using establish_connection method of activerecord to connect the sql server. But wice_grid always uses the default one. Is there any workaround which will allow wice_grid to use both the databases?

Thanks and Regards,

Vishakha

leikind commented 12 years ago

WiceGrid uses the connection of the model class that you supply to initialize_grid as the first parameter.

Use webkit inspector (as in Chrome or Safari) or a similar tool to see if wice_grid.js is loaded.

vishakhasawant commented 12 years ago

Sorry for troubling you for the minor issues which I should have resolved.

Thanks a lot for your reply and making such a fabulous gem.

vishakhasawant commented 12 years ago

Hi Leikind,

We are using establish_connection to connect the database which is not default one. But wice_grid is still connecting to the default database. Any idea how I can configure wice_grid to use the connection of the model class.

Regards,

Vishakha

leikind commented 12 years ago

Sorry, I am failing to see the problem. Imagine you have Db1ActiveRecordModel and Db2ActiveRecordModel. When you use WiceGrid the first thing you do is call initialize_grid. So, initialize_grid(Db1ActiveRecordModel) will use one database, initialize_grid(Db2ActiveRecordModel) will use another database. If you call establish_connection to connect to a non default database, let's say, the one for Db2ActiveRecordModel, just make sure it is called before establish_connection. Does it make sense, or have I misunderstood you?

leikind commented 12 years ago

Sorry, here's what I meant: "just make sure it is called before initalize_grid"

vishakhasawant commented 12 years ago

Hi Leikind,

Below is the stack trace of it. It seems it is using the model level establish connection method but throwing some exception. Is it because of my other database is SQL server?

activerecord (3.2.0) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:233:in `query'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:233:in `block in execute'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:233:in `execute'
activerecord (3.2.0) lib/active_record/connection_adapters/mysql2_adapter.rb:214:in `execute'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:247:in `execute_and_free'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:505:in `pk_and_sequence_for'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:518:in `primary_key'
arel (3.0.2) lib/arel/table.rb:39:in `primary_key'
activerecord-sqlserver-adapter (3.2.9) lib/arel/visitors/sqlserver.rb:302:in `select_primary_key_sql?'
activerecord-sqlserver-adapter (3.2.9) lib/arel/visitors/sqlserver.rb:355:in `rowtable_projections'
activerecord-sqlserver-adapter (3.2.9) lib/arel/visitors/sqlserver.rb:174:in `visit_Arel_Nodes_SelectStatementWithOffset'
activerecord-sqlserver-adapter (3.2.9) lib/arel/visitors/sqlserver.rb:97:in `visit_Arel_Nodes_SelectStatement'
arel (3.0.2) lib/arel/visitors/visitor.rb:19:in `visit'
arel (3.0.2) lib/arel/visitors/visitor.rb:5:in `accept'
arel (3.0.2) lib/arel/visitors/to_sql.rb:19:in `accept'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql'
activerecord (3.2.0) lib/active_record/relation.rb:456:in `to_sql'
activerecord (3.2.0) lib/active_record/relation.rb:524:in `references_eager_loaded_tables?'
kaminari (0.13.0) lib/kaminari/models/active_record_relation_methods.rb:20:in `total_count'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:630:in `pagination_info'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:585:in `pagination_panel_content'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:339:in `block in grid_html'
wice_grid (3.2.0.pre3) lib/grid_renderer.rb:99:in `pagination_panel'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:334:in `grid_html'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:126:in `define_grid'
wice_grid (3.2.0.pre3) lib/helpers/wice_grid_view_helpers.rb:76:in `grid'
app/views/exports/view_export.html.erb:41:in `block in _app_views_exports_view_export_html_erb___54627270_91594150'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
haml (3.1.4) lib/haml/helpers/xss_mods.rb:109:in `with_output_buffer_with_haml_xss'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in `capture'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:105:in `capture_with_haml'
actionpack (3.2.0) lib/action_view/helpers/form_tag_helper.rb:643:in `form_tag_in_block'
actionpack (3.2.0) lib/action_view/helpers/form_tag_helper.rb:62:in `form_tag'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:169:in `form_tag_with_haml'
haml (3.1.4) lib/haml/helpers/xss_mods.rb:122:in `form_tag_with_haml_xss'
app/views/exports/view_export.html.erb:10:in `_app_views_exports_view_export_html_erb___54627270_91594150'
actionpack (3.2.0) lib/action_view/template.rb:143:in `block in render'
activesupport (3.2.0) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.0) lib/action_view/template.rb:141:in `render'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:41:in `block (2 levels) in render_template'
actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:40:in `block in render_template'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:48:in `render_with_layout'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:39:in `render_template'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:12:in `render'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:109:in `_render_template'
actionpack (3.2.0) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.0) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.0) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.0) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
activesupport (3.2.0) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.0) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.0) lib/active_support/callbacks.rb:414:in `_run__302715847__process_action__771055558__callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.0) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.0) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.0) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.0) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.0) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.0) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:in `call'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.0) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `_run__48425901__call__905216340__callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.0) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.0) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.0) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.0) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.0) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.2.0) lib/rails/engine.rb:479:in `call'
railties (3.2.0) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.0) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
vishakhasawant commented 12 years ago

Hi Leikind,

It seems the total_count method of lib/kaminari/models/active_record_relation_methods.rb calling the default connection method and causing the issue. As a result it is calling https://github.com/rails/arel/blob/master/lib/arel/table.rb which in turn calls activerecord default connection.

Do you have any idea how I can tweak this?

Thanks and Regards,

Vishakha

leikind commented 12 years ago

Your exception stacktrace is missing the exception itself. I do not see what exactly happened.

WiceGrid is known to work with Postgres and Mysql. I have never used Rails with MS SQL Server. I am not even sure that the fact that in your stacktrace you have both sqlserver.rb and abstract_mysql_adapter.rb is correct or not.

Line 233 of abstract_mysql_adapter.rb is

log(sql, name) { @connection.query(sql) }

Try to see what is in sql.

There is nothing special going on in WiceGrid. WiceGrid calls collection.total_count on line 630 of wice_grid_view_helpers.rb, total_count is a kaminari method. Kaminari calls references_eager_loaded_tables? from which it goes deep into Arel and ActiveRecord and them crashes.

I am pretty sure this is related to your model and the database and not WiceGrid.

Run

YouModel.page(page_number).per(10).includes(your_includes).order(yourorder).where(your_conditions).

in the rails console without any record to see if it works. This is basically how WiceGrid calls ActiveRecord/Arel/Kaminari

leikind commented 12 years ago

I don't get it, do you have one and the same class which can be ised for different databases? If so, this is very very wrong. Don't expect ActiveRecord not to have problems with this

vishakhasawant commented 12 years ago

Hi Leikind,

I am not using the same class for different databases. It is only for SQL server.

And application stack trace shows that it is trying to connect the mysql database(local_database) though it have establish_connection method to connect the SQL server database

ActionView::Template::Error (Mysql2::Error: Table 'local_development.Member' doesn't exist: SHOW CREATE TABLE `Member`):
    38: 
    39: 
    40: 
    41: <%= grid(@export_results) do |g|
    42: g.column :name => 'id',:attribute => 'id' do |export_result| 
    43:                             export_result.id
    44:                           end
  app/views/exports/view_export.html.erb:41:in `block in _app_views_exports_view_export_html_erb___54627270_91594150'
  app/views/exports/view_export.html.erb:10:in `_app_views_exports_view_export_html_erb___54627270_91594150'

  Rendered /usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (4.4ms)
  Rendered /usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms)
  Rendered /usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (6.8ms)

If I make the SQL server database as default one. It is working fine.

Regards,

Vishakha

leikind commented 12 years ago

how do you call establish_connection? On what?

vishakhasawant commented 12 years ago

I am calling it on the same model before calling initialize_grid method. Same model I am trying to use with wice_grid. When I am calling regular activerecord methods it is connecting to SQL server database only.

leikind commented 12 years ago

You should never call establish_connection on ActiveRecord::Base

You should have an abstract class as a parent for all your models of the second database

class SecondDbAbstractModel < ActiveRecord::Base
  self.abstract_class = true
end

and call establish_connection on this abstract class

Tms::TmsAbstractModel.establish_connection(connection_options)
class Model1 < SecondDbAbstractModel

end
class Model2 < SecondDbAbstractModel

end

You establish the second connection once while loading the application and you will have a hierarchy branch serving the second DB.

In any case this does not have any relation to the WiceGrid plugin. WiceGrid only calls the ActiveRecord API which you can also call manually without any WiceGrid to test if your db connection is correct.

leikind commented 12 years ago

3.2.0.pre4 released with the fix

vishakhasawant commented 12 years ago

I have followed the guidelines for connecting to multiple databases but still I am facing the same issue. I have created a gist regarding for the same at https://gist.github.com/3488235. Would you please go through the same? And help me to resolve it.

vishakhasawant commented 11 years ago

I have tried to debug the wice_grid as per your instructions on the above gist https://gist.github.com/3488235. But still facing same issue in my controller code

vishakhasawant commented 11 years ago

Is this related to this issue https://github.com/rails/rails/issues/4836 ? As adding the monkey patch mentioned in this resolves my issue.

leikind commented 11 years ago

You are saying here https://gist.github.com/3488235 that when you run the code without WiceGrid you have the same problem. That means that this is not a problem caused by WiceGrid.