Wednesday, April 9, 2014

Ruby on Rails, Rest in Place with Authorization taken into Account

Hey all,

Just a quick one. Just started using Rest in Place in my Rails applications. If you don't know what it is - it seems to be the most popular In-place editing gem (according to Ruby Toolbox).

Anyway, the one thing that kind of got annoying, is that my view templates were getting pretty ugly with a lot of IF statements because I didn't want in-place editing to be active for people who weren't allowed to edit. I realize that Rest in Place still goes through the controller, so any authorization code you have on the controller side prevents true editing - but still, I wanted to prevent the UI in-place editing for people who weren't authorized to do so either.

So I created a simple helper to remedy this.

You can check out the Gist here.