Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion attr_accessible with an :if option

Received: by 10.181.12.101 with SMTP id ep5mr2011782wid.1.1349124393020;
        Mon, 01 Oct 2012 13:46:33 -0700 (PDT)
X-BeenThere: rubyonrails-core@googlegroups.com
Received: by 10.180.105.1 with SMTP id gi1ls7557606wib.2.canary; Mon, 01 Oct
 2012 13:46:21 -0700 (PDT)
Received: by 10.216.239.205 with SMTP id c55mr980013wer.12.1349124381675;
        Mon, 01 Oct 2012 13:46:21 -0700 (PDT)
Received: by 10.216.239.205 with SMTP id c55mr980012wer.12.1349124381664;
        Mon, 01 Oct 2012 13:46:21 -0700 (PDT)
Return-Path: <st...@steveklabnik.com>
Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179])
        by gmr-mx.google.com with ESMTPS id bu8si875179wib.2.2012.10.01.13.46.21
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 01 Oct 2012 13:46:21 -0700 (PDT)
Received-SPF: neutral (google.com: 209.85.212.179 is neither permitted nor denied by best guess record for domain of st...@steveklabnik.com) client-ip=209.85.212.179;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.212.179 is neither permitted nor denied by best guess record for domain of st...@steveklabnik.com) smtp.mail=st...@steveklabnik.com
Received: by wibhq7 with SMTP id hq7so2544026wib.8
        for <rubyonrails-core@googlegroups.com>; Mon, 01 Oct 2012 13:46:21 -0700 (PDT)
        d=google.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type:x-gm-message-state;
        bh=Ufsa2yZIF71ekD/1RrOblwf8jWgUP2ncV2RQYgjPQj4=;
        b=O6rTZgrHlxiTXBvf3XfjQMvdlHw6g+hM4R5bahsdJq0DuAodSBaTM5+OMpcTvuyDid
         AlYjMEboGpA5SJ6T7H1iWy4MAnfvPklHtyFgXmKwHu5lAum5lzd1xNRmfbUVORVHrzb4
         JqYjbgP4JIsbl7A2NpUTsgGloAHHM0NdIUMtf/tR5EmKiohoNVOOJ5OgK4JraxLJygXu
         vYWnsleEwuWSIte1TCPcU1vd00xtU04klgYZTLNtj5mbvGH1ZGecKlYn6p9Uv+hUNOnA
         NCzsJi8TkCBdyhdx0LbrxW5tWN6/hyXIsP7ZfgXzFBAzcYacg0JguBnUXxClfx91qMmM
         U1Iw==
MIME-Version: 1.0
Received: by 10.180.77.34 with SMTP id p2mr17111007wiw.0.1349124381330; Mon,
 01 Oct 2012 13:46:21 -0700 (PDT)
Received: by 10.194.14.6 with HTTP; Mon, 1 Oct 2012 13:46:21 -0700 (PDT)
In-Reply-To: <81505b64-3b6b-4812-ae74-bb75cb747ecf@googlegroups.com>
References: <81505b64-3b6b-4812-ae74-bb75cb747ecf@googlegroups.com>
Date: Mon, 1 Oct 2012 13:46:21 -0700
Message-ID: <CABL+ZB7TwusA=JmKB9VVPs4yFa-Xn4R-PpjKSjfDBiDy7nS...@mail.gmail.com>
Subject: Re: [Rails-core] attr_accessible with an :if option
From: Steve Klabnik <st...@steveklabnik.com>
To: rubyonrails-core@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
X-Gm-Message-State: ALoCoQm33jLxl+Lrt36abulyGBscqB55ZCs2uBOyBObHDYxl0Ng+ctj93KSpDvyEj1RYbN0EpMP5

Can you Just Use Ruby? (tm)

$ irb
1.9.3p194 :001 > class Foo
1.9.3p194 :002?>   attr_reader :bar if true
1.9.3p194 :003?>   end
 => nil
1.9.3p194 :004 > Foo.new.methods.grep(/bar/)
 => [:bar]
1.9.3p194 :005 > class Bar
1.9.3p194 :006?>   attr_reader :foo if false
1.9.3p194 :007?>   end
 => nil
1.9.3p194 :008 > Bar.new.methods.grep(/foo/)
 => []