Project

General

Profile

Actions

Feature #14534

closed

Upgrade to Rails 4.2

Added by Marwan Rabbaa over 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Category:
Rails support
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

Hi,

I want to run redmine on rails 4.
For me (a rails / ruby newbie), it was not a short time task ;), but I'm shure i will rage against this with you help.

I want completed 4 steps, and with it I can run my application, but I have a HTTP/500 error on the welcome controller.

Started GET "/" for 83.217.232.12 at 2013-07-24 13:38:04 +0200
Processing by WelcomeController#index as HTML
WARNING: Can't mass-assign protected attributes for Setting: name
        app/models/setting.rb:173:in `find_or_default'
        app/models/setting.rb:108:in `[]'
        app/models/setting.rb:141:in `rest_api_enabled?'
        app/controllers/application_controller.rb:106:in `find_current_user'
        app/controllers/application_controller.rb:87:in `user_setup'
Completed 500 Internal Server Error in 3ms

NoMethodError (undefined method `[]' for nil:NilClass):
  app/models/setting.rb:95:in `value'
  app/models/setting.rb:108:in `[]'
  app/models/setting.rb:141:in `rest_api_enabled?'
  app/controllers/application_controller.rb:106:in `find_current_user'
  app/controllers/application_controller.rb:87:in `user_setup'

  • Firstly I remove version called in Gemfile for thos gems * rails * jquery-rails * i18n * coderay * fastercsv * builder
  • Secondly, I have added 3 gems (because remove on rails core, for fourth version of this framework). * gem "protected_attributes" * gem "actionpack-action_caching", github: "rails/actionpack-action_caching" * gem "rails-observer"
  • Thirdly, I have added config.eager_load to config/environments/*.rb (true on production, false on else)
  • Fourthly (and I'm not sure of this), I have remove 3 migrations (I have ot skill to rewrite them) * 105_build_projects_tree.rb * 018_set_doc_and_files_notifications.rb * 20110228000100_copy_repositories_log_encoding.rb

Have you ever tried to migrate redmine to rails 4


Related issues

Related to Redmine - Feature #15367: Replace outdated awesome_nested_set by gemClosed

Actions
Related to Redmine - Feature #14371: Drop Ruby 1.8.7 supportClosed

Actions
Related to Redmine - Feature #12097: Multi Thread SupportClosed

Actions
Related to Redmine - Defect #18174: Rails-4.1 branch merge into trunk (r13482) reverts trunk commitsClosedJean-Philippe Lang

Actions
Related to Redmine - Defect #18192: LDAP tests not running with Rails 4.1ClosedJean-Philippe Lang

Actions
Related to Redmine - Defect #18429: Error raised on project settings after project wiki is deletedClosedJean-Philippe Lang

Actions
Related to Redmine - Defect #18275: First argument in form cannot contain nil or be empty error on revision viewClosedJean-Philippe Lang

Actions
Has duplicate Redmine - Feature #14907: Rails 4.0 SupportClosed

Actions
Actions #1

Updated by Toshi MARUYAMA over 10 years ago

  • Subject changed from Running redmine on rails 4 to Rails 4 porting
  • Priority changed from Urgent to Normal
Actions #2

Updated by Sergiy Nazarov over 10 years ago

#14907 - migrate redmine to rails 4

Actions #3

Updated by Toshi MARUYAMA over 10 years ago

Actions #4

Updated by Toshi MARUYAMA over 10 years ago

Actions #5

Updated by Toshi MARUYAMA over 10 years ago

Actions #6

Updated by Ondřej Surý over 10 years ago

Hi,

just checking if there's a plan to add the Rails 4 support yet to do some next-stable Debian release planning.

New rack 1.5 broke rails-3.2, and we would really like to release next stable Debian with as latest rails release as possible by our reverse dependencies.

There's still some time left (about a year) before the archive is frozen, but I would like to be assured that everything will be solved by that time.

Thanks,
O.

Actions #7

Updated by Toshi MARUYAMA over 10 years ago

Actions #8

Updated by Toshi MARUYAMA over 10 years ago

Actions #9

Updated by Toshi MARUYAMA over 10 years ago

I rebased on r12470.

These are unit test results.

Rais4 uses strong parameter by default.
But, Redmine has many ActiveRecord.new and ActiveRecord.create at tests.
For examples: source:tags/2.4.2/test/unit/issue_test.rb#L52

So, I use config.active_record.whitelist_attributes = false.

Actions #10

Updated by Toshi MARUYAMA over 10 years ago

I rebased on r12644.

I removed almost all deprecating warnings.
But, awesome_nested_set and acts_as_activity_provider have many deprecating warnings.
So, I use ActiveSupport::Deprecation.silence.

  ActiveSupport::Deprecation.silence do
    scope.all(provider_options[:find_options].dup)
  end

awesome_nested_set master branch requires Rails4.
https://travis-ci.org/marutosi/redmine/builds/16771785

Redmine on Rails3 tests fail on awesome_nested_set 2-1-stable branch.
https://travis-ci.org/marutosi/redmine/builds/16771672

Actions #11

Updated by Toshi MARUYAMA about 10 years ago

  • Related to Feature #15367: Replace outdated awesome_nested_set by gem added
Actions #12

Updated by Jean-Philippe Lang about 10 years ago

  • Subject changed from Rails 4 porting to Upgrade to Rails 4
  • Target version set to 3.0.0
Actions #13

Updated by Toshi MARUYAMA about 10 years ago

I rebased on trunk r12884.

Previous revision uses awesome_nested_set 2.1.6 removing Rails4 deprecate warning.

Gemfile:

gem "awesome_nested_set",
    :git => "git://github.com/marutosi/awesome_nested_set.git",
    # PR 230, 231 and 232
    :ref => "4c4fdfe80f7451b" 

So, DB migration of PostgreSQL fails.
https://travis-ci.org/marutosi/redmine/jobs/18922993

== 105 BuildProjectsTree: migrating ===========================================

rake aborted!

An error has occurred, this and all later migrations canceled:

PG::GroupingError: ERROR: column "projects.id" must appear
 in the GROUP BY clause or be used in an aggregate function

LINE 1: ...lft" HAVING COUNT("projects"."lft") > 1 ORDER BY "projects"...
^

: SELECT "projects"."lft", COUNT("projects"."lft") FROM "projects" 
 GROUP BY "projects"."lft" HAVING COUNT("projects"."lft") > 1
 ORDER BY "projects"."id" ASC LIMIT 1
 /home/travis/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-702f3dca61f1/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:791:in `async_exec'

awesome_nested_set master branch and 2-1-stable branch have regression.

So, tests using awesome_nested_set master branch fails.
Actions #14

Updated by Jean-Philippe Lang about 10 years ago

Gemfile:

 gem "awesome_nested_set",
 :git => "git://github.com/marutosi/awesome_nested_set.git",
 # PR 230, 231 and 232
 :ref => "4c4fdfe80f7451b" 
 

I don't like that, we should either use the official gem or bundle it in Redmine as it was before with the appropriate fix.

Actions #16

Updated by Ondřej Surý almost 10 years ago

JFTR now that rails 4.1 is out - redmine should target rails 4.1 instead of rails 4.0.

Do you have any idea when that happens?

Actions #17

Updated by Jean-Philippe Lang almost 10 years ago

  • Subject changed from Upgrade to Rails 4 to Upgrade to Rails 4.1

4.1 indeed. It should happen in fall.

Actions #18

Updated by Jean-Philippe Lang almost 10 years ago

toshio harita, we're not targeting Rails 4.0. The branch /sandbox/rails-4.1 is working with Rails 4.1, please don't make changes for 4.0 compatibility/warnings.

Actions #19

Updated by Toshi MARUYAMA almost 10 years ago

Sorry.
I need feedback to Rails team that JPL fixed this Rails 4.0 issue.
https://github.com/rails/rails/issues/15471

And I need feedback to awesome_nested_set author.
https://github.com/collectiveidea/awesome_nested_set/pull/242

There is only one DEPRECATION WARNING on Rails 4.0.
https://travis-ci.org/marutosi/redmine/jobs/29510718#L2074

DEPRECATION WARNING: You didn't set config.secret_key_base.
Read the upgrade documentation to learn more about this new config option.
(called from env_config
 at /home/travis/.rvm/gems/ruby-1.9.3-p545/gems/railties-4.0.8/lib/rails/application.rb:141)

Actions #20

Updated by Toshi MARUYAMA almost 10 years ago

On r13312, some tests fail on Travis.
https://travis-ci.org/marutosi/redmine-bb/jobs/29816929

