I''m following the acts_as_taggable chapter from the Rails Recipes book. I want my view form to have a text_field that correlates to an attribute in the Model that accepts a string of space delimited tags. The book uses tag-_list, but from what I can tell this attribute can''t be written to. I''ve added this to the plugin code itself - am I missing something, is there a better way? def tag_list=(s) self.tag_with(s) end -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060807/14801ed2/attachment.html
I think i have the same problem? you try to tag your model in a new form ? (when you create it ) no? It''s work for me in a _form_tag_ when i use *<%= text_field ''tags'', '''' %>* and use _tag_with_ method in controller, but now i''am trying with _form_for_ and it''s doesn''t work because text_field depend on the form object which don''t accept other text_field that the model permit (one by attribute, no more)... did you find a solution ? Nathan P. Verni wrote:> I''m following the acts_as_taggable chapter from the Rails Recipes book. > I want my view form to have a text_field that correlates to an attribute > in the Model that accepts a string of space delimited tags. The book > uses tag-_list, but from what I can tell this attribute can''t be written > to. I''ve added this to the plugin code itself - am I missing something, > is there a better way? > > > > def tag_list=(s) > > self.tag_with(s) > > end-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I first tried to deal with a new method in my model : def tags=(tags) self.tag_with(tags) end it worked in prefectly in script/console but not in my app, i don''t know why? So i searched in googlecode and found another solution, pretty easy in fact... in your model adds: attr_writer :tag_list def after_save self.tag_with @tag_list end in your new form_for : <%= f.text_field :tag_list %> And of course in the controller : @model = Model.new(params[:model]) @model.save :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
just a custom, add a if test to after_save callback def after_save self.tag_with @tag_list if @tag_list end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---