Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
multiple taggable fields on form
5 Posts
multiple taggable fields on form

Hello, Im' building an app , but in one form, i have two fields that are taggables, later i want to use an autocomplete option, to make it easier.

but, how can i make two fields taggables with "acts_as_taggable_on" pluggin?

i make the following:

form.html.erb

'long_text' %> 'long_text' %>

user.rb (model)

acts_as_taggable_on :atribute, :features

but when i submit the form, i get this error:


ActsAsTaggableOn::Tag(#2173873640) expected, got String(#2148246520)

/Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_proxy.rb:259:in raise_on_type_mismatch' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:320:inreplace' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:320:in each' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:320:inreplace' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations.rb:1331:in features=' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2906:insend' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2906:in assign_attributes' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2902:ineach' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2902:in assign_attributes' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2775:inattributes=' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2663:in `update_attributes'

etc......etc....

anyone can help me??? thanks


Hello Alejandro,

Please also do post your code of the related controller file here. That will be helpful to analysis your issue.

As you shown in above code. Try following things

  1. i.e model (user.rb) file

acts_as_taggable_on :atribute, :features

instead of :atribute use :atributes (i.e pluralize)

  1. in your method of your relevant controller file

Try following code

http://pastie.org/1085626

I hope this will help you.

Good Luck ;)

-Ganesh

Person
Jruby, Ruby, Rails Programmer
Sign In To Rate Post

Hello Ganesh, and thanks for reply.

here is the code you ask me : http://pastie.org/1085940

i made the changes you told me, but, it continuous not working. maybe, the fields "features" and "atributes" exist on estate table on DB is this correct? the error continuos being the same: http://pastie.org/1085956

also, as you can se there. the "estates" belong to a "realestate" but, i also need to put it to an "agent id" how can i automatically do this? realestate_id and agent_id are stored on session used (restful_authentication)

very apreciate for your help :) thank you.

Hi,

After review on source code I gone through many blog and google search.. I observed that relevant model file should follow like

either acts_as_taggable_on :tags, :atributes, :features

i.e #estate.rb model class Estate < ActiveRecord::Base acts_as_taggable_on :tags, :atributes, :features end

OR should be like

acts_as_taggable acts_as_taggable_on :atributes, :features

i.e #estate.rb model class Estate < ActiveRecord::Base acts_as_taggable acts_as_taggable_on :atributes, :features end

have a look at following two links..

http://github.com/mbleigh/acts-as-taggable-on http://intridea.com/2007/12/4/announcing-acts_as_taggable_on

I haven't tried this at my side, but its just one small thing which I feel.. Please try this with your task and let me know the result.

Good Luck ;) -Ganesh

Person
Jruby, Ruby, Rails Programmer
Sign In To Rate Post

Hello Ganesh, i've solved the problem, thank you for your help, very appreciated.

this was the solution: use "tag_list" for on of the fields i want to be taggables, and thats it, maybe the pluggin needs "tag" field. secont parameter y called "features" so, i rename "atributes" to "tags" and thats it.

thanks for the links also :)


can you help me on this issue:

also, as you can se there. the “estates” belong to a “realestate” but, i also need to put it to an “agent id” how can i automatically do this? realestate_id and agent_id are stored on session used (restful_authentication)

actualli y save the "estates" in this way:

params_form = params[:estate] @estate = @realestate_info.estate.new(params_form)

"@realestate_info" has the info from the "realestate" how can i automatically add agent_id from current_user session?

thank you very much.

5 Posts
Login to add your message