On my console, following test fails

$ ruby test/unit/issue_test.rb
  1) Failure:
IssueTest#test_visible_scope_for_member_with_groups_should_return_assigned_issues [test/unit/issue_test.rb:295]:
Failed assertion, no message given.
Actions #21

Updated by Saimon Lovell over 9 years ago

Any news on if RedMine will migrate to Rails 4.1?
So far there has been 3 updates (4.1.4) over time and changes are not feature breaking.
I would recommend now would be a good time to start migrating to rails 4.1

I am going to give it a shot and see how far I can go.

Actions #22

Updated by Toshi MARUYAMA over 9 years ago

Actions #23

Updated by Robert Weclawski over 9 years ago

Saimon Lovell wrote:

Any news on if RedMine will migrate to Rails 4.1?
So far there has been 3 updates (4.1.4) over time and changes are not feature breaking.
I would recommend now would be a good time to start migrating to rails 4.1

I am going to give it a shot and see how far I can go.

Hi Saimon,
any progress on that ? If you got some repo on github for that please let me know.
I would be quite happy if I could help.

--
Regards,
Robert

Actions #24

Updated by Toshi MARUYAMA over 9 years ago

Robert Weclawski wrote:

any progress on that ? If you got some repo on github for that please let me know.

Actions #25

Updated by Toshi MARUYAMA over 9 years ago

Actions #26

Updated by Toshi MARUYAMA over 9 years ago

Actions #27

Updated by Jean-Philippe Lang over 9 years ago

  • Related to Defect #18174: Rails-4.1 branch merge into trunk (r13482) reverts trunk commits added
Actions #28

Updated by Jean-Philippe Lang over 9 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed
Actions #29

Updated by Jean-Philippe Lang over 9 years ago

  • Related to Defect #18192: LDAP tests not running with Rails 4.1 added
Actions #30

Updated by Jean-Philippe Lang over 9 years ago

  • Related to Defect #18429: Error raised on project settings after project wiki is deleted added
Actions #31

Updated by Jean-Philippe Lang over 9 years ago

  • Related to Defect #18275: First argument in form cannot contain nil or be empty error on revision view added
Actions #32

Updated by Jean-Philippe Lang over 9 years ago

  • Subject changed from Upgrade to Rails 4.1 to Upgrade to Rails 4.2
  • Status changed from Closed to Reopened

Rails 4.2 is about to be released and will be the last 4.x branch. When Rails 5 is out, only Rails 4.2 will get bug fixes (security fixes only for previous versions). So we should target Rails 4.2 for Redmine 3.x.

Actions #33

Updated by Jean-Philippe Lang over 9 years ago

I've done the upgrade to Rails 4.2 (not yet committed) but there are still some issues:

  • the rbpdf gem uses ActionView::Base.sanitized_allowed_css_properties= which is deprecated in Rails 4.2
Actions #34

Updated by Toshi MARUYAMA over 9 years ago

Jean-Philippe Lang wrote:

I reported awesome_nested_set 3.0.1 break Redmine.
https://github.com/collectiveidea/awesome_nested_set/issues/280

Actions #35

Updated by Toshi MARUYAMA over 9 years ago

  • Resolution deleted (Fixed)
Actions #36

Updated by Jean-Philippe Lang over 9 years ago

Toshi MARUYAMA wrote:

I reported awesome_nested_set 3.0.1 break Redmine.
https://github.com/collectiveidea/awesome_nested_set/issues/280

The error you reported should be fixed in Redmine.

The error with awesome_nested_set 3.0.1 and Rails4.2 is: NoMethodError: undefined method `join_sql' for #<Arel::SelectManager:0xa907c58>. #join_sql was replaced in the above commit:
https://github.com/collectiveidea/awesome_nested_set/commit/2f3f28baf71f4964cedcc2548b51e2a4671e8e10

Actions #37

Updated by Mischa The Evil about 9 years ago

Jean-Philippe Lang wrote:

I've done the upgrade to Rails 4.2 (not yet committed) but there are still some issues:

This is no longer an issue due to #18860.

  • the rbpdf gem uses ActionView::Base.sanitized_allowed_css_properties= which is deprecated in Rails 4.2

I've relayed this issue to Jun as https://github.com/naitoh/rbpdf/issues/8.

Actions #38

Updated by Toshi MARUYAMA about 9 years ago

On r13893, PostgreSQL migration fails.

https://travis-ci.org/marutosi/redmine-bb/jobs/47402990#L1278

== 20091114105931 AddViewIssuesPermission: migrating ==========================

rake aborted!

StandardError: An error has occurred, this and all later migrations canceled:

can't convert Symbol into String
/home/travis/build/marutosi/redmine-bb/app/models/role.rb:99:in `include?'
Actions #39

