No ruote table created with Ruote::Sequel.create_table($sequel, true) in rails 3.2.12

61 views
Skip to first unread message

emc_lab

unread,
Jun 19, 2013, 12:57:03 PM6/19/13
to openwfe...@googlegroups.com
ruote-sequel is used to connect to sqlite3 used in our rails 3.2.12 app and follow the example in ruote-sequel https://github.com/jmettraux/ruote-sequel.
Ruote::Sequel.create_table($sequel, true) is the command creating the table in the db.

In ruote.rb under rails config/initializers, the table ruote_docs will be created if the table not existing:

  sequel = Sequel.connect('sqlite://development') if Rails.env.development?
  sequel = Sequel.connect('sqlite://test') if Rails.env.test?
  sequel = Sequel.connect('sqlite://ruote_in_rail') if Rails.env.production?

  #ruote_docs is the table name
  opts = { 'sequel_table_name' => 'ruote_docs' }
  #create ruote_docs table if it is not existing
  Ruote::Sequel.create_table(sequel, true) unless ActiveRecord::Base.connection.table_exists? 'ruote_docs'
  RUOTE_STORAGE = Ruote::Sequel::Storage.new(sequel, opts)

However, RUOTE_STORAGE = Ruote::Sequel::Storage.new(sequel, opts) causes error:

  C:/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3/database.rb:91:in `initialize': SQLite3::SQLException: no such table: ruote_
  docs (Sequel::DatabaseError)

Why Ruote::Sequel.create_table($sequel, true) did not create the table? Thanks for help.

John Mettraux

unread,
Jun 19, 2013, 1:03:52 PM6/19/13
to openwfe...@googlegroups.com

On Wed, Jun 19, 2013 at 09:57:03AM -0700, emc_lab wrote:
>
> (...)
>
> C:/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3/database.rb:91:in
> `initialize': SQLite3::SQLException: no such table: ruote_
> docs (Sequel::DatabaseError)
>
> Why Ruote::Sequel.create_table($sequel, true) did not create the table?

Hello,

no idea.

Would it be possible to see the whole error backtrace?


Thanks in advance,

--
John Mettraux - http://lambda.io/jmettraux

emc_lab

unread,
Jun 19, 2013, 1:16:12 PM6/19/13
to openwfe...@googlegroups.com
John, here it is (when running rails console):


C:/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3/database.rb:91:in `initialize': SQLite3::SQLException: no such table: ruote
docs (Sequel::DatabaseError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3/database.rb:91:in `new'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3/database.rb:91:in `prepare'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3/database.rb:263:in `query'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/adapters/sqlite.rb:179:in `block (2 levels) in _execute'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/database/logging.rb:33:in `log_yield'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/adapters/sqlite.rb:179:in `block in _execute'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/database/connecting.rb:235:in `block in synchronize'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/connection_pool/threaded.rb:104:in `hold'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/database/connecting.rb:235:in `synchronize'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/adapters/sqlite.rb:172:in `_execute'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/adapters/sqlite.rb:122:in `execute'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/dataset/actions.rb:860:in `execute'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/adapters/sqlite.rb:350:in `fetch_rows'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/dataset/actions.rb:156:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/dataset/actions.rb:636:in `single_record'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/dataset/actions.rb:217:in `first'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruote-sequel-2.3.0/lib/ruote/sequel/storage.rb:373:in `do_get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruote-sequel-2.3.0/lib/ruote/sequel/storage.rb:166:in `get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/ruote-2048bc6ad7c6/lib/ruote/storage/base.rb:79:in `replace_engine_configuration'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruote-sequel-2.3.0/lib/ruote/sequel/storage.rb:95:in `initialize'
        from C:/D/code/rails_proj/ruote_in_rails/config/initializers/ruote.rb:16:in `new'
        from C:/D/code/rails_proj/ruote_in_rails/config/initializers/ruote.rb:16:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `block in load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:587:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:587:in `block in <class:Engine>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from C:/D/code/rails_proj/ruote_in_rails/config/environment.rb:5:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:103:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:103:in `require_environment!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:40:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

emc_lab

unread,
Jun 19, 2013, 1:17:39 PM6/19/13
to openwfe...@googlegroups.com
line 16 is the RUOTE_STORAGE = .....

John Mettraux

unread,
Jun 19, 2013, 1:20:36 PM6/19/13
to openwfe...@googlegroups.com

Sorry,

it's really simple.

You have to tell create_table that you want to use "ruote_docs":

https://github.com/jmettraux/ruote-sequel/blob/ce0a15673fc56213988fcdac04a8add8b8ba3ddc/lib/ruote/sequel/storage.rb#L33-L42


Best regards,

emc_lab

unread,
Jun 19, 2013, 11:42:23 PM6/19/13
to openwfe...@googlegroups.com
Changed to :

Ruote::Sequel.create_table($sequel, true, 'ruote_docs') unless ActiveRecord::Base.connection.table_exists? 'ruote_docs'

Here is another error which is caused by:

m = re_create ? :create_table! : :create_table?

in storage.rb.

