Permalink
Browse files

added tagging autocompletion, issue 54

  • Loading branch information...
1 parent c6f5dcf commit a64cf31df2fdabb19803ae11565f317728258725 @dmitryame committed Jan 6, 2009
@@ -6,11 +6,14 @@ class ConversationsController < ApplicationController
auto_complete_with_scope_for 'published', :conversation, :name # multiple scopes can be chained like 'published.readonly'
+ auto_complete_for :tag, :name
+
def complete_name
@conversation = Conversation.published.find_by_name(params[:id])
redirect_to conversation_messages_path(@conversation)
end
+
def index
@conversations = Conversation.published.not_personal.paginate :page => params[:page], :order => 'created_at DESC'
respond_to do |format|
@@ -186,7 +189,7 @@ def invite_from_list
def add_tag
@conversation = Conversation.published.find(params[:id])
- current_user.tag(@conversation, :with => @conversation.tags.collect{|tag| tag.name}.join(", ") + ", " + params[:tag].to_s, :on => :tags)
+ current_user.tag(@conversation, :with => @conversation.tags.collect{|tag| tag.name}.join(", ") + ", " + params[:tag][:name].to_s, :on => :tags)
end
def remove_tag
@@ -5,9 +5,11 @@ class MessagesController < ApplicationController
public :render_to_string # this is needed to make render_to_string public for message model to be able to use it
before_filter :login_required, :except => [:index, :show, :get_more_messages ]
- before_filter :find_conversation, :except => :send_data
+ before_filter :find_conversation, :except => [ :send_data, :auto_complete_for_tag_name]
before_filter :check_write_access, :only => [ :create ]
after_filter :store_location, :only => [:index]
+
+ auto_complete_for :tag, :name
def index
@messages = @conversation.messages.published.find(:all, :include => [:user], :limit => 100, :order => 'id DESC').reverse
@@ -4,7 +4,7 @@
<div class="clear"></div>
<%if current_user%>
<% form_remote_tag(:url => {:controller => 'conversations', :action => 'add_tag', :id => @conversation.id}) do %>
- <%= text_field 'tag', '', :size => 15 %>
+ <%= text_field_with_auto_complete :tag, :name -%>
<%= submit_tag t("ui.add_tag") %>
<%end%>
<% end %>

0 comments on commit a64cf31

Please sign in to comment.