$ rake db:migrate
(in /Users/myuser/src/test)
rake aborted!
Table as does not exist
Here are the steps I went through to reproduce this. First, create the
Hobo app:
$ hobo testproject
Create the first model, A:
$ ruby script/generate hobo_model_resource a name:string type:string
Setup database.yml, generate and execute the migration:
$ ruby script/generate hobo_migration
Create the second model, B:
$ruby script/generate hobo_model_resource b
Edit the B model to extend A:
class B < A
# --- Permissions --- #
def create_permitted?
acting_user.administrator?
end
def update_permitted?
acting_user.administrator?
end
def destroy_permitted?
acting_user.administrator?
end
def view_permitted?(field)
true
end
end
Generate and run the migration:
$ ruby script/generate hobo_migration
Voila. All works fine. Now, if I delete all the tables and run
db:migrate, it fails:
$ rake db:migrate
(in /Users/myuser/src/test)
rake aborted!
Table as does not exist
Following the suggestions at
http://stackoverflow.com/questions/646391/ruby-on-rails-single-table-inheritance-sti-and-unit-test-problem-with-postgres,
I tried removing test/fixtures/as.yml and test/fixtures/bs.yml, but
that didn't help.
hobo 0.9.103
rails 2.3.5
rake 0.8.7
jruby 1.4.0RC1
Any suggestions?
> Following the suggestions athttp://stackoverflow.com/questions/646391/ruby-on-rails-single-table-...,
> Yup. Basically started with a brand new database... no tables at all.
Even in vanilla Rails, migrating on a blank DB isn't the preferred way
to clear the db - rake db:reset should work better, and has the
advantage of re-seeding the DB, if your using the db/seeds.rb stuff
added in Rails 2.3.
There's a ticket about this someplace on the LH - as I recall, there's
a place where we call 'columns' on a model without a table during the
setup process.
--Matt Jones
On Jan 22, 1:40 pm, Matt Jones <al2o...@gmail.com> wrote:
> On Jan 22, 2010, at 2:30 PM, VegHead wrote:
>
> > Yup. Basically started with a brand new database... no tables at all.
>
> Even in vanilla Rails, migrating on a blank DB isn't the preferred way
> to clear the db - rake db:reset should work better, and has the
> advantage of re-seeding the DB, if your using the db/seeds.rb stuff
> added in Rails 2.3.
There is a scenario where it is normal for the user/developer to have
a blank db: adding a new member to the development team.
In fact, that's how I discovered this. Another developer checked out
the project, added the necessary database users, created the databases
and tried to run the migrations. He immediately ran into the "Table
foo does not exist" error.
That's also why I was testing with a blank database - I was trying to
recreate his experience.
-Sean
-Sean
"Even in this case, you'll want to run something like db:setup (which
creates the db, loads the schema from db/schema.rb and seeds it)
rather than mucking around with re-running all the migrations."
Unfortunately, db:setup produces the same results:
$ rake db:setup
...
rake aborted!
Table as does not exist
-Sean
I've got some free cycles this weekend; I'll take a look at it. I
*thought* this was a repeat of #345 (https://hobo.lighthouseapp.com/projects/8324/tickets/345-inheritance-is-broken-again
), but it's a little different.
--Matt Jones
> --
> You received this message because you are subscribed to the Google
> Groups "Hobo Users" group.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to hobousers+...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/hobousers?hl=en
> .
>
On Jan 22, 2:25 pm, Matt Jones <al2o...@gmail.com> wrote:
> Ah, got it now. I could have *sworn* db:schema:load worked even in
> this instance, but peeking at the source in Rails 2.3.5 shows that's
> not the case; that task requires the environment to load first as well.
>
> I've got some free cycles this weekend; I'll take a look at it. I
> *thought* this was a repeat of #345 (https://hobo.lighthouseapp.com/projects/8324/tickets/345-inheritance-...
-Sean
On Jan 22, 3:25 pm, Matt Jones <al2o...@gmail.com> wrote:
> Ah, got it now. I could have *sworn* db:schema:load worked even in
> this instance, but peeking at the source in Rails 2.3.5 shows that's
> not the case; that task requires the environment to load first as well.
>
> I've got some free cycles this weekend; I'll take a look at it. I
> *thought* this was a repeat of #345 (https://hobo.lighthouseapp.com/projects/8324/tickets/345-inheritance-...
> Yeah, #345 is really really close... Is it possible I don't have the
> fix that Tom Locke made for #345? I'm running hobo 0.9.103 and it
> looks like he made that change for 1.0RC1.
>
> -Sean
0.9.100 was (I think) right around RC1; the naming is a little
confusing. The issue closed by #345 wouldn't handle your case, as the
migration generator does an entirely different class-loading dance
than the standard methods. Just to speed things up for me, can you
post a complete backtrace (run 'rake db:migrate --trace') of the error?
--Matt Jones
$ rake db:setup --trace
(in /Users/myuser/src/testproject)
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
testproject_dev already exists
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Table as does not exist
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activerecord-2.3.5/lib/active_record/base.rb:1271:in `columns'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobofields-0.9.103/lib/hobo_fields/model_extensions.rb:212:in `column'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/scopes/automatic_scopes.rb:340:in `column'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/scopes/automatic_scopes.rb:171:in `create_scope'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/scopes/automatic_scopes.rb:8:in
`create_automatic_scope'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model.rb:354:in `respond_to?'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/core_ext/class/
inheritable_attributes.rb:125:in
`inherited_with_inheritable_attributes'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activerecord-2.3.5/lib/active_record/observer.rb:50:in `inherited'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activerecord-2.3.5/lib/active_record/base.rb:401:in `inherited'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobofields-0.9.103/lib/hobo_fields/model_extensions.rb:30:in
`inherited'
/Users/myuser/src/testproject/app/models/b.rb:1
/Users/myuser/src/testproject/app/models/b.rb:380:in `load'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:380:in
`load_file'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:521:in
`new_constants_in'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:379:in
`load_file'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:259:in
`require_or_load'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:425:in
`load_missing_constant'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:80:in
`const_missing_with_dependencies'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:92:in
`const_missing'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/inflector.rb:361:in
`constantize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/inflector.rb:360:in
`constantize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:
162:in `constantize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_controller.rb:86:in `model'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_controller.rb:299:in
`available_auto_write_actions'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_controller.rb:286:in
`available_auto_actions'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_controller.rb:128:in `auto_actions'
/Users/myuser/src/testproject/app/controllers/bs_controller.rb:5
/Users/myuser/src/testproject/app/controllers/bs_controller.rb:380:in
`load'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:380:in
`load_file'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:521:in
`new_constants_in'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:379:in
`load_file'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:259:in
`require_or_load'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:425:in
`load_missing_constant'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:80:in
`const_missing_with_dependencies'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:92:in
`const_missing'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/inflector.rb:361:in
`constantize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/inflector.rb:360:in
`constantize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:
162:in `constantize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_controller.rb:61:in `all_controllers'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_controller.rb:57:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_controller.rb:57:in `all_controllers'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_router.rb:97:in `add_routes_for'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_router.rb:83:in `add_routes'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_router.rb:83:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo/model_router.rb:83:in `add_routes'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
hobo-0.9.103/lib/hobo.rb:73:in `add_routes'
/Users/myuser/src/testproject/config/routes.rb:6
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
actionpack-2.3.5/lib/action_controller/routing/route_set.rb:226:in
`draw'
/Users/myuser/src/testproject/config/routes.rb:1
/Users/myuser/src/testproject/config/routes.rb:145:in `load'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:145:in
`load_with_new_constant_marking'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:521:in
`new_constants_in'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:145:in
`load_with_new_constant_marking'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
actionpack-2.3.5/lib/action_controller/routing/route_set.rb:286:in
`load_routes!'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
actionpack-2.3.5/lib/action_controller/routing/route_set.rb:286:in
`each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
actionpack-2.3.5/lib/action_controller/routing/route_set.rb:286:in
`load_routes!'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
actionpack-2.3.5/lib/action_controller/routing/route_set.rb:266:in
`load!'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rails-2.3.5/lib/initializer.rb:537:in `initialize_routing'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rails-2.3.5/lib/initializer.rb:188:in `process'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rails-2.3.5/lib/initializer.rb:113:in `run'
/Users/myuser/src/testproject/config/environment.rb:9
/Users/myuser/src/testproject/config/environment.rb:31:in `require'
/Users/myuser/Apps/jruby/current/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:31:in `require'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:156:in
`require'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:521:in
`new_constants_in'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:156:in
`require'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rails-2.3.5/lib/tasks/misc.rake:4
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/Users/myuser/Apps/jruby/current/lib/ruby/1.8/monitor.rb:242:in
`mon_synchronize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:604:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/Users/myuser/Apps/jruby/current/lib/ruby/1.8/monitor.rb:242:in
`mon_synchronize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:604:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/Users/myuser/Apps/jruby/current/lib/ruby/1.8/monitor.rb:242:in
`mon_synchronize'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/bin/rake:31
/Users/myuser/Apps/jruby/jruby-1.4.0RC1/lib/ruby/gems/1.8/gems/
rake-0.8.7/bin/rake:19:in `load'
/Users/myuser/Apps/jruby/current/bin/rake:19
Nothing like a little live patching... can you try adding this line:
return unless table_exists?
at the very beginning of the column method (line 211 of hobofields/lib/
hobo_fields/model_extensions.rb)?
The trace has the automatic scope code trying to see if
inherited_without_inheritable_attributes is a column, which hits the
DB and dies. This code essentially says, "if the DB isn't there,
nevermind about that scope...".
--Matt JOnes
Woo woo!
That did the trick. Worked perfectly.
Thanks! That is very cool. This is why I love open source. :)
Sean
Reminds me of the old stories about IBM tech support back in the Iron
Age: staff engineers would apparently give field support lists of
*physical* patches (ie, solder a wire from A to B on card X) to the
mainframe circuits, over the phone...
:)
--Matt Jones
--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.