Ruby-on-rails-3 – Access acquisition parameters in Cancan

Can I access the parameters passed in the url in CanCan? I am trying to authenticate guests based on the token in the URL.

Thank you!

I recently implemented a similar function using the method described here:

https://github.com/ryanb/cancan/wiki/Accessing-request-data

In my case, it looks like this:

Application /Controller/application_controller.rb:

class ApplicationController 
...

def current_ability
@current_ability ||= Ability.new(current_user, params[:token])
end

end

application/model/ ability.rb :

class Ability
include CanCan::Ability

def initialize(user, token=nil)
...
can :read, Article, :tokens => {:token => token }
...
end

end

Is it possible to access the parameters passed in the url in CanCan? I am trying to authenticate guests based on the token in the URL.

Thank you!

I recently implemented a similar function using the method described here:

https://github.com/ ryanb/cancan/wiki/Accessing-request-data

In my case, it looks like this:

application/controller/application_controller.rb:

class ApplicationController 
...

def current_ability
@current_ability ||= Ability.new (current_user, params[:token])
end

end

application/model/ability.rb:

class Ability
include CanCan::Ability

def initialize(user, token=nil)
...
can :read, Article, :tokens => {:token => token }
...
end

end

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3351 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.