我在android上的class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.role == "member"
their own only
can :read, User
can :manage, User, user_id: user.id
elsif user.role == "guest"
can :read, User
end
class User < ActiveRecord::Base
#attr_accessible :name , :email # Include default devise modules. Others available are:
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
ROLES = %w[member guest]
def is?( requested_role )
self.role == requested_role.to_s
end
end
上收到以下错误:
Adapter
我有一个填充适配器的聊天消息列表。我正在做的是从适配器列表中获取消息,然后找出发送消息的用户是谁,最后得到他们的ID:
getView
如果我在这一行上设置一个断点,只要调试器停在那里就点击恢复程序就可以了。只有在我没有任何断点时才会出现问题。
这是A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x187 in tid 20034 (kup.android.app)
上的int id = mChatMessages.get(position).getFrom().getId();
:
getFrom
这是ChatMessage
上的private User from;
public User getFrom() {
return from;
}
:
getID
这是User
:
private int id;
public int getId() {
return id;
}