def create
    @share_link = @file.share_links.build(permitted_params.share_link)
    @share_link.user = current_user

    if @share_link.save
      UserMailer.share_link_email(@share_link).deliver_now
      redirect_to @folder, :notice => t(:shared_successfully)
    else
      render :action => 'new'
    end
  end
Note: @file and @folder are set in require_existing_file