开发者

What is wrong with this method? (I need some awesome Ruby Coders)

Ignoring rolerequirement with restfulauthentication method in a subdomain scope

I have created a site which utilizes subdomains and searches whether or not the user is at: subdomain.domain.com or domain.com. If the user is in subdomain.domain.com, /views/layouts/application.html.erb appears, if the user is in domain.com /views/layouts/promo_site.html.erb appears. To accomplish this I closely followed Robby on Rails directions.

Both layouts utilize the same controller. In addition I use rolerequirement with restfulauthentication, for both of my views to function I've created methods which search your scope (url.com or subdomain.url.com)

I've isolated the following problem:

  1. Method within the Controller is causing fail. "NoMethodError Controller: undefined method `require_role'"
  2. If the controller is in the c开发者_C百科orrect scope, url.com the before_filter :check_if_role_is_required method works fine. If it is in the subdomain.url.com scope, the check_if_role_is_required method produces a NoMethodError.

The following code is the check_if_role_is_required method:

def check_if_role_is_required 
require_role ["alt", "student worker"], :except => [:list, :show, :index, :create] unless promo_site?
end

*note the above code fails when require_role ["alt", "student worker"], :except => [:list, :show, :index, :create] is initiated, this code works fine outside of the check_if_role_is_required method, so this is probably a simple ruby error.

How can I rewrite this method to function?

Thanks!


The method itself looks ok.

Since you are getting the error when you are on subdomain.url.com, but not when you are on url.com, your problem isn't on the method definition, but on the code that handles "subdomain changing". That is the code you should check; it looks as if you are "not including" rolerequirement when you are on subdomain.url.com.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