Upgrade and ActiveRecord::RecordNotFound error
Added by Otto Krebs about 8 years ago
Hi everyone,
I have been using 2.4.1 and now want to upgrade to latest version.
I have succesfully upgraded test system, but now I have a problem with some plugins. I have an error in log file:
ActiveRecord::RecordNotFound (Couldn't find all Users with 'id': (first, {:conditions=>["lower(uid) = ?", "username@domain.name"]}) [WHERE "users"."type" IN ('User', 'AnonymousUser')] (found 0 results, but was looking for 2)):
plugins/redmine_cas/lib/redmine_cas.rb:224:in `login_with_cas'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
In ruby file there are following lines:user = User.find(:first, :conditions => [ "lower(uid) = ?", session[:cas_extra_attributes][:userPrincipalName].to_s.downcase ])
Here we find first user with parameter "uid" equals userPrincipalName, and I suppose that API has changed between versions so I have now error here.
I have found an article with patch to another plugin with code like -<% Mention.find(:all,
- :conditions => { :mentioned_id => @user.id },
- :order => "created_on DESC").each do |mention|
+<% Mention.where(mentioned_id: @user.id).order(created_on: :desc).find_each do |mention|
and tried to do alike:user = User.where(uid: session[:cas_extra_attributes][:userPrincipalName].to_s.downcase).limit(1)
but this caused different error:NoMethodError (undefined method `uid=' for #<ActiveRecord::Relation []>):
plugins/redmine_cas/lib/redmine_cas.rb:227:in `login_with_cas'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
I can't remove this plugin because we have user authorization through it and didn't found any update or activity on github page of this plugin.
Unfortunately I'm not ruby programmer and I have found no solution in internet.
Can anybody explain me how I must change this code to work in 3.3.1 version?