views:

471

answers:

1

Hello, I am using Single access token to do some data transfer, so far I got it to work with one action in the controller through

ProjectsController private def single_access_allowed? action_name == 'index' end

But I need two more actions to be allowed access with single access token, I tried to modify the line action_name == 'index' to action_name == ['index', 'update', 'destroy'] but to no avail. I have tried to look for the single_access_allowed? definition in all of the files in authlogic's gem directory, but it doesn't say what sort of variable action_name is, e.g., array, hash, string?

Any help would be great!

Thanks!

+1  A: 

action_name is a string. You want to check if action_name is within a list of actions (an array of strings). To do this in ruby:

def single_access_allowed?
  ["index","update","destroy"].include?(action_name)
end
Jonathan Julian
Oh I see, the '==' operator returns a true/false value, that's why it was 'action_name == "index"', Thanks very much!
Nik