lundi 6 juillet 2015

How to setup the follow/unfollow/block link_to button for Acts_As_Follower Rails 4

I'm currently in the process of completing the setup for the acts_as_follower gem for Rails 4. When I click on the follow button, the ActionView Exception Missing Template kicks in. Does anyone know how to create a multi-state Zurb Foundation button for it or even custom radius button. Simply: "Follow/Unfollow" If you have a better approach, please share it. These solutions are necessities to development.

Missing template users/follow, application/follow with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :slim, :haml, :jbuilder]}. Searched in:

<%= link_to 'Follow', follow_user_path(@user), class: 'button success radius small' %>

def follow
    @user = User.friendly.find(params[:id])
    if current_user
      if current_user == @user
        flash[:error] = 'You cannot follow yourself.'
      else
        current_user.follow(@user)
        flash[:notice] = "You are now following #{@user.username}"
      end
    else
      flash[:error] = "You must be logged in to follow #{@user.username}."
      redirect_to :back
    end
  end

  def unfollow
    @user = User.friendly.find(params[:id])
    if current_user
    current_user.stop_following(@user)
      flash[:notice] = "You are no longer following #{@user.username}."
    else
      flash[:error] = "You must be logged in to unfollow #{@user.username}."
      redirect_to user_path(@user)
  end
  end

  def block
    @user = User.friendly.find(params[:id])
    if current_user
      current_user.block(@user)
      flash[:notice] = "You have blocked #{@user.username}."
      redirect_to user_path(@user)
    else
      flash[:notice] = "You aren't following #{@user.username}."
    end
  end

Aucun commentaire:

Enregistrer un commentaire