I have a site with a coming soon page -- it's managed by a boolean value in the database and a method the application controller called by a before_filter
.
def is_it_live?
@setting = Setting.find(1)
if @setting.is_it_live
开发者_StackOverflow中文版 return true
else
unless admin_signed_in?
redirect_to comingsoon_path
end
end
end
I tried to use skip_filter
on the specific controllers that should be public if the site isn't live, specifically the one that's for comingsoon
... but it's not working. I'm getting a redirect when I go to the comingsoon path because it's still running the before_filter in the application controller. Anyway to fix this? Or a better way to handle the logic?
weird, did you try:
skip_before_filter :is_it_live, :only => [:action1, :action2]
Well, I solved the problem. I was also declaring is_it_live?
as a helper method to use the logic in the views, so the problem might be that the filter was still getting called by the view (though it seems if the controller for the view is removing it from the filter chain, it should be removed the view, too? but maybe my thinking is just way off on that), taking it out fixed the problem.
精彩评论