Project

General

Profile

Actions

Feature #14534

closed

Upgrade to Rails 4.2

Feature #14534: Upgrade to Rails 4.2

Added by Marwan Rabbaa over 13 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Normal
Category:
Rails support
Target version:
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 8 (0 open — 8 closed)

Related to Redmine - Feature #15367: Replace outdated awesome_nested_set by gemClosedActions
Related to Redmine - Feature #14371: Drop Ruby 1.8.7 supportClosedActions
Related to Redmine - Feature #12097: Multi Thread SupportClosedActions
Related to Redmine - Defect #18174: Rails-4.1 branch merge into trunk (r13482) reverts trunk commitsClosedJean-Philippe LangActions
Related to Redmine - Defect #18192: LDAP tests not running with Rails 4.1ClosedJean-Philippe LangActions
Related to Redmine - Defect #18429: Error raised on project settings after project wiki is deletedClosedJean-Philippe LangActions
Related to Redmine - Defect #18275: First argument in form cannot contain nil or be empty error on revision viewClosedJean-Philippe LangActions
Has duplicate Redmine - Feature #14907: Rails 4.0 SupportClosedActions

Updated by Toshi MARUYAMA over 13 years ago Actions #1

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

Updated by Sergiy Nazarov about 13 years ago Actions #2

#14907 - migrate redmine to rails 4

Updated by Toshi MARUYAMA about 13 years ago Actions #3

Updated by Toshi MARUYAMA about 13 years ago Actions #4

Updated by Toshi MARUYAMA about 13 years ago Actions #5

Updated by Ondřej Surý about 13 years ago Actions #6

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.

Updated by Toshi MARUYAMA almost 13 years ago Actions #7

Updated by Toshi MARUYAMA almost 13 years ago Actions #8

Updated by Toshi MARUYAMA almost 13 years ago Actions #9

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.

Updated by Toshi MARUYAMA almost 13 years ago Actions #10

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

Updated by Toshi MARUYAMA almost 13 years ago Actions #11

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

Updated by Jean-Philippe Lang almost 13 years ago Actions #12

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

Updated by Toshi MARUYAMA almost 13 years ago Actions #13

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.

Updated by Jean-Philippe Lang almost 13 years ago Actions #14

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.

Updated by Ondřej Surý over 12 years ago Actions #16

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?

Updated by Jean-Philippe Lang over 12 years ago Actions #17

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

4.1 indeed. It should happen in fall.

Updated by Jean-Philippe Lang over 12 years ago Actions #18

@Toshi, 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.

Updated by Toshi MARUYAMA over 12 years ago Actions #19

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)

Updated by Toshi MARUYAMA over 12 years ago Actions #20

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.

Updated by Saimon Lovell over 12 years ago Actions #21

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.

Updated by Toshi MARUYAMA over 12 years ago Actions #22

Updated by Robert Weclawski about 12 years ago Actions #23

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

Updated by Toshi MARUYAMA about 12 years ago Actions #24

Robert Weclawski wrote:

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

Updated by Toshi MARUYAMA about 12 years ago Actions #25

Updated by Toshi MARUYAMA about 12 years ago Actions #26

Updated by Jean-Philippe Lang about 12 years ago Actions #27

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

Updated by Jean-Philippe Lang about 12 years ago Actions #28

  • Status changed from New to Closed
  • Resolution set to Fixed

Updated by Jean-Philippe Lang about 12 years ago Actions #29

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

Updated by Jean-Philippe Lang almost 12 years ago Actions #30

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

Updated by Jean-Philippe Lang almost 12 years ago Actions #31

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

Updated by Jean-Philippe Lang almost 12 years ago Actions #32

  • 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.

Updated by Jean-Philippe Lang almost 12 years ago Actions #33

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

Updated by Toshi MARUYAMA almost 12 years ago Actions #34

Jean-Philippe Lang wrote:

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

Updated by Toshi MARUYAMA almost 12 years ago Actions #35

  • Resolution deleted (Fixed)

Updated by Jean-Philippe Lang almost 12 years ago Actions #36

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

Updated by Mischa The Evil almost 12 years ago Actions #37

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.

Updated by Toshi MARUYAMA almost 12 years ago Actions #38

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?'

Updated by Toshi MARUYAMA almost 12 years ago Actions #39

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

Updated by Jean-Philippe Lang almost 12 years ago Actions #40

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

Updated by Toshi MARUYAMA almost 12 years ago Actions #41

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.

Updated by Jun NAITOH almost 12 years ago Actions #42

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.

Updated by Jean-Philippe Lang almost 12 years ago Actions #43

Jun NAITOH wrote:

This problem fixed by rbpdf 1.18.5.
please bundle update.

Gemfile updated to ~>1.18.5, thanks!

Updated by Jean-Philippe Lang almost 12 years ago Actions #44

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

SQLServer compatibility is now fixed.

Updated by Toshi MARUYAMA almost 12 years ago Actions #45

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

Updated by Etienne Massip over 11 years ago Actions #46

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?

Updated by Toshi MARUYAMA about 11 years ago Actions #47

Etienne Massip wrote:

Specifying Rails ~> 4.1 in Gemfile seems ...

FTR: #20603

Actions

Also available in: PDF Atom