jeffp / wizardly

create a functioning wizard for any model in three steps
http://github.com/jeffp/wizardly-examples
MIT License
131 stars 16 forks source link

Error in db:migrate on a fresh database when using act_wizardly_for #4

Open matellis opened 15 years ago

matellis commented 15 years ago

I'm using the Lockdown gem with my app. When I drop, create & migrate my database I get this error:

/project/vendor/gems/wizardly-0.1.8.9/lib/wizardly/wizard/configuration.rb:67:in `create':
 Cannot convert :user to model constant for User: Mysql::Error: Table 'project_dev.users'
  doesn't exist: SHOW FIELDS FROM `users`

It's a chicken and egg: the class can't load because there is no User table and there will be no User table until I've ran db:migrate. Commenting out the act_wizardly_for allows me to migrate.

I've seen this before with eager_class_loading but this was fixed in Rails 2.3. (I'm running Rails 2.3.4 and Ruby 1.8.7.)

I fixed it with a nasty hack that disables Lockdown when I'm running db:migrate but I'm pretty sure this will bite me some other way in the future.

I posted an example here http://github.com/matellis/wizardly-examples and filed a bug with Lockdown here http://stonean.lighthouseapp.com/projects/33317/tickets/35

jetpad commented 14 years ago

This problem is also happening for me when I try to deploy my application to Heroku. Same chicken and egg problem but without involving lockdown. This happens right after pushing to a fresh app and then typing "heroku console".

/home/slugs/151205_a99b705_d9bd/mnt/.gems/gems/wizardly_gt-0.1.8.9/lib/wizardly/wizard/configuration.rb:67:in `create': Failed to configure wizard from User validation groups: PGError: ERROR:  relation "users" does not exist (Wizardly::ValidationGroupError)
SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
          FROM pg_attribute a LEFT JOIN pg_attrdef d
            ON a.attrelid = d.adrelid AND a.attnum = d.adnum
         WHERE a.attrelid = '"users"'::regclass
           AND a.attnum > 0 AND NOT a.attisdropped
         ORDER BY a.attnum
    from /home/slugs/151205_a99b705_d9bd/mnt/.gems/gems/wizardly_gt-0.1.8.9/lib/wizardly/action_controller.rb:22:in `configure_wizard_for_model'
    from /home/slugs/151205_a99b705_d9bd/mnt/.gems/gems/wizardly_gt-0.1.8.9/lib/wizardly.rb:10:in `act_wizardly_for'
    from /disk1/home/slugs/151205_a99b705_d9bd/mnt/app/controllers/signup_controller.rb:3
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:265:in `require_or_load'