Not the gem.
I''ve got something working in console, but not in controller. Any idea
why?
This is the plugin not the gem of acts_as_taggable
*View*
<code>
<h1>Listing elements</h1>
<% if @elements.blank? %>
<p>There are currently no elements in the system tagged
<%""#{params[:tag_name]}"" %>.</p>
<% else %>
<p>Currently tracking <%= @elements.size %> elements in the system
tagged <%= ""#{params[:tag_name]}""
%>.</p>
<table>
<tr>
</tr>
<%= render :partial => ''element'', :collection =>
@elements %>
</table>
<% end %>
<br />
<%= link_to ''New element'', new_element_path %>
</code>
This returns that the array is empty and there''s nothing in the tag in
http://localhost:3000/elements/tagged/:tag_name
SO teh view is seeing it, but the controller is not getting it. Because
in the console, using a string in place of params(:tag_name) returns an
actual entry.
*Controller*
<code>
def tagged
# This should take the :tag_name in the url string and pull
elements that match
# It does not. I suck as a programmer.
@elements = Element.find_tagged_with(params[:tag_name])
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @elements.to_xml }
end
end
</code>
*Models*
<code>
class Element < ActiveRecord::Base
acts_as_taggable
[...]
end
</code>
*CONSOLE*
This does work:
<code>
soho:~/Sites/work/koji jathayde$ script/console
Loading development environment.>> @elements = Element.find_tagged_with("spam")
DEPRECATION WARNING: The :dependent => true option is deprecated and
will be removed from Rails 2.0. Please use :dependent => :destroy
instead. See http://www.rubyonrails.org/deprecation for details. See
http://www.rubyonrails.org/deprecation for details. (called from
has_many at
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5618/lib/active_record/associations.rb:550)
=> [#<Element:0x330a8d8 @attributes={"name"=>"Koji Test
One",
"updated_at"=>"2006-11-30 18:16:40",
"id"=>"1", "description"=>"supa
sexy description", "filename"=>nil,
"element_type_id"=>"3",
"created_at"=>nil}]
But this does not (because there is no value in params[:tag_list]:
> @elements = Element.find_tagged_with(params[:tag_list])
NameError: undefined local variable or method `params'' for
#<Object:0x1f59f0>
from (irb):4
from :0
</code>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---