Hmm.. I'm in your same situation.

In your code:
<% if can? :create, @user %>
I believe that @user is nil, so when your Ability.rb try's to
read :account_id, it returns nil, and it is never == user.account_id,
thus your link is not displayed.
I don't know if it's the correcto solution, but I'm adding new
abilities.

In your case, you could use a create_user ability, and check it
against the Account in question.

So in Ability.rb:
if user.role == "admin"
can :create_user, Account do |acc|
  acc.id == user.account_id
end

And in your view:
link_to "New user", .... if can? :create_user, account # you have to
set the account variable somewhere.

Note that you don't have to "create" the :create_user ability. You can
just use it.

FWIW, these are the only actions included by default in CanCan
(no :write!)

alias_action :index, :show, :to => :read
alias_action :new, :to => :create
alias_action :edit, :to => :update

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to