NoMethodError (undefined method `username` and `email`) in project_wiki.rb
Environment
I've installed GitLab CE 8.7.0-ce.0
on Ubuntu 14.04 with the instruction. The only change I have made on GitLab CE after installation is to disable bundled Nginx and using my own Nginx.
Problem 1
When I post a page on Wiki, it throws a 500
error.
Looking into production.log
, says:
Processing by Projects::WikisController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "wiki"=>{"title"=>"home", "format"=>"markdown", "content"=>"asdf", "message"=>""}, "namespace_id"=>"MoNet", "project_id"=>"Atheros-CSI-Tool"}
Completed 500 Internal Server Error in 40ms (ActiveRecord: 3.0ms)
NoMethodError (undefined method `username' for #<Group:0x00000011d78f50>):
app/models/project_wiki.rb:158:in `default_message'
app/models/project_wiki.rb:152:in `commit_details'
app/models/project_wiki.rb:91:in `create_page'
app/models/wiki_page.rb:183:in `save'
app/models/wiki_page.rb:143:in `create'
app/services/wiki_pages/create_service.rb:6:in `execute'
app/controllers/projects/wikis_controller.rb:58:in `create'
lib/gitlab/middleware/go.rb:16:in `call'
Solution of 1
I've solved this by replacing@user.username
with @user.name
in project_wiki.rb:158
Problem 2
Yet, another problem appears.
Processing by Projects::WikisController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "wiki"=>{"title"=>"home", "format"=>"markdown", "content"=>"asdf", "message"=>""}, "namespace_id"=>"MoNet", "project_id"=>"Atheros-CSI-Tool-Documentation"}
Completed 500 Internal Server Error in 41ms (ActiveRecord: 4.6ms)
NoMethodError (undefined method `email' for #<Group:0x000000074b9888>):
app/models/project_wiki.rb:154:in `commit_details'
app/models/project_wiki.rb:91:in `create_page'
app/models/wiki_page.rb:183:in `save'
app/models/wiki_page.rb:143:in `create'
app/services/wiki_pages/create_service.rb:6:in `execute'
app/controllers/projects/wikis_controller.rb:58:in `create'
lib/gitlab/middleware/go.rb:16:in `call'
(Tentative) Workaround of 2
But my naive guess @user.mail
does not solve the problem. Thus, currently, I made a workaround. I've commented out the original statement and put a placeholder for email address:
# { email: @user.email, name: @user.name, message: commit_message }
{ email: "Disabled currently", name: @user.name, message: commit_message }
I am not sure this rarely happens.