On 19 July 2017 at 00:07, babacar thiam <thiamd...@gmail.com> wrote:
> the error says no MethodError (undefined method `name' for nil:NilClass):

Exactly. The error says you have tried to call method 'name' on
something that is nil. You are calling method 'name' on self.role (you
have used self.role.name) therefore the error is saying that self.role
is nil.

Colin

>
>
>
> app/models/user.rb:15:in `admin?'
>
> app/models/ability.rb:7:in `initialize'
>
>
> Le mardi 18 juillet 2017 17:15:51 UTC-4, Colin Law a écrit :
>>
>> On 18 July 2017 at 22:02, babacar thiam <thia...@gmail.com> wrote:
>> >
>> > hi i have a mistake since this morning .
>> >
>> > undefined method `name' for nil:NilClass
>> >
>> > Extracted source (around line #15):
>>
>> >
>> > end
>> > def admin?
>> >   self.role.name == "Admin"
>> > end
>> > def seller?
>> >   self.role.name == "Seller"
>> >
>>
>> As the error says, self.role is nil
>>
>> Colin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/e7a9e5c3-d026-495e-914d-fa26bcf39f8a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsAKajSL3dB0sVEGB5ezqAPwRHyzig9cZRg_DbTJKH0pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to