before-filter

before_filter: is it possible to specify controller for action?

I'm having the following string in my application_controller: before_filter :login_required, :only => [ :edit, :update, :show, :index ] But in case with :show, I need to put {:controller => 'users', :action => 'show'} in exception. Is it possible to do that? ...

In Ruby on Rails, when a before_filter is used, then the local variables need to become instance variables?

If we have a before filter that's called initialize to initialize common variables, then those variables must be made into instance variables? Are there alternative ways of doing it? Update: The situation is to validate some URL params, and set them. This used to be in one action, so everything can be done using local variables. But ...

Checking an attribute is true before executing a CRUD action

Before any of my article controller crud actions can run (excluding index), i want to make sure that the article's active field is true. I thought about doing this in a before_filter, but at that point @article has not been set, any ideas please? Thanks ...

FInding out which before_filters are already set in Rails 3

I have a DSL for controller configuration. The underlying functionality relies on before_filters. To prevent setting the before_filter more than once, I really need to find out whether a before_filter is already set in a Rails 3 controller. Since before_filter work different from class variables (inheritance, class reloading), I cannot...

cancel request in beforefilter() in PHP

Hi All, I'm using CakePHP , CAS for Authentication and ACL for Authorization. If the user donot have permission to view the page, i need to flash a message stating Not permitted OR redirect to another page. Ex: If the user is viewing /users/view/1 .Now the user requests /users/delete/1. The user donot have permission to delete. So I wa...

CakePHP strange behavior with beforeFilter: I cannot set the variables to the view.

Okay, this will require some setup: I'm working on a method of using nice post title "slugs" in the URL's of my cakePHP powered blog. For example: /blog/post-title-here instead of /blog/view_post/123. Since I'm obviously not going to write a new method for every post, I'm trying to be slick and use CakePHP callbacks to emulate the beh...

ignore before_update when save

some case I don't want execute before_update. please help me. case A: in case I want used before_update obj = Object.find(id) obj.save but case B I don't want used before_update obj = Object.find(id) obj.save # in case I want used before_update ...

In a node.js application, how can I asynchronously achieve the effect of a rails controller before_filter?

I have a node.js Express application with a basic user authentication system where the session is stored in redis. I'd like to write and re-use a current_user() function that populates a JSON representation of the logged in user (if there is one) in a current_user variable. Here is the code to retrieve the user: if( req.cookie('fingerpr...

Rails 3 Override Destroy without Canceling callbacks, and triggering a ROLLBACK

My desired behavior is that when destroy is called on an instance, that instance will not actually be destroyed, but it will just be marked as having been destroyed. This needs to percolate up for any model associations. In the models that I don't want to actually destroy, but just mark them as deleted I have a deactivated field. From...