app/controllers/socials_controller.rb
# Invite friends action.
#
# === GET:
#     Renderes the landing page with the invite form.
# ==== Params:
#     id: the id of the swimming buddy (user) to be invited by the current user
#
# === POST:
#     Creates the friendship row with pending status (pending invites will be
#     automatically shown to a user on its personalized news-feed).
# ==== Params:
#     id: the id of the swimming buddy to be invited 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
#
Invite friends action.
GET:
Renderes the landing page with the invite form.
Params:
id: the id of the swimming buddy (user) to be invited by the current user

Creates the friendship row with pending status (pending invites will be
automatically shown to a user on its personalized news-feed).
Invite friends action . GET : Renderes the landing page with the invite form . Params : id : the id of the swimming buddy ( user ) to be invited by the current user Creates the friendship row with pending status ( pending invites will be automatically shown to a user on its personalized news - feed ) .
def invite
    @title = I18n.t('social.invite_title')
    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).invite_with_notify( @swimming_buddy, shares_passages, shares_trainings, shares_calendars )
        flash[:info] = I18n.t('social.invite_successful')
      else
        flash[:error] = I18n.t('social.invite_error')
      end
      redirect_to( swimmer_radio_path(id: @swimming_buddy.swimmer_id) ) and return
    else
      if SwimmerUserStrategy.new(@swimming_buddy.swimmer).is_invitable_by( current_user )
        @submit_title = I18n.t('social.send')
        @friendship = Amistad.friendship_class.new( friendable_id: current_user.id, friend_id: @swimming_buddy.id )
      else
        flash[:warning] = I18n.t( 'social.warning_friendship_invite_already_sent_edit_options' )
          .gsub( "{SWIMMER_NAME}", @swimming_buddy.name )
        redirect_back( fallback_location: root_path ) and return
      end
    end
  end
def invite @title = I18n . t ( 'social.invite_title' ) 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 ) . invite_with_notify ( @swimming_buddy , shares_passages , shares_trainings , shares_calendars ) flash [ :info ] = I18n . t ( 'social.invite_successful' ) else flash [ :error ] = I18n . t ( 'social.invite_error' ) end redirect_to ( swimmer_radio_path ( id : @swimming_buddy . swimmer_id ) ) and return else if SwimmerUserStrategy . new ( @swimming_buddy . swimmer ) . is_invitable_by ( current_user ) @submit_title = I18n . t ( 'social.send' ) @friendship = Amistad . friendship_class . new ( friendable_id : current_user . id , friend_id : @swimming_buddy . id ) else flash [ :warning ] = I18n . t ( 'social.warning_friendship_invite_already_sent_edit_options' ) . gsub ( "{SWIMMER_NAME}" , @swimming_buddy . name ) redirect_back ( fallback_location : root_path ) and return end end end
Invite friends action.
Invite friends action .
# DEBUG #    logger.debug "\r\n\r\n!! ------ #{self.class.name}.invite() -----" #    logger.debug "PARAMS: #{params.inspect}" # === POST: === # === GET: === # Let's create an empty instance that will store the form fields before POST: # If friendship exists: