-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Project doesn't load Home Page and can't add pages. #2450
Comments
I am experiencing the exact same issue on CentOS 6 x86-64, using MySQL. rake db:seed fails on install due to page_id being NULL, and as such, the home page has no content by default. If you navigate to /refinery on the newly-created site, you can create the admin user, but no new articles can be generated due to the same error (refinery_page_id may not be NULL). Rails version is 3.2.15, refinery gem versions are as follows: refinerycms (2.1.0) |
Try this:
|
I tried running with both globalize3 v0.3.0 and v0.3.1. Both times when I ran the |
I, too, am still experiencing this issue. I now have globalize3 0.3.0 in use, and rake db:seed still produces the page_id cannot be NULL error:
|
If it's possible, could you try dropping the db and running |
After dropping the databases via the MySQL command line, then running rake db:migrate db:seed as requested, I am presented with the following "database unknown" error: rake db:migrate db:seed Also, I should note that the "page_id cannot be null" issue we're now experiencing is relatively new, as I deployed two refinerycms projects within the past week successfully. |
I got the same error after deleting the sqlite db and running |
Idling in the #refinerycms IRC channel, it appears a lot of users are now having this issue. |
It's not to do with globalize is it? cc @shioyama |
It does look like a globalize issue, but downgrading to |
Here are all the changes between 0.3.0 and 0.3.1: globalize/globalize@v0.3.0...3-0-stable |
@parndt I suspect it's this commit: globalize/globalize@bc2402b. It added a |
It is strange that translations are being added without a model id... but this may have been happening before and nobody noticed. |
I've confirmed that once you drop the @parndt I don't know refinerycms at all so I think you should confirm this is in fact what's going wrong, although it looks pretty clear-cut to me. It seems strange that refinery is seeding the db with translations that do not have a parent model id, though. |
Thanks a lot, Chris! |
Same problem happens after creating an extension to refinery and trying to test it by deploying dummy app with task 'refinery:testing:dummy_app'. |
…lation table migration to fix refinery/refinerycms#2450
I've created a branch with the fix in the 3-0-stable branch of globalize (see above). If all tests pass we can release this as globalize 3.0.1. Although I'd still like to know why refinery is creating translations that don't reference the parent model. |
@shioyama thanks, that helps... I think Refinery is faulty.. the master branch of Refinery (3.0.0 development) doesn't have this bug because it doesn't have, in before_save { |m| m.translation.save }
before_create :ensure_locale!
# ..
# Make sures that a translation exists for this page.
# The translation is set to the default frontend locale.
def ensure_locale!
if self.translations.empty?
self.translations.build(:locale => Refinery::I18n.default_frontend_locale)
end
end This was probably a workaround for when Globalize was not as good. On the 2-1-stable version of Refinery, this also has to do with the seo_meta integration. I remove the seo_meta stuff from 2-1-stable in addition to the lines commented out above then all of the tests pass again and pages can be created successfully. So, something's going on with ActiveRecord v3, Refinery 2.1.x and code that works fine in ActiveRecord v4, Refinery 3.0.0.dev |
@shioyama having said this, I can't figure out why this is happening and as technically this is a regression in globalize we should probably release version 3.0.1 so that Refinery is fixed and other libraries don't have the same problem. Do you agree? We could close this issue by making Refinery 2.1.x depend on |
@parndt sure as long as we know the source of the problem, I'm okay with it. And it would definitely be good to update the dependency to |
Is there a work around for this until a new version of refinery is release? |
Currently I'm not sure that we've even fixed the issue. Can you try any of the solutions proposed here to let us know if anything helps: |
Created new refinery project with: Then added this to gemfile
bundled, dropped/created/migrated db and was able to run However now when I go to the pages index in refinery I get
|
Yeah, that's ( |
Patched gem of @scottolsen worked for me ;) |
The symptomI cannot say exactly what happens, but as the null restraint error obviously points out, translations are being created with a # pages count and translations count starts at 0
p = Refinery::Page.new
p.title = "test"
p.save
Refinery::Page.count
# => 1
Refinery::Page::Translation.count
# => 1
# refinery_page id is nil! why?
Refinery::Page::Translation.first
# => #<Refinery::Page::Translation id: 27, refinery_page_id: nil, locale: "en", created_at: "2013-10-31 02:01:55", updated_at: "2013-10-31 02:01:56", title: "test", custom_slug: nil, menu_title: nil, slug: "test"> Code problemNow a bit more towards the code.. When a translation is initialized through Parked on line 51 of record.translations
# => [#<Refinery::Page::Translation id: 25, refinery_page_id: nil, locale: "en", created_at: "2013-10-31 01:44:55", updated_at: "2013-10-31 01:44:55", title: nil, custom_slug: nil, menu_title: nil, slug: nil>]
# ==================================
# Translation association is built but FK (refinery_page_id) is nil.
# possibly a missing :inverse_of?
# ==================================
record.translations.size
# => 1
record.translations.count
# => 0
existing_translations_by_locale[locale_str]
# => #<Refinery::Page::Translation id: 26, refinery_page_id: nil, locale: "en", created_at: "2013-10-31 01:50:10", updated_at: "2013-10-31 01:50:10", title: nil, custom_slug: nil, menu_title: nil, slug: nil>
# =============================================================
# IF we were to ignore the existing translation record and simply
# initialize from scratch, refinery_page_id would be properly populated:
# =============================================================
record.translations.find_or_initialize_by_locale(locale_str)
# => #<Refinery::Page::Translation id: nil, refinery_page_id: 22, locale: "en", created_at: nil, updated_at: nil, title: nil, custom_slug: nil, menu_title: nil, slug: nil> Attributes are updated on the already initialized translation that doesn't have an association ID, so when everything saves, we end up with a translation that doesn't belong anywhere. This is why the null constraint fails and why removing it ultimately does nothing to resolve the issue. Since these translations are being saved without a foreign key, any translations saved will not be accessible by a Page, ultimately leading to |
UPDATE:
If you remove both the before_save and before_create callbacks you mentioned, the translations are created in globalize without an issue and everything seems to proceed normally ... I think, but I'm new to this refinery stuff :-). |
It's testing the issue I mentioned above, about creating/updating a new translation in two steps rather than just one. But if the current code is breaking refinery, then I think it's a priority to fix that. I'm exploring using |
@parndt I think I've finally got a fix for this which gets tests to pass in both globalize and refinery. Will update the branch later today. It will require a small change to refinery 2.1, which I'll post as a PR. |
Ok PR #2462 should finally fix this problem -- all tests pass locally -- but for some bizarre reason one solitary test is failing on Travis. This is the failing test:
If anybody would like to get this problem fixed, now is the time to step in. Clone the branch I created, switch to the branch with rake refinery:testing:dummy_app
rake Then please report what you find, and if you get the failure then it would greatly help if you could try to figure out what is going on. |
Hi everybody, thanks for your work you saved my night... The following sequence worked nicely for me too (I give details for newbies like me): In the Gemfile insert: gem "globalize3", "0.3.0" |
@shioyama |
@laspluviosillas thanks any help would be much appreciated. I can't really put any more time into this, and fixing a failure that only appears in Travis is a pain... if anybody has any suggestions I'm all ears. Maybe just rerunning the build would work. This seems like an urgent issue though, so maybe the refinery maintainers could just ignore that one failure for now and merge the PR? That should close this issue. |
ChristopheBelpair worked for me. Using PG. |
I ran into StackLevelTooDeep hell when I tried this (can't load the environment) with an existing project and cherry-picked the commits into a fork of 2-1-stable. They seem to be related to il8n. I was at commit 9b973c5 previously. The few commits between that and these commits are innocuous. |
It seems like I've isolated this to a conflict with refinerycms-blog. When I get rid of references to it in the project, I can load the environment. |
I added d543eb1 to get I'm not really familiar with the roots of this dep conflict and it really doesn't have anything to do with the issue here, so I just did whatever seemed to work to get it to build correctly. |
When is this going to be fixed? Using |
@Haegin what if you use I've no idea when we'll have a consistent solution for this. |
@shioyama I've merged it. |
@parndt thanks! Everyone following this, please try the latest version of refinery from the |
@parndt @shioyama Thanks guys, it's nice to see Refinery working as it should. The test failure in Travis seems really strange. I've just run the tests on the 2-1-stable branch locally and they're passing fine. Hopefully it's a Travis CI problem and won't cause problems for anyone using RefineryCMS in the wild. |
@shioyama I'm still seeing this and so is @captproton source 'https://rubygems.org'
gem 'rails', '3.2.15'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# Refinery CMS
gem 'refinerycms', '~> 2.1.0', github: 'refinery/refinerycms', branch: '2-1-stable'
gem 'globalize', github: 'globalize/globalize', branch: '3-0-stable'
# Optionally, specify additional Refinery CMS Extensions here:
gem 'refinerycms-acts-as-indexed', '~> 1.0.0'
# gem 'refinerycms-blog', '~> 2.1.0'
# gem 'refinerycms-inquiries', '~> 2.1.0'
# gem 'refinerycms-search', '~> 2.1.0'
# gem 'refinerycms-page-images', '~> 2.1.0' So, fairly standard. |
OK SO the reason for this is because it was keeping the bad schema information from when I wasn't using edgey versions. Solution:
Problem solved. @shioyama we should release new gems? |
@parndt I think you should release refinery, the latest version of globalize (3.0.1) should work fine without any update. btw I think globalize/globalize#306 might explain the weird random failing refinery spec, since it was related to a slug. Once I fix that issue I think that one failure should disappear, although can't be 100% sure. |
globalize gem add a validation for locale field in translation table we should be explicit expose locale more details see refinery#140
Hi all, just to double-check is there a solution to this without having to drop & reseed the db? |
When I first install the project and go to localhost:3000, the server redirects me to the standard 404 page. I'm able to navigate to localhost:3000/refinery and access the admin pages. When I go to add a new page I get this error.
There was also another person on the IRC that was having the same issue. I'm running on OSX 10.9 if that may be an issue also. I can provide more info if needed. Thanks.
The text was updated successfully, but these errors were encountered: