hi all
i''m trying to have a post with tags included but i''m getting
undefined method `tag_with''
i''ve already added acts_as_taggable to the model
and on the controller the code for creating the post is:
def create
@post = Post.new(params[:post])
@post.tag_with(params[:tag_list])
@post.user = current_user
if @post.save
redirect_to root_url
else
render :action => ''new''
end
end
and the form on the view has the tagging code:
<p><label for="tag_list">Tags</label><br/>
<%= text_field_tag ''tag_list'', @post.tags.collect{|t|
t.name}.join(" ")
%>
since the acts_as_taggable is in the model i don''t see why it would
give
me undefined method.
any help would be greatly appreciateddd thank youu
--
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
-~----------~----~----~----~------~----~------~--~---
Harry Seldon
2008-Feb-26 22:01 UTC
Re: problem with posting with acts as taggable on steroids
You might want to have a look at the readme in the
vendor/plugins/acts_as_taggable_on_steroids directory.
You will read the text hereafter.
In short : there is not tag_with method.
To add a tag do : p.tag_list.add("Great", "Awful")
=== Basic tagging
Let''s suppose users have many posts and we want those posts to have
tags.
The first step is to add +acts_as_taggable+ to the Post class:
class Post < ActiveRecord::Base
acts_as_taggable
belongs_to :user
end
We can now use the tagging methods provided by acts_as_taggable,
<tt>#tag_list</tt> and <tt>#tag_list=</tt>. Both these
methods work like regular attribute accessors.
p = Post.find(:first)
p.tag_list # []
p.tag_list = "Funny, Silly"
p.save
p.tag_list # ["Funny", "Silly"]
You can also add or remove arrays of tags.
p.tag_list.add("Great", "Awful")
p.tag_list.remove("Funny")
H
Richard Yoo wrote:> hi all
>
> i''m trying to have a post with tags included but i''m
getting
> undefined method `tag_with''
>
> i''ve already added acts_as_taggable to the model
>
> and on the controller the code for creating the post is:
>
> def create
> @post = Post.new(params[:post])
> @post.tag_with(params[:tag_list])
> @post.user = current_user
> if @post.save
> redirect_to root_url
> else
> render :action => ''new''
> end
> end
>
> and the form on the view has the tagging code:
>
> <p><label
for="tag_list">Tags</label><br/>
> <%= text_field_tag ''tag_list'', @post.tags.collect{|t|
t.name}.join(" ")
> %>
>
> since the acts_as_taggable is in the model i don''t see why it
would give
> me undefined method.
>
> any help would be greatly appreciateddd thank youu
--
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
-~----------~----~----~----~------~----~------~--~---