# Help needed regaring Acts As Taggable On Steroids

**URL:** <https://www.ruby-forum.com/t/help-needed-regaring-acts-as-taggable-on-steroids/155409>\
**Category:** Rails\
**Created:** [December 11, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/help-needed-regaring-acts-as-taggable-on-steroids/155409 "2008-12-11T15:59:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mac-eros](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@mac-eros](https://www.ruby-forum.com/u/mac-eros)\
**Post date:** [December 11, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/help-needed-regaring-acts-as-taggable-on-steroids/155409/1 "2008-12-11T15:59:07Z")

</div>

Hello,  
In my rails application, I have a book model.  
I want to add tags. For that I have installed  
acts\_as\_taggable\_on\_steroids from this link  
[http://agilewebdevelopment.com/plugins/acts\_as\_taggable\_on\_steroids](http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroids)  
and do as the readme file.  
This is my Model :  
class Book \< ActiveRecord::Base  
acts\_as\_taggable  
end

Here is my ApplicationHelper :  
module ApplicationHelper  
include TagsHelper  
end

And I couldn’t get the idea what should I add in the controller to save  
tags(please guide me to save tags) . I just try to follow the readme and  
Edited part of BookController is:

def create  
@book = Book.new(params[:book])  
@book.tag\_list # []  
@book.tag\_list = “Funny, Silly”  
respond\_to do |format|  
if @book.save  
flash[:notice] = ‘Book was successfully created.’  
format.html { redirect\_to(@book) }  
format.xml { render :xml =\> @book, :status =\> :created,  
:location =\> @book }  
else  
format.html { render :action =\> “new” }  
format.xml { render :xml =\> @book.errors, :status =\>  
:unprocessable\_entity }  
end  
end  
end

def tag\_cloud  
@tags = Books.tag\_counts  
end

In the new.html.erb I have added these lines :  
\<% tag\_cloud @tags, %w(css1 css2 css3 css4) do |tag, css\_class| %\>  
\<%= link\_to tag.name, { :action =\> :tag, :id =\> tag.name }, :class  
=\> css\_class %\>  
\<% end %\>

After I restarting the server, When I want to create a new book entry it  
shows error as below:

“You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occurred while evaluating nil.empty?”  
And the error details shows that the error is in tag\_cloud

When I add a TagList.delimiter = " " in config/environment.rb  
and restart the server… the server stop with error showing as  
uninitialized constant TagList .

Please help me as I am new in ruby.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mac-eros](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@mac-eros](https://www.ruby-forum.com/u/mac-eros)\
**Post date:** [December 12, 2008, 2:34am UTC](https://www.ruby-forum.com/t/help-needed-regaring-acts-as-taggable-on-steroids/155409/2 "2008-12-12T02:34:46Z")

</div>

Mac Eros wrote:

> Hello,  
> Edited part of BookController is:
> 
> def create  
> @book = Book.new(params[:book])  
> @book.tag\_list # []  
> @book.tag\_list = “Funny, Silly”  
> respond\_to do |format|  
> if @book.save  
> flash[:notice] = ‘Book was successfully created.’  
> format.html { redirect\_to(@book) }  
> format.xml { render :xml =\> @book, :status =\> :created,  
> :location =\> @book }  
> else  
> format.html { render :action =\> “new” }  
> format.xml { render :xml =\> @book.errors, :status =\>  
> :unprocessable\_entity }  
> end  
> end  
> end
> 
> def tag\_cloud  
> @tags = Books.tag\_counts  
> end
> 
> In the new.html.erb I have added these lines :  
> \<% tag\_cloud @tags, %w(css1 css2 css3 css4) do |tag, css\_class| %\>  
> \<%= link\_to tag.name, { :action =\> :tag, :id =\> tag.name }, :class  
> =\> css\_class %\>  
> \<% end %\>

I have done almost the same but in create methos I have place the code  
@book = Book.new(params[:book])  
@book.tag\_with(params[:tag\_list])  
respond\_to do |format|  
…  
and in new.html.erb  
\<%= text\_field\_tag ‘tag\_list’, @book.tags.collect{|t| t.name}.join(" ")  
%\>

But when I run the application and try to create a new Entry  
if shows the error that "undefined method `tag\_with’ for  
#Book:0x4a8bc14  
"  
Please help me.  
Thanks in advance.
