Introducing comma as tag separator (if present, otherwise it behaves as before), allowing spaces in tags. fixes #2032

This commit is contained in:
Štefan Baebler 2009-07-07 22:05:03 +00:00
parent c0b9420c7b
commit ebbcf63f0d
3 changed files with 18 additions and 10 deletions

View file

@ -20,16 +20,24 @@ class Trace < ActiveRecord::Base
end
def tagstring
return tags.collect {|tt| tt.tag}.join(" ")
return tags.collect {|tt| tt.tag}.join(", ")
end
def tagstring=(s)
if s.include?','
self.tags = s.split(/\s*,\s*/).collect {|tag|
tt = Tracetag.new
tt.tag = tag
tt
}
else
self.tags = s.split().collect {|tag|
tt = Tracetag.new
tt.tag = tag
tt
}
end
end
def large_picture= (data)
f = File.new(large_picture_name, "wb")

View file

@ -27,8 +27,8 @@
<%= t'trace.trace.by' %> <%=link_to h(trace.user.display_name), {:controller => 'user', :action => 'view', :display_name => trace.user.display_name} %>
<% if !trace.tags.empty? %>
<%= t'trace.trace.in' %>
<% trace.tags.each do |tag| %>
<%= link_to_tag tag.tag %>
<% trace.tags.each_with_index do |tag, index| %>
<%= link_to_tag tag.tag %><%=', ' if index+1 < trace.tags.count %>
<% end %>
<% end %>
</td>

View file

@ -36,8 +36,8 @@
<td><%= t'trace.view.tags' %></td>
<td>
<% unless @trace.tags.empty? %>
<% @trace.tags.each do |tag| %>
<%= link_to tag.tag, { :controller => 'trace', :action => 'list', :tag => tag.tag, :id => nil } %>
<% @trace.tags.each_with_index do |tag, index| %>
<%= link_to tag.tag, { :controller => 'trace', :action => 'list', :tag => tag.tag, :id => nil } %><%=', ' if index+1 < @trace.tags.count %>
<% end %>
<% else %>
<i><%= t'trace.view.none' %></i>