#1164: crash when user with custom domain visits another user.

Type: BugItem Feature:   Tags:  
ScheduledFor: N/A Assigned to:   Sites:  
Priority: 0 Status: Pending  

To reproduce:

  • add a custom domain to an user profile
  • login as that user.
  • Visit any other user homepage

This will also happen when visiting any community. The problem is that it tries to generate a URL under the user control panel using Profile#url, but since the profile URL parameter is nil in the case of custom domains, it founds no route. The solution is to move the "add friend" and "join community" actions to the Profile controller, i.e. these actions will be processed in the context of the profile being added or joined instead of the adding/joining user.

Log of the crash:

ActionView::TemplateError (No route matches {:action=>"add", :controller=>"friends", :profile=>nil, :page=>[], :id=>237}) on line #5 of blocks/profile_info_actions/person.rhtml:
2:   <%if logged_in? && (user != profile) %>
3: 
4:     <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %>
5:       <li><%= link_to content_tag('span', __('Add friend')), user.url.merge(:controller => 'friends', :action => 'add', :id => profile.id), :class => 'button with-text icon-add' %></li>
6:     <% end %>
7: 
8:     <% if user.is_a_friend?(profile) && profile.enable_contact? %>

    vendor/rails/actionpack/lib/action_controller/routing.rb:1408:in `generate'
    vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:124:in `rewrite_path'
    vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:103:in `rewrite_url'
    vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:81:in `rewrite'
    vendor/rails/actionpack/lib/action_controller/base.rb:616:in `url_for'
    vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:in `send'
    vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:in `url_for'
    vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:144:in `link_to'
    app/views/blocks/profile_info_actions/person.rhtml:5:in `_run_erb_47app47views47blocks47profile_info_actions47person46rhtml'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `send'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `compile_and_render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:365:in `render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:316:in `render_file_without_locale'
    /usr/lib/ruby/1.8/gettext/rails.rb:283:in `render_file'
    vendor/rails/actionpack/lib/action_view/base.rb:348:in `render'
    app/views/blocks/my_network.rhtml:14:in `_run_erb_47app47views47blocks47my_network46rhtml'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `send'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `compile_and_render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:365:in `render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:316:in `render_file_without_locale'
    /usr/lib/ruby/1.8/gettext/rails.rb:283:in `render_file'
    vendor/rails/actionpack/lib/action_view/base.rb:348:in `render'
    app/models/my_network_block.rb:23:in `content'
    app/helpers/boxes_helper.rb:117:in `instance_eval'
    app/helpers/boxes_helper.rb:117:in `extract_block_content'
    app/helpers/boxes_helper.rb:79:in `display_block_content'
    app/views/shared/block.rhtml:6:in `_run_erb_47app47views47shared47block46rhtml'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `send'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `compile_and_render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:365:in `render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:316:in `render_file_without_locale'
    /usr/lib/ruby/1.8/gettext/rails.rb:283:in `render_file'
    vendor/rails/actionpack/lib/action_view/base.rb:348:in `render'
    app/helpers/boxes_helper.rb:70:in `display_block'
    app/helpers/boxes_helper.rb:62:in `display_box_content'
    app/helpers/boxes_helper.rb:62:in `map'
    app/helpers/boxes_helper.rb:62:in `display_box_content'
    app/helpers/boxes_helper.rb:52:in `display_box'
    app/helpers/boxes_helper.rb:35:in `display_boxes'
    app/helpers/boxes_helper.rb:35:in `map'
    app/helpers/boxes_helper.rb:35:in `display_boxes'
    app/helpers/boxes_helper.rb:8:in `insert_boxes'
    app/views/layouts/application.rhtml:119:in `_run_erb_47app47views47layouts47application46rhtml'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `send'
    vendor/rails/actionpack/lib/action_view/base.rb:637:in `compile_and_render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:365:in `render_template'
    vendor/rails/actionpack/lib/action_view/base.rb:316:in `render_file_without_locale'
    /usr/lib/ruby/1.8/gettext/rails.rb:283:in `render_file'
    vendor/rails/actionpack/lib/action_controller/layout.rb:268:in `render_without_benchmark'
    vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
    vendor/rails/actionpack/lib/action_controller/base.rb:1153:in `default_render'
    vendor/rails/actionpack/lib/action_controller/base.rb:1159:in `perform_action_without_filters'
    vendor/rails/actionpack/lib/action_controller/filters.rb:697:in `call_filters'
    vendor/rails/actionpack/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'
    vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    vendor/rails/actionpack/lib/action_controller/rescue.rb:199:in `perform_action'
    vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
    vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'
    vendor/rails/actionpack/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
    vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in `process'
    vendor/rails/actionpack/lib/action_controller/base.rb:388:in `process'
    vendor/rails/actionpack/lib/action_controller/dispatcher.rb:171:in `handle_request'
    vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in `dispatch'
    vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
    vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in `dispatch'
    /usr/lib/ruby/1.8/mongrel/rails.rb:76:in `process'
    /usr/lib/ruby/1.8/mongrel/rails.rb:74:in `synchronize'
    /usr/lib/ruby/1.8/mongrel/rails.rb:74:in `process'
    /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'
    /usr/lib/ruby/1.8/mongrel.rb:158:in `each'
    /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'
    /usr/lib/ruby/1.8/mongrel.rb:285:in `run'
    /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'
    /usr/lib/ruby/1.8/mongrel.rb:285:in `new'
    /usr/lib/ruby/1.8/mongrel.rb:285:in `run'
    /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'
    /usr/lib/ruby/1.8/mongrel.rb:268:in `new'
    /usr/lib/ruby/1.8/mongrel.rb:268:in `run'
    /usr/lib/ruby/1.8/mongrel/configurator.rb:282:in `run'
    /usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `each'
    /usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `run'
    /usr/bin/mongrel_rails:129:in `run'
    /usr/lib/ruby/1.8/mongrel/command.rb:212:in `run'
    /usr/bin/mongrel_rails:282

Rendering /home/noosfero/zen3/public/500.html (500 Internal Server Error)

-- AntonioTerceiro -- 13 Jul 2009
Add comment
You need to login to be able to comment.
 

ActionItemForm edit

Title crash when user with custom domain visits another user.
ActionItemType BugItem
Priority Low
Tags
Feature
Plugin
ResponsibleDevelopers
ScheduledFor N/A
AffectsVersion
Status Pending
Ticket SAC:
Topic revision: r4 - 19 Jul 2012, DanielaFeitosa

irc Talk with Devs Now!

 
Translations: English
Search on Docs:
   
ActionItem Search:

Copyright © 2007-2018 by the Noosfero contributors
Colivre - Cooperativa de Tecnologias Livres