hey guys,
i am writing a couple of actions which are only used with an xhr. I
‘protect’ them all against a direct access with the ‘verify’ method in
the controller
verify :only => …, :xhr => true
it would be cool if the system would automatically recognize the xhr
actions and protect them … i want to postfix methods with ‘_xhr’ and
those should be only accessible with an xhr.
good for readability
good for my DRY
does anyone has a tip on how to implement this? i guess it should go
into the ‘ApplicationController’
In a filter, make sure to return false and not just to render /
redirect. You should always return false in a filter if you want to halt
the execution chain.
i.e redirect_to my_url and false
Michal G. wrote:
yeah that was exactly what i needed… thanks…
the only problem i have now is that i have two before_filters:
before_filter :protect_xhr, check_login
and both can do a redirect … when protect_xhr does one already and
check_login also wants to do one i get a double response error …
Yea, I am aware that they changed that and I am really glad they did. I
always thought that the whole “returning false” thing was counter
intuitive. Everyone coming in expects a render or a redirect to stop the
execution. I always felt that was the better solution. Glad the rails
core finally agreed.
Just be glad you aren’t trying to follow the Agile book NOW, when
Rails 2.0is installed when you do a fresh installation I feel
really sorry for any
newbies right now.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.