How to use amistad gem in rails3?

本小妞迷上赌 提交于 2019-12-10 08:05:02

问题


I need help on how to implement AMISTAD gem in a rails3 application. Please suggest some tutorials or views? I saw github amistad link. but i want a full coverage on this gem. Please help me.


回答1:


The gem creator kindly send me an example of how to use the GEM try these, create a friendship controller that handles the methods

class FriendshipsController < ApplicationController
  before_filter :authenticate_user!

  def index
    @friends = current_user.friends
    @pending_invited_by = current_user.pending_invited_by
    @pending_invited = current_user.pending_invited
  end

  def create
    @Friend = User.find(params[:user_id])
    @friendship_created = current_user.invite(@Friend)
    if @friendship_created
      flash.now[:notice] = "Une demande d'amiti a t envoye  #{@friend.fullname}"
    end
  end

  def approve
    @Friend = User.find(params[:user_id])
    @friendship_approved = current_user.approve(@Friend)
    @friends = current_user.friends
    @pending_invited_by = current_user.pending_invited_by
    flash.now[:notice] = "La demande d'amiti de #{@friend.fullname} a t approuve"
  end

  def remove
    @Friend = User.find(params[:user_id])
    @friendship = current_user.send(:find_any_friendship_with, @Friend)
    if @friendship
      @friendship.delete
      @removed = true
      flash.now[:notice] = "L'amiti avec #{@friend.fullname} a t supprime"
    end
  end
end


来源:https://stackoverflow.com/questions/6013720/how-to-use-amistad-gem-in-rails3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!