snnrk / redmine_mailwrapper

Plugin for Redmine to rewrite mail according to rules for each projects.
12 stars 1 forks source link

500 error creating a new recipient #1

Closed javiruj closed 11 years ago

javiruj commented 12 years ago

Hi

I've tried to install the plugin following the standard of redmine (rake db:migrate_plugins RAILS_ENV=..., restarting the server...). I've enabled the module for one project and gone to the settings tab.

When I've created a new sender I have no problems but when I've tried to create a new recipient I've obtained a 500 error. The log:

Processing MailwrapperRecipientsController#add (for x.x.x.x at 2012-02-23 13:44:54) [GET]
  Parameters: {"project_id"=>"sistem-9", "action"=>"add", "controller"=>"mailwrapper_recipients"}
Rendering template within layouts/base
Rendering mailwrapper_recipients/add

ActionView::TemplateError (PGError: ERROR:  column "User" does not exist
LINE 1: ...users.type='User' AND users.status=1)) AND (type = "User")) 
                                                          ^
: SELECT "members"."id" AS t0_r0, "members"."user_id" AS t0_r1, "members"."project_id" AS t0_r2, "members"."created_on" AS t0_r3, "members"."mail_notification" AS t0_r4, "users"."id" AS t1_r0, "users"."login" AS t1_r1, "users"."hashed_password" AS t1_r2, "users"."firstname" AS t1_r3, "users"."lastname" AS t1_r4, "users"."mail" AS t1_r5, "users"."admin" AS t1_r6, "users"."status" AS t1_r7, "users"."last_login_on" AS t1_r8, "users"."language" AS t1_r9, "users"."auth_source_id" AS t1_r10, "users"."created_on" AS t1_r11, "users"."updated_on" AS t1_r12, "users"."type" AS t1_r13, "users"."identity_url" AS t1_r14, "users"."mail_notification" AS t1_r15, "users"."salt" AS t1_r16 FROM "members"  LEFT OUTER JOIN "users" ON "users".id = "members".user_id WHERE ("members".project_id = 5 AND (users.type='Group' OR (users.type='User' AND users.status=1)) AND (type = "User")) ) on line #2 of vendor/plugins/redmine_mailwrapper/app/views/mailwrapper_recipients/_form.html.erb:
1: <%= error_messages_for 'mailwrapper_recipient' %>
2: <% members = @project.member_principals.find(:all, :conditions => ['type = "User"']).sort %>
3: <p><%= f.text_field :name %></p>
4: <p>
5:   <%= f.label :user_ids %>

vendor/plugins/redmine_mailwrapper/app/views/mailwrapper_recipients/_form.html.erb:2
vendor/plugins/redmine_mailwrapper/app/views/mailwrapper_recipients/add.html.erb:4
app/helpers/application_helper.rb:871:in `labelled_tabular_form_for'
vendor/plugins/redmine_mailwrapper/app/views/mailwrapper_recipients/add.html.erb:3
config/initializers/mongrel.rb:62:in `dispatch_cgi'

Rendering .../public/500.html (500 Internal Server Error)

Processing MailwrapperSendersController#mod (for x.x.x.x at 2012-02-23 13:45:03) [GET]
  Parameters: {"project_id"=>"sistem-9", "action"=>"mod", "sender_id"=>"1", "controller"=>"mailwrapper_senders"}
