jzaiat / redshares

Redmine Plugin to share issues with other users

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to add shares

opened this issue · comments

I just installed the plugin on the following environment.
Environment:
Redmine version 2.3.3.stable
Ruby version 1.9.3-p484 (2013-11-22) [i686-linux]
Rails version 3.2.13
Environment production
Database adapter Mysql2
Redmine plugins:
my_projects 1.0
redmine_contacts 3.2.7-light
redmine_contacts_invoices 2.2.2-light
redmine_finance 1.0.5-light
redmine_issue_checklist 2.0.5
redmine_people 0.1.6
redmine_update_reminder 1.0.1
redshares 1.0.0

I believe I have configured everything correctly, and I am able to see the Shares button on the sidebar for my issue. However, when I try to ADD a share, I see the "Loading" but nothing else happens

Firebug console is giving the following error:

GET http://pm.jmdezigns.com/redshares/new?object_id=30&object_type=issue 500 (Internal Server Error) jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:2
send jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:2
v.extend.ajax jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:2
a.rails.d.ajax jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:11
a.rails.d.handleRemote jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:11
(anonymous function) jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:11
v.event.dispatch jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:2
o.handle.u jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js?1379141328:2

Everything else seems to be working fine with my Redmine installation. So not sure if issue is specific to RedShares or general to Redmine.

Same issue here.

Environment:
Redmine version 2.3.3.stable
Ruby version 1.9.3-p448 (2013-06-27) [x86_64-linux]
Rails version 3.2.13
Environment production
Database adapter Mysql2
Redmine plugins:
redmine_bitbucket 0.2.0
redmine_code_review 0.6.3
redmine_github_hook 0.2.0
redshares 1.0.0

I also receive 500 Internal Server error when going to the configuration page of plugin with this in log:

Completed 500 Internal Server Error in 7.8ms

NoMethodError (undefined method plugin_redshares' for #<Class:0x00000004d84a88>): app/controllers/settings_controller.rb:69:inplugin'

Same issue here.

Environment:
    Redmine version                2.5.1.stable
    Ruby version                   2.1.0-p0 (2013-12-25) [x86_64-linux]
    Rails version                  3.2.17
    Environment                    production
    Database adapter               Mysql2

Log error:

  Started GET "/redshares/new?object_id=65&object_type=issue" for 192.168.32.100 at 2014-03-30 19:55:35 +0100
  Processing by RedsharesController#new as JS
    Parameters: {"object_id"=>"65", "object_type"=>"issue"}
    Current user: michael.pinheiro (id=2064)
    Rendered plugins/redshares/app/views/redshares/_new.html.erb (24.1ms)
    Rendered plugins/redshares/app/views/redshares/new.js.erb (24.7ms)
  Completed 500 Internal Server Error in 37.9ms

    ActionView::Template::Error (undefined method `id' for nil:NilClass):
    18:                  :project_id => @project) }')" %>
    19: 
    20:   <div id="users_for_redshare">
    21:     <%= principals_check_box_tags 'redshare[user_ids][]', (redshared ? redshared.addable_redshare_users : nil) %>
    22:   </div>
    23:   
    24:   <div id="roles_for_redshare">
  app/helpers/application_helper.rb:367:in `block in principals_check_box_tags'
  app/helpers/application_helper.rb:366:in `each'
  app/helpers/application_helper.rb:366:in `principals_check_box_tags'

I found out that the retrieved list of users contains a nil value (first element) that is causing the problem. I managed to solve this issue by editing files:

  • plugins/redshares/app/views/redshares/_new.html.erb
...
<div id="users_for_redshare">
    <%= principals_check_box_tags( 'redshare[user_ids][]', (redshared ? redshared.addable_redshare_users.reject!(&:nil?) : nil) ) %>
  </div>
...
  • plugins/redshares/app/controllers/redshares_controller.rb
...
def autocomplete_for_user
    if @redshared
      @users = @redshared.addable_redshare_users
      q = params[:q].to_s.downcase
      q = q == '' ? ' ' : q
      @users = @users.select{|u| u.to_s.downcase.include?(q)}
    end
    render :layout => false
  end
...

I try the patch by mickael83 but it seems not working for my redmine (2.6.5, ruby 2, rails 3.2). Then I fix it this way and it seems OK

  1. Use the original distribution (without mickael83 patch)
  2. in the file lib/acts_as_redshareable.rb, I replace the method addable_redshare_users by this new one
    def addable_redshare_users
      filter_roles ||= Setting.plugin_redshares['roles']
      valid_users ||= []          
      self.project.members.each do |member|       # Get all members from Project and loop through them
        member.roles.each do |role|
          if filter_roles.include? role.id.to_s   # Member is in shareable roles                
            valid_users << member.user
           end
        end
      end   
      valid_users.uniq!                           #remove duplicates          
      valid_users.delete self.assigned_to         #disallow to redshare to assigned
      users = valid_users - self.redshare_users

      users

    end