Updated by Toshi MARUYAMA about 9 years ago

I have created issue on Rails GitHub.

Rails 4.2 SQLite3 regression: Encoding::UndefinedConversionError: "\xE9" from ASCII-8BIT to UTF-8
https://github.com/rails/rails/issues/18580

Actions #40

Updated by Jean-Philippe Lang about 9 years ago

I've reported another regression with sqlite:
https://github.com/rails/rails/issues/18585

Actions #41

Updated by Toshi MARUYAMA about 9 years ago

On console, IssueTest#test_visible_scope_for_member_with_groups_should_return_assigned_issues always fails.

  1) Failure:
IssueTest#test_visible_scope_for_member_with_groups_should_return_assigned_issues [test/unit/issue_test.rb:324]:
Failed assertion, no message given.

Actions #42

Updated by Jun NAITOH about 9 years ago

Mischa The Evil wrote:

Jean-Philippe Lang wrote:

  • the rbpdf gem uses ActionView::Base.sanitized_allowed_css_properties= which is deprecated in Rails 4.2

I've relayed this issue to Jun as https://github.com/naitoh/rbpdf/issues/8.

This problem fixed by rbpdf 1.18.5.
please bundle update.

Actions #43

Updated by Jean-Philippe Lang about 9 years ago

Jun NAITOH wrote:

This problem fixed by rbpdf 1.18.5.
please bundle update.

Gemfile updated to ~>1.18.5, thanks!

Actions #44

Updated by Jean-Philippe Lang about 9 years ago

  • Status changed from Reopened to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

SQLServer compatibility is now fixed.

Actions #45

Updated by Toshi MARUYAMA about 9 years ago

This issue is closed and we dropped awesome_nested_set gem (#18860) in 3.0.0.
But I record some my works.

Jean-Philippe Lang wrote:

Toshi MARUYAMA wrote:

I reported awesome_nested_set 3.0.1 break Redmine.
https://github.com/collectiveidea/awesome_nested_set/issues/280

The error you reported should be fixed in Redmine.

Following change fixes on Redmine trunk r13839 (last trunk revision with awesome_nested_set)
with awesome_nested_set 3.0.1.

diff --git a/app/models/issue.rb b/app/models/issue.rb
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -185,7 +185,7 @@ class Issue < ActiveRecord::Base
   # the lock_version condition should not be an issue but we handle it.
   def destroy
     super
-  rescue ActiveRecord::RecordNotFound
+  rescue ActiveRecord::StaleObjectError, ActiveRecord::RecordNotFound
     # Stale or already deleted
     begin
       reload

But awesome_nested_set 3.0.2 breaks Redmine.

  1) Error:
IssueTest#test_visible_and_nested_set_scopes:
ActiveRecord::ActiveRecordError: Impossible move, target node cannot be inside moved tree.
    app/models/issue.rb:1374:in `update_nested_set_attributes'
    app/models/issue.rb:173:in `create_or_update'
    test/object_helpers.rb:93:in `generate!'
    test/unit/issue_test.rb:360:in `test_visible_and_nested_set_scopes'

This is caused by this change.
https://github.com/collectiveidea/awesome_nested_set/commit/87d8c7cc94eadf08

Actions #46

Updated by Etienne Massip over 8 years ago

Jean-Philippe Lang wrote:

SQLServer compatibility is now fixed.

As Toshi noticed (Redmine 3.0 problem with MSSQL 2008) they chose to break compatibility with MSSQL < 2012 which is a bit brutal.

Specifying Rails ~> 4.1 in Gemfile seems to do the trick with trunk @ r14520, do you know if some of the changes that were made when switching from 4.1 to 4.2 aren't 4.1 compatible?

Actions #47

Updated by Toshi MARUYAMA over 8 years ago

Etienne Massip wrote:

Specifying Rails ~> 4.1 in Gemfile seems ...

FTR: #20603

Actions

Also available in: Atom PDF