Rendering template within layouts/base
Rendering mailwrapper_senders/mod
Completed in 62ms (View: 47, DB: 0) | 200 OK [http://redmine.company.com/mailwrapper_senders/mod?project_id=sistem-9&sender_id=1]

Redmine Version: 1.3.0 Database: Postgresql 8.3

Thanks for the plugin.

snnrk commented 12 years ago

Although I tested again, it was not reproduced on Redmine 1.3.0 with MySQL 5.0.45. It seems that it is due to the difference in behavior of MySQL and Postgresql. So I will make environment (with Postgresql) and to test whether it is reproduced or not.

chupacabras commented 12 years ago

I am running Redmine 1.4.1 on Postgresql 8.4 and I see "500" error as well. When I assign "mailwrapper" module to any project than I am not able to display settings of that project:

Processing ProjectsController#settings (for 192.168.1.77 at 2012-05-09 21:23:54) [GET] Parameters: {"id"=>"redmine", "action"=>"settings", "controller"=>"projects"} Rendering template within layouts/base Rendering projects/settings

ActionView::TemplateError (No route matches {:controller=>"mailwrapper_recipients", :action=>"add", :project_id=>#<Project id: 4, name: "redmine system", description: "Všetko čo súvisí s používaním Redmine", homepage: "", is_public: true, parent_id: nil, created_on: "2011-11-23 12:40:45", updated_on: "2011-11-28 20:00:30", identifier: "redmine", status: 1, lft: 47, rgt: 48>}) on line #38 of vendor/plugins/mailwrapper/app/views/mailwrapper_recipients/_show.html.erb: 35: 36: 37: <% end %> 38:

<%= link_to_if_authorized l(:label_mailwrapper_recipient_new), {:controller => 'mailwrapper_recipients', :action => 'add', :project_id => @project} %>

39: 40:

app/helpers/application_helper.rb:43:in `link_to_if_authorized'
vendor/plugins/mailwrapper/app/views/mailwrapper_recipients/_show.html.erb:38
vendor/plugins/mailwrapper/app/views/mailwrapper_settings/_show.html.erb:6
app/views/common/_tabs.html.erb:24
app/views/common/_tabs.html.erb:23:in `each'
app/views/common/_tabs.html.erb:23
app/helpers/application_helper.rb:231:in `render_tabs'
app/views/projects/settings.html.erb:3
passenger (3.0.12) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.12) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.12) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
passenger (3.0.12) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.12) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.12) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
passenger (3.0.12) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.12) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.12) helper-scripts/passenger-spawn-server:99

Rendering /opt/redmine-single/public/500.html (500 Internal Server Error)

snnrk commented 12 years ago

Hi chupacabras,

I understand that problem. Current version of redmine_mailwrapper do not work with redmine-1.4.x because redmine_mailwrapper do not have definition of routing. I will fix this problem asap.

ghost commented 11 years ago

Problem is due to postgres interpreting "User" as reference to a table instead of a String literal. Changing :conditions => ['type = "User"'] to :conditions => ['type = ?', 'User'] in app/views/mailwrapper_issue_rules/_form.html.erb and app/views/mailwrapper_recipients/_form.html.erb solves the issue.

snnrk commented 11 years ago

Hi Tordmor,

I just got it. I will fix it later.

missedone commented 11 years ago

hi, snnrk

i got the same error

ActionView::Template::Error (PG::Error: ERROR:  column "User" does not exist
LINE 1: ... (users.type='User' AND users.status=1)) AND (type = "User")
                                                                ^
: SELECT "members"."id" AS t0_r0, "members"."user_id" AS t0_r1, "members"."project_id" AS t0_r2, "members"."created_on" AS t0_r3, "members"."mail_notification" AS t0_r4, "users"."id" AS t1_r0, "users"."login" AS t1_r1, "users"."hashed_password" AS t1_r2, "users"."firstname" AS t1_r3, "users"."lastname" AS t1_r4, "users"."mail" AS t1_r5, "users"."admin" AS t1_r6, "users"."status" AS t1_r7, "users"."last_login_on" AS t1_r8, "users"."language" AS t1_r9, "users"."auth_source_id" AS t1_r10, "users"."created_on" AS t1_r11, "users"."updated_on" AS t1_r12, "users"."type" AS t1_r13, "users"."identity_url" AS t1_r14, "users"."mail_notification" AS t1_r15, "users"."salt" AS t1_r16 FROM "members" LEFT OUTER JOIN "users" ON "users"."id" = "members"."user_id" WHERE "members"."project_id" = 1 AND (users.type='Group' OR (users.type='User' AND users.status=1)) AND (type = "User")):
    1: <%= error_messages_for 'mailwrapper_recipient' %>
    2: <% members = @project.member_principals.find(:all, :conditions => ['type = "User"']).sort %>
    3: <p><%= f.text_field :name, :required => true %></p>
    4: <p>
    5:   <%= f.hidden_field :project_id, :value => @project.id %>
  app/helpers/application_helper.rb:944:in `labelled_form_for'

my environment:

root@ubuntu:/opt/redmine# ruby script/about
Environment:
  Redmine version                          2.3.0.stable
  Ruby version                             1.9.3 (x86_64-linux)
  Rails version                            3.2.13
  Environment                              production
  Database adapter                         PostgreSQL
Redmine plugins:
  redmine_backlogs                         v0.9.37
  redmine_create_wiki_page                 0.1
  redmine_gitolite                         0.0.2
  redmine_jenkins                          2.1.0
  redmine_mailwrapper                      0.1.2
  redmine_release_notes                    1.3.1-beta
  redmine_tags                             2.0.1-dev
missedone commented 11 years ago

Tordmor's suggestion works for me, thanks

snnrk commented 11 years ago

I pulled missedone's commit into branch 0.1.2 on my repository. And, I'll merge it to master-branch after test on my environment.

snnrk commented 11 years ago

Now, I merged branch 0.1.2 into master.