Update: deleted since it is now redundant
Update: switch to acts_as_taggable_on_steroids more features, less pain/bugs 🙂
Need simple input/output for tags and got acts_as_taggable_on_steroids ?
…..
and in your forms:
f.text_area('tag_list')
Done!
#Spec: it "does not create duplicated tags" do @taggable.tag_list = "Bad, Bad, Evil" @taggable.save! @taggable.tags.size.should == 2 end #Often need count of Tags ? #taggings.rb belongs_to :tag, :counter_cache=>'taggings_count'
hi
xplanation of tags is good using as reference
i am implementing a application using acts as taggable.
my app contain tables like
1)streams table
for tag support
1)tags table
2)taggings table
my requirement is i want to search the data from streams table using tagname assing to the streams table entry.
to achieve this i have modifid my code like:
1)i am typing the tagname in search box.
2)the enterd text is recieved and to search with the text i have added a methos called get_results like:
def get_results
if request.xhr?
if params[‘search_text’].strip.length > 0
terms = params[‘search_text’].split.collect do |word|
“%#{word.downcase}%”
end
if blank?
flash[:notice] = ‘Stream was successfully updated.’
else
#@streams = Stream.find_tagged_with(
@streams = Stream.find(:all, :joins => “streams inner join tags as t on
stream.id=t.id”, :conditions => [‘name LIKE ?’,’%’+params[:search_text]+’%’],select => “name”)
end
end
render :partial => “search”
else
redirect_to :action => “index”
end
end
i am getting erros like :
wrong number of arguments (0 for 1)
app/controllers/streams_controller.rb:72:in `select’
app/controllers/streams_controller.rb:72:in `get_results’
Parameters:
{“authenticity_token”=>”310fff3b3d649a7d724f5fb128e8954d24004890”,
“search_text”=>”mpeg2”}
how to use Stream.find_taggable_with in the search method instead of writing the query?
thanks
Srikanth
as far as i understand your problem you are trying to find everything tagged with %name% AND %other% so if Stream1 is tagged with” myname” AND “myother” it should be found ?
judging from a quick code review, this should be accomplished by
find_all_tagged_with([‘%name%’,’%other%’])
hope this helps 🙂
if not, you could try asking the authors…