Closed miscelatore closed 12 years ago
Can you test it with ruby 1.9?
No til this moment
ss
Il giorno 17/mag/2012, alle ore 17:09, Hassan Zamanireply@reply.github.com ha scritto:
Can you test it with ruby 1.9?
Reply to this email directly or view it on GitHub: https://github.com/hzamani/acts_as_relation/issues/16#issuecomment-5765938
I do not have a machine with ruby-1.9
This is a ruby 1.9 specific gem (not compatible with 1.8). If you want to install 1.9 there is a Ruby Version Manager.
I have ruby 1.9.3 installed on my computer. Now I get the following error when creating a new record:
$ rails console Loading development environment (Rails 3.2.3) 1.9.3p194 :001 > pen = Pen.new(:name=>"Red Pen", :color=>:red, :price=>0.99) ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: name, price from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security/sanitizer.rb:48:in
process_removed_attributes' from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security/sanitizer.rb:20:in
debug_protected_attribute_removal' from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security/sanitizer.rb:12:insanitize' from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security.rb:230:in
sanitize_for_mass_assignment' from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/attribute_assignment.rb:75:inassign_attributes' from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/base.rb:498:in
initialize' from (irb):1:innew' from (irb):1 from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in
start' from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:8:instart' from /Users/stefano/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:41:in
<top (required)>' from script/rails:6:inrequire' from script/rails:6:in
'
Have you any idea?
Best regards
ss
I solved it by changing the model pen like this:
class Pen <ActiveRecord :: Base attr_accessible: color,: name,: price
acts_as: product,: as =>: producible end
bye
ss
Yes, in rails 3.2 attr_accessible
s are required. I will add in in docs, tanks.
Hello,
I.m try to use your gem by following the read me.
class Product < ActiveRecord::Base attr_accessible :name, :price
acts_as_superclass
validates_presence_of :name, :price
def hello puts "Hello, My name is '#{name}', my price is $#{price}." end end
class Pen < ActiveRecord::Base attr_accessible :color
acts_as :product, :as => :as_product end
rails console
p = Pen.new NameError: undefined local variable or method
includeconditionsautosavetrueclass_nameProductasas_productdependentdestroyvalidatefalse' for ActiveRecord::ActsAsModules::ActsAsProduct:Module from /Library/Ruby/Gems/1.8/gems/acts_as_relation-0.1.1/lib/active_record/acts_as_relation.rb:93:in
included' from /Library/Ruby/Gems/1.8/gems/acts_as_relation-0.1.1/lib/active_record/acts_as_relation.rb:96:ininclude' from /Library/Ruby/Gems/1.8/gems/acts_as_relation-0.1.1/lib/active_record/acts_as_relation.rb:96:in
acts_as' from /Library/Ruby/Gems/1.8/gems/acts_as_relation-0.1.1/lib/active_record/acts_as_relation.rb:95:inclass_eval' from /Library/Ruby/Gems/1.8/gems/acts_as_relation-0.1.1/lib/active_record/acts_as_relation.rb:95:in
acts_as' from /Users/stefano/RoR/test_acts_as_relation/app/models/pen.rb:4 from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:469:inload' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:469:in
load_file' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:639:innew_constants_in' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:468:in
load_file' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:353:inrequire_or_load' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:502:in
load_missing_constant' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:192:inconst_missing' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in
each' from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `const_missing' from (irb):1Have you any idea?
Best regards
ss