Hi Sergio

Just saw your last suggestion on not using global variable.

This works great !

 def can_show_create_link
 #  if $level > 0
   if current_user.level > 0
       return true
   else
return false
   end
  end


On Wednesday, 8 March 2017 21:47:29 UTC+8, Chee Chong Hwa wrote:
>
> Hi Sergio
>
> TQVM for your speedy and relevant feedback.
>
> This works !
>
>    conf.create.link.ignore_method = :can_show_create_link
>
> def can_show_create_link
>    if $level > 0
>        return true
>    else
> return false
>    end
>   end
>
>
>
>
> On Wednesday, 8 March 2017 17:16:31 UTC+8, Chee Chong Hwa wrote:
>>
>> Hi Sergio
>>
>> 1. In my seesions controller
>> def create
>>     user = User.find_by(username: params[:username])
>>     if user && user.authenticate(params[:password])
>> *$level*=user.level
>>     end
>> end
>>
>> 2. in my tasks controller, I am trying not to show the Crete New if 
>> user.level>0
>>
>> active_scaffold :"task" do |conf|
>>   if $level > 0
>>   conf.create.link = false
>>        end 
>> end
>>
>> Result, the $level >0 is not honoured.
>>
>> Q. How can I get this to work. I am using levels for role-based security. 
>> Ever user has a level=0-100
>>
>> TIA
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.

Reply via email to