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.
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---