On Monday, April 15, 2013 8:18:18 AM UTC+1, Filip Matošić wrote:
> Developing an application with angular I came into a problem. In my application I use cancan (
https://github.com/ryanb/cancan ).
> Now when showing data in a table i have to filter if the logged user can or cannot edit, view etc, and thus disabling buttons that allow given operations.
> When using ror its not a problem:
>
> %td
> -if can? :edit,script
> %a{:href=>edit_script_path(script)}
> edit
> but when i need to do the same thing with angular i need to mark the row data inside the controller with a flag eg. can_edit, can_view and then
> so i come up with an idea to add an attribute to each row before rendering to json:
>
>
As the warning suggests, I'd use attr_writer/attr_accessor. This doesn't mean adding columns to your database, just some ruby accessor methods (people sometimes call these virtual attributes)