Hi,
I would simply like to remove spaces of the property "name" before save
and update.
So i did the code below, but i get this error when I save or update a
tag. #error
undefined method `strip' for nil:NilClass
#Tag class
class Tag < ActiveRecord::Base
has_and_belongs_to_many :students
This is how i save or update my tag #From another class
def tag_attributes=(tags_att)
splits = tags_att.split(',')
splits.each do |tag|
if !tags.find_by_name(tag)
tags.build(:name => tag)
end
end
end
Hi,
I would simply like to remove spaces of the property "name" before save
and update.
So i did the code below, but i get this error when I save or update a
tag. #error
undefined method `strip' for nil:NilClass
#Tag class
class Tag < ActiveRecord::Base
has_and_belongs_to_many :students
the "name = " part is enough to trick the interpreter into treating 'name' as a local rather than a bare method call. Using self.name forces the treatment as a method.
-Rob
end
end
This is how i save or update my tag #From another class
def tag_attributes=(tags_att)
splits = tags_att.split(',')
splits.each do |tag|
if !tags.find_by_name(tag)
tags.build(:name => tag)
end
end
end
--
Posted via http://www.ruby-forum.com/\.