app/controllers/socials_controller.rb
# Accept/edit friends action.
#
# === GET:
#     Renderes the landing page with the accept form for editing friendship
#     parameters.
# ==== Params:
#     id: the id of the swimming buddy (user) to be accepted by the current user
#
# === PUT:
#     Updates friendship row with the accepted status (creates also a personalized
#     news feed article).
# ==== Params:
#     id: the id of the swimming buddy to be accepted by the current user
#     :shares_passages  => set to '1' to enable, anything else to disable
#     :shares_trainings => set to '1' to enable, anything else to disable
#     :shares_calendars => set to '1' to enable, anything else to disable
#
Accept/edit friends action.
GET:
Renderes the landing page with the accept form for editing friendship
parameters.
Params:
id: the id of the swimming buddy (user) to be accepted by the current user

Updates friendship row with the accepted status (creates also a personalized
news feed article).
Accept / edit friends action . GET : Renderes the landing page with the accept form for editing friendship parameters . Params : id : the id of the swimming buddy ( user ) to be accepted by the current user Updates friendship row with the accepted status ( creates also a personalized news feed article ) .
def approve
    @title = I18n.t('social.approve_title')
    @swimming_buddy = User.find_by_id( params[:id] )
    if request.post?                                
      shares_passages  = (params[:shares_passages].to_i > 0)
      shares_trainings = (params[:shares_trainings].to_i > 0)
      shares_calendars = (params[:shares_calendars].to_i > 0)
      if UserSocializer.new(current_user).approve_with_notify( @swimming_buddy, shares_passages, shares_trainings, shares_calendars )
        flash[:info] = I18n.t('social.approve_successful')
      else
        flash[:error] = I18n.t('social.approve_error')
      end
      redirect_to( swimmer_radio_path(id: @swimming_buddy.swimmer_id) ) and return
    else
      if SwimmerUserStrategy.new(@swimming_buddy.swimmer).is_approvable_by( current_user )
        @submit_title = I18n.t('social.approve')
        @friendship = current_user.find_any_friendship_with(@swimming_buddy)
      else
        flash[:warning] = I18n.t( 'social.warning_could_not_find_valid_or_pending_friendship' )
          .gsub( "{SWIMMER_NAME}", @swimming_buddy.name )
        redirect_back( fallback_location: root_path ) and return
      end
    end
  end
def approve @title = I18n . t ( 'social.approve_title' ) @swimming_buddy = User . find_by_id ( params [ :id ] ) if request . post? shares_passages = ( params [ :shares_passages ] . to_i > 0 ) shares_trainings = ( params [ :shares_trainings ] . to_i > 0 ) shares_calendars = ( params [ :shares_calendars ] . to_i > 0 ) if UserSocializer . new ( current_user ) . approve_with_notify ( @swimming_buddy , shares_passages , shares_trainings , shares_calendars ) flash [ :info ] = I18n . t ( 'social.approve_successful' ) else flash [ :error ] = I18n . t ( 'social.approve_error' ) end redirect_to ( swimmer_radio_path ( id : @swimming_buddy . swimmer_id ) ) and return else if SwimmerUserStrategy . new ( @swimming_buddy . swimmer ) . is_approvable_by ( current_user ) @submit_title = I18n . t ( 'social.approve' ) @friendship = current_user . find_any_friendship_with ( @swimming_buddy ) else flash [ :warning ] = I18n . t ( 'social.warning_could_not_find_valid_or_pending_friendship' ) . gsub ( "{SWIMMER_NAME}" , @swimming_buddy . name ) redirect_back ( fallback_location : root_path ) and return end end end
Accept/edit friends action.
Accept / edit friends action .
# DEBUG #    logger.debug "\r\n\r\n!! ------ #{self.class.name}.approve() -----" #    logger.debug "PARAMS: #{params.inspect}" # === POST: === # === GET: ===