Skip to content

Commit

Permalink
remove :null => false condition on reference to parent model in trans…
Browse files Browse the repository at this point in the history
…lation table migration to fix refinery/refinerycms#2450
  • Loading branch information
shioyama committed Oct 28, 2013
1 parent 40a2e36 commit f2fd6e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/globalize/active_record/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def complete_translated_fields

def create_translation_table
connection.create_table(translations_table_name) do |t|
t.references table_name.sub(/^#{table_name_prefix}/, '').singularize, :null => false
t.references table_name.sub(/^#{table_name_prefix}/, '').singularize
t.string :locale, :null => false
t.timestamps
end
Expand Down

16 comments on commit f2fd6e7

@DaveahamLincoln
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried jury-rigging this commit to my app to try and fix the "Mysql2::Error: Column 'refinery_page_id' cannot be null" error and it doesn't seem to make any difference. Still getting the same error when I run the rake db:setup or attempt to add pages.

@parndt
Copy link
Member

@parndt parndt commented on f2fd6e7 Oct 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remember that it's a migration so you'll have to re-migrate your database. Don't use rake db:setup but use rake db:{drop,create,migrate} then rake db:seed

@DaveahamLincoln
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, tried that. The database dropped and created fine, but the seed failed, same error. I'm going to look at the stack trace I've got and see if I can figure anything out that might help resolve the issue. If I come up with anything I'll let you know.

@shioyama
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I tried it and it worked. I made the change and switched the dependency in the refinery Gemfile to depend on my local instance of globalize. I tried it with and without the change, each time re-creating the db, migrating and running rake db:seed and it failed without the change, worked with it.

@shioyama
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parndt you'd better confirm that this works before releasing 3.0.1.

@parndt
Copy link
Member

@parndt parndt commented on f2fd6e7 Oct 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shioyama agreed.

@DaveahamLincoln
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got to head home, but I'll leave you with these- hope they help. It's probably a problem on my end, but I'm not quite sure- everything in the install checks out and I'm able to generate a new Refinery app just fine- just when I get to the point where I need to actually bolt on the database bad things happen.

My Gemfile: http://pastebin.com/MFddWzur
My output from rake db:{drop,create,migrate}: http://pastebin.com/J4TH2p0G
My output from rake db:seed --trace: http://pastebin.com/erGaG8wz

@shioyama
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaveahamLincoln Just putting globalize in the Gemfile of your refinery app won't work because refinery itself depends on globalize3. You have to actually clone refinery, swap globalize3 for the branch of globalize here in the Gemfile of that cloned repo, and then change your Gemfile to depend on that local repo (with path:). I'm pretty sure that's why the fix wasn't working for you.

@DaveahamLincoln
Copy link

@DaveahamLincoln DaveahamLincoln commented on f2fd6e7 Oct 28, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parndt
Copy link
Member

@parndt parndt commented on f2fd6e7 Oct 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct. I've created a branch on Refinery called 2-1-globalize which has these changes (and failing tests):

gem 'globalize', :github => 'globalize/globalize', :branch => 'fix_refinery_db_seed'
gem 'refinerycms', :github => 'refinery/refinerycms', :branch => '2-1-globalize'

Bundle, try again.

@shioyama
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried running bundle on that branch and I got a dependency conflict:

Bundler could not find compatible versions for gem "mime-types":
  In Gemfile:
    refinerycms (>= 0) ruby depends on
      mime-types (~> 1.16) ruby

    refinerycms-testing (~> 2.1.0) ruby depends on
      mime-types (2.0)

Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    refinerycms (>= 0) ruby depends on
      actionpack (= 3.1.3) ruby

    refinerycms (>= 0) ruby depends on
      actionpack (3.2.12)

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    refinerycms (>= 0) ruby depends on
railties (!= 3.2.0, != 3.2.1, != 3.2.10, != 3.2.11, != 3.2.2, != 3.2.3, != 3.2.4, != 3.2.5, !=
3.2.6, != 3.2.7, != 3.2.8, != 3.2.9, < 3.3, >= 3.1.11) ruby

    refinerycms (>= 0) ruby depends on
      railties (3.2.11)

@parndt
Copy link
Member

@parndt parndt commented on f2fd6e7 Oct 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shioyama that's quite the conflict

@parndt
Copy link
Member

@parndt parndt commented on f2fd6e7 Oct 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, I don't see that conflict but it looks like Travis does.

@parndt
Copy link
Member

@parndt parndt commented on f2fd6e7 Oct 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK Deleting my Gemfile.lock means I can reproduce the bundler error.. joy!

@drfigs
Copy link

@drfigs drfigs commented on f2fd6e7 Nov 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI i still getting the error, in my gemfile:

I commented the line:
#gem 'refinerycms', '~> 2.1.0'
I added:
gem 'globalize', :github => 'globalize/globalize', :branch => 'fix_refinery_db_seed'
gem 'refinerycms', :github => 'refinery/refinerycms', :branch => '2-1-globalize'
I deleted the gem.lock
I ran bundle install
I remove the database and then I ran rake db:migrate
...Now I am getting a different error:
NoMethodError in Refinery::Admin::PagesController#create
undefined method `to_slug' for nil:NilClass
...any help on that??

@mattkorp-zz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing :null saved me. Thank you!!!

Please sign in to comment.