Skip to content
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

Internal Error : ArgumentError (wrong number of arguments (1 for 0)) #49

Open
okobloko opened this issue Nov 21, 2014 · 5 comments
Open

Comments

@okobloko
Copy link

After upgrading to redmine 2.5.2.devel and cloning the git repo, navigating to the timesheet page I get an "Internal Error". In production.log it says : ArgumentError (wrong number of arguments (1 for 0)):
/usr/lib/ruby/vendor_ruby/active_record/scoping/named.rb:24:in all' plugins/redmine_timesheet_plugin/app/controllers/timesheet_controller.rb:118:inget_activities'

the get_activities function has a single line :
def get_activities
@activities = TimeEntryActivity.all(:conditions => 'parent_id IS NULL')
end

The problem is the TimeEntryActivity.all(:conditions => 'parent_id IS NULL') ... and I can't see why :-(

Can anybody see a solution to this? Writing invoices has turned into a bit of a nightmare of late!

@hishammalik
Copy link
Member

try using the stable redmine version

@okobloko
Copy link
Author

Unless I'm mistaken the only redmine package available for jessie (whether using apt-cache madison/show) is currently :

redmine | 3.0~20140825-1 | http://ftp.de.debian.org/debian/ jessie/main amd64 Packages

...which isn't going to help much. I'm guessing this is probably due to the various security patches which have been flowing through recently. I remember trying to get the stable version working from source a while ago, without success.

I'm feeling stuck between a rock and a hard place.

@okobloko
Copy link
Author

So, it seems the problem is that many calls in the plugin need to be upgraded to Rails 4. The old Rails 2 style of querying ActiveRecord is no longer valid. Pity, because I haven't touched Ruby in years. I've made a start, and this will need to be done by somebody at some point anyway. Anybody else want to take a look into modernising the code as well?

@okobloko
Copy link
Author

For example : the index screen now displays. The following lines in timesheet_controller.rb needed to be changed :
[code]
def get_activities
#@activities = TimeEntryActivity.all(:conditions => 'parent_id IS NULL')
@activities = TimeEntryActivity.where(parent_id: nil).all
end

def allowed_projects
if User.current.admin?
#return Project.find(:all, :order => 'name ASC')
return Project.order("name ASC").all
else
#return Project.find(:all, :conditions => Project.visible_condition(User.current), :order => 'name ASC')
return Project.where(Project.visible_condition(User.current)).order("name ASC").all
end
end
[/code]

But this process needs to be continued for every action

@okobloko
Copy link
Author

in the timesheet.rb model

def time_entries_for_all_users(project)
#return project.time_entries.find(:all,
# :conditions => self.conditions(self.users),
# :include => self.includes,
# :order => "spent_on ASC")
return project.time_entries.where(self.conditions(self.users)).order("spent_on ASC").includes(self.includes).all
end

AND ------

def initialize(options = { })
self.projects = [ ]
self.time_entries = options[:time_entries] || { }
self.potential_time_entry_ids = options[:potential_time_entry_ids] || [ ]
self.allowed_projects = options[:allowed_projects] || [ ]
self.groups = [ ]

unless options[:activities].nil?
  self.activities = options[:activities].collect do |activity_id|
    # Include project-overridden activities
    activity = TimeEntryActivity.find(activity_id)
    #project_activities = TimeEntryActivity.all(:conditions => ['parent_id IN (?)', activity.id]) if activity.parent_id.nil?
    project_activities = TimeEntryActivity.where(parent_id: activity.id).all if activity.parent_id.nil?

in the initialize method... and it works with ActiveRecord4

Thanks to David Workman, the Ruby/Rails guru who explained how to do the migration (and pointed out how much work it would take to do it properly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants