Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
SF Standup 6/7/2011: CanCan allows model field authorization by user

Ask for Help

“How do you restrict access to particular fields in a model by user (e.g. admin user versus regular user)?”

The CanCan gem can do this.

“How exactly does Active Support find helper files when injecting them into view contexts? The goal is to add helper files into view contexts without using ActionController.”

There was no immediate answer; some pivots are going to look into this.

Interesting Things

  • An Xcode update (4.0) has end-of-life’d hwprefs, which older versions of the parallel_tests gem require. The solution is to upgrade to the newest version of the parallel_tests gem or to place the shell script below somewhere within your search path.
  #!/bin/sh

  case $1 in
  'thread_count') sysctl -n hw.ncpu
  esac

Events

  • Code for America is having an Open House tonight more info..
  • SF Ruby is having a hack night tomorrow at TrueCar more info..

Comments
  1. scragz says:

    “How do you restrict access to particular fields in a model by user (e.g. admin user versus regular user)?”

    New in Rails 3.1 is scoped mass assignment.

    attr_accessible :role, :as => :admin

  2. Sylvain says:

    “How do you restrict access to particular fields in a model by user (e.g. admin user versus regular user)?”

    It appears that this functionnality is only implemented in cancan 2.0 which is still in beta yet. Is CanCan 2.0 stbale for you ? I hesitated using it even though this functionnality would be pretty useful for me.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *