Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add supermodel attr_accessibles to submodels, version bump

  • Loading branch information...
commit 37638f572ca42907396d4a8a8a7f9b7ffc39a2e5 1 parent 25c3dbd
Hassan authored
2  lib/active_record/acts_as_relation.rb
@@ -61,6 +61,8 @@ def self.included(base)
61 61 ignored = ["created_at", "updated_at", "#{association_name}_id", "#{association_name}_type", "#{association_name}"]
62 62 attributes_to_delegate = attributes + associations - ignored
63 63 base.send :define_acts_as_accessors, attributes_to_delegate, "#{name}"
  64 +
  65 + base.attr_accessible.update(#{class_name}.attr_accessible)
64 66 end
65 67
66 68 def #{name}_with_autobuild
2  lib/version.rb
... ... @@ -1,5 +1,5 @@
1 1 module ActiveRecord
2 2 module ActsAsRelation
3   - VERSION = "0.1.1"
  3 + VERSION = "0.1.2"
4 4 end
5 5 end
6 spec/acts_as_relation_spec.rb
@@ -71,6 +71,12 @@
71 71 end
72 72 end
73 73
  74 + it "have supermodel attr_accessibles as attr_accessibles" do
  75 + Pen.attr_accessible[:default].each do |a|
  76 + Pencil.attr_accessible[:default].should include(a)
  77 + end
  78 + end
  79 +
74 80 it "should be findable" do
75 81 pen = Pen.create :name => 'RedPen', :price => 0.8, :color => 'red'
76 82 pen = Pen.find(pen.id)
2  spec/dummy/app/models/pen.rb
@@ -2,5 +2,7 @@ class Pen < ActiveRecord::Base
2 2 acts_as_superclass
3 3 acts_as :product, as: 'producible'
4 4
  5 + attr_accessible :name, :price, :color
  6 +
5 7 validates_presence_of :color
6 8 end

0 comments on commit 37638f5

Please sign in to comment.
Something went wrong with that request. Please try again.