ascendro / redmine_issue_reminder

Plugin for Redmine to create different role based reminders for a project
20 stars 48 forks source link

Redmine 2.3 (using redmine2.0 branch) - undefined method 'remote function' #29

Open akohlsmith opened 11 years ago

akohlsmith commented 11 years ago

rake db:migrate_plugins creates the table correctly (the README says db:migrate:plugins).

I can enable the module for a project, but when I click on the new "issues reminder" tab for the project, I get an HTTP 500 error and the production.log has the following and an ugly backtrace:

ActionView::Template::Error (undefined method `remote_function' for #<#<Class:0xc4a59c8>:0xbc918b8>):
    8:     <%= f.label l(:interval) %>:
    9:     <%= f.select :interval, reminders_intervals_for_options, {},
    10:           {:onchange => remote_function(:url  => {:action => "update_interval_values"},
    11:               :with => "'interval='+value +'&reminder_id=#{reminder.new_record? ? 'new' : reminder.id}'")}
    12:     %>
    13:   </p>
    14:     <%= render :partial => 'interval_values',

This is because remote_function was removed from Rails 3.1.

akohlsmith commented 11 years ago

I managed to get it working with some #rails help.

did a gem install prototype-rails to install the gem, then added

gem "prototype-rails"

to the Redmine Gemfile. Now that Redmine knows about it, I added

require 'prototype-rails'

to the list of requires in the plugin init.rb file. Now it will let me get into the issues reminder page, but I can't add any reminders, presumably because the query is empty and I can't add one.

akohlsmith commented 11 years ago

Just tried to see if a public custom query would show up, and it crashes out since rails 3.2 does not have link_to_remote; I changed it to link_to based on this and it seems to work!

akohlsmith commented 11 years ago

Patch attached.

diff --git a/app/views/reminders/index.html.erb b/app/views/reminders/index.html.erb
index dc9e010..86a4bdd 100644
--- a/app/views/reminders/index.html.erb
+++ b/app/views/reminders/index.html.erb
@@ -20,7 +20,7 @@
                                  "$('reminder-#{reminder.id}-edit').show(); return false;",
                                  :class => 'icon icon-edit' 
            %>
-             <%= link_to_remote(l(:button_delete), { :url => {:controller => 'reminders', :action => 'destroy', :id => reminder},
+             <%= link_to(l(:button_delete), { :url => {:controller => 'reminders', :action => 'destroy', :id => reminder},
                                               :method => :delete,
                                               :confirm => l(:reminder_delete_confirmation)
                                             }, :title => l(:button_delete),
diff --git a/init.rb b/init.rb
index 40612d9..278d01f 100644
--- a/init.rb
+++ b/init.rb
@@ -1,5 +1,6 @@
 require 'redmine'
 require 'active_support/core_ext'
+require 'prototype-rails'

 # This plugin should be reloaded in development mode.
 if Rails.env == 'development'
gyhor commented 10 years ago

even after patching the plugin there are errors. :( For example it isn't possible to change a reminder - nothing happens
or delete a reminder - 403 Error after http:host/reminders?confirm=Wollen+sie+diese+Erinnerung+wirklich+löschen%3F&method=delete&url[action]=destroy&url[controller]=reminders&url[id]=1

jcppkkk commented 10 years ago

Fixed delete function for Redmine 2.5.1.stable (Rails 3)

diff --git a/app/views/reminders/index.html.erb b/app/views/reminders/index.html.erb
index c1fe610..d25d210 100644
--- a/app/views/reminders/index.html.erb
+++ b/app/views/reminders/index.html.erb
@@ -20,11 +20,10 @@
                                  "$('reminder-#{reminder.id}-edit').show(); return false;",
                                  :class => 'icon icon-edit'
            %>
-            <%= link_to(l(:button_delete), { :url => {:controller => 'reminders', :action => 'destroy', :id => reminder},
-                                              :method => :delete,
-                                              :confirm => l(:reminder_delete_confirmation)
-                                            }, :title => l(:button_delete),
-                                               :class => 'icon icon-del')  %>
+        <%= link_to l(:button_delete),
+            {:controller => 'reminders', :action => :destroy, :id => reminder},
+            {:confirm => l(:reminder_delete_confirmation), :method => :delete, :remote => true, :title => l(:button_delete), :class => 'icon icon-del'}
+        %>
           </td>
         </tr>
         <tr id="reminder-<%= reminder.id %>-edit" style="display:none">