C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruote-sequel-2.3.0/lib/ruote/sequel/storage.rb:46:in `create_table': undefined method `create_table!' for nil:NilC
lass (NoMethodError)
        from C:/D/code/rails_proj/ruote_in_rails/config/initializers/ruote.rb:15:in `<top (required)>'

        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `block in load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:587:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:587:in `block in <class:Engine>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from C:/D/code/rails_proj/ruote_in_rails/config/environment.rb:5:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:103:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:103:in `require_environment!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:40:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

John Mettraux

unread,
Jun 20, 2013, 12:00:13 AM6/20/13
to openwfe...@googlegroups.com

On Wed, Jun 19, 2013 at 08:42:23PM -0700, emc_lab wrote:
> Changed to :
>
> Ruote::Sequel.create_table($sequel, true, 'ruote_docs') unless
> ActiveRecord::Base.connection.table_exists? 'ruote_docs'
>
> Here is another error which is caused by:
>
> m = re_create ? :create_table! : :create_table?
>
>
> in storage.rb.
>
>
> C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruote-sequel-2.3.0/lib/ruote/sequel/storage.rb:46:in
> `create_table': undefined method `create_table!' for nil:NilC
> lass (NoMethodError)
> from
> C:/D/code/rails_proj/ruote_in_rails/config/initializers/ruote.rb:15:in

Hello,

if we look at more of the code (and especially at the line where the error
happens, not at the previous line):


```
def self.create_table(sequel, re_create=false, table_name='documents')

m = re_create ? :create_table! : :create_table?

sequel.send(m, table_name.to_sym) do # <=========== error happens here
# ...
end
# ...
end
```

The error says "undefined method `create_table!' for nil:NilClass
(NoMethodError)".

That means "sequel" is nil.

You are passing nil in $sequel.

Please read error messages it will make you a better programmer.

emc_lab

unread,
Jun 20, 2013, 12:51:50 PM6/20/13
to openwfe...@googlegroups.com
After removing $ sign before sequel, the code passes. Here is the code that works:

     Ruote::Sequel.create_table(sequel, true, 'ruote_docs') unless ActiveRecord::Base.connection.table_exists? 'ruote_docs'

In rails console, there is the deprecation message about storage in ruote-sequel:

SEQUEL DEPRECATION WARNING: Symbol#desc is deprecated and will be removed in Sequel 4.0.  Please use Sequel.desc instead, or Sequel.extension(:core_ex
tensions) to continue using it.
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-3.48.0/lib/sequel/deprecated.rb:67:in `block (3 levels) in deprecated_module'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruote-sequel-2.3.0/lib/ruote/sequel/storage.rb:413:in `prepare_cache'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruote-sequel-2.3.0/lib/ruote/sequel/storage.rb:345:in `begin_step'
C:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/ruote-2048bc6ad7c6/lib/ruote/worker.rb:239:in `begin_step'
C:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/ruote-2048bc6ad7c6/lib/ruote/worker.rb:247:in `step'
C:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/ruote-2048bc6ad7c6/lib/ruote/worker.rb:109:in `run'
C:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/ruote-2048bc6ad7c6/lib/ruote/worker.rb:120:in `block in run_in_thread'

This deprecation message keeps popping up in rails console screen and seems never stopping.

John Mettraux

unread,
Jun 20, 2013, 1:47:33 PM6/20/13
to openwfe...@googlegroups.com

On Thu, Jun 20, 2013 at 09:51:50AM -0700, emc_lab wrote:
>
> After removing $ sign before sequel, the code passes. Here is the code that
> works:
>
> Ruote::Sequel.create_table(sequel, true, 'ruote_docs') unless
> ActiveRecord::Base.connection.table_exists? 'ruote_docs'
>
> In rails console, there is the deprecation message about storage in
> ruote-sequel:
>
> (...)

Hello,

please fill a detailed issue report at:

https://github.com/jmettraux/ruote-sequel

Here is a good document about how to report issues:

http://www.chiark.greenend.org.uk/~sgtatham/bugs.html


Thanks in advance,

John Mettraux

unread,
Jun 21, 2013, 12:25:27 AM6/21/13
to openwfe...@googlegroups.com

On Thu, Jun 20, 2013 at 09:51:50AM -0700, emc_lab wrote:
> After removing $ sign before sequel, the code passes. Here is the code that
> works:
>
> Ruote::Sequel.create_table(sequel, true, 'ruote_docs') unless
> ActiveRecord::Base.connection.table_exists? 'ruote_docs'
>
> In rails console, there is the deprecation message about storage in
> ruote-sequel:
>
> SEQUEL DEPRECATION WARNING: Symbol#desc is deprecated and will be removed
> in Sequel 4.0. Please use Sequel.desc instead, or Sequel.extension(:core_ex
> tensions) to continue using it.
>
> (...)

Hello,

thanks for the issue at https://github.com/jmettraux/ruote-sequel/issues/9

In fact it was already fixed by Iuri Gagnidze.

I'll try to release a 2.3.0.2 ruote-sequel gem.


Thanks again,

John Mettraux

unread,
Jun 21, 2013, 12:43:50 AM6/21/13
to openwferu-users
Hello,

ruote-sequel 2.3.0.2 is out.

Thanks again,

John

emc_lab

unread,
Jun 21, 2013, 4:36:03 PM6/21/13
to openwfe...@googlegroups.com
Thank you!
Reply all
Reply to author
Forward
0 new messages