act_as_tggable プラグインを使用して、Ruby on Rails アプリケーションにタグ機能を含めようとしています。コードを添付しました。プラグインをインストールし、移行も実行しました。次のエラーが表示されます。
undefined method `each' for "value of the parameter":String
コード
location.rb - ロケーションテーブルには名前、タグがあります (これはテーブルにある追加フィールドです。プラグインについて知る前に追加しました:)、都市フィールド
class Location < ActiveRecord::Base
belongs_to :profile
acts_as_taggable
end
profile.rb
class Profile < ActiveRecord::Base
has_many :locations
acts_as_tagger
end
location_controller.rb
def create
@location = Location.new(params[:location])
@location.tag_list = ["tags1","tags2"]
if @location.save
redirect_to(@location)
else
redirect_to(@profile)
end
end
アプリケーション トレース
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:320:in `replace'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/associations.rb:1331:in `block in collection_accessor_methods'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2906:in `block in assign_attributes'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2902:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2902:in `assign_attributes'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2775:in `attributes='
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2473:in `initialize'
/Users/felix/rails_projects/sample_app/app/controllers/locations_controller.rb:92:in `new'
/Users/felix/rails_projects/sample_app/app/controllers/locations_controller.rb:92:in `create'
ありがとう