Skip to content

Instantly share code, notes, and snippets.

@kevinpfromnm
Created June 29, 2011 04:12
Show Gist options
  • Save kevinpfromnm/1053091 to your computer and use it in GitHub Desktop.
Save kevinpfromnm/1053091 to your computer and use it in GitHub Desktop.
example from tagglable hobo plugin (hobo 1.0.x)
autocomplete :new_tag_name do
post = find_instance
items = Tag.find(:all,:conditions => ['name LIKE ?',"%#{params[:query]}%"]).select { |i| i.viewable_by?(current_user) }
items = items - post.tags
render :text => "<ul>\n" +
items.map { |i| "<li>#{i.name}</li>\n" }.join +
"</ul>"
end
<def tag="tag-list">
<% target = this %>
<h3 param="tag-heading">Tags</h3>
<div param="collection-wrap">
<collection:taggings part="tags">
<a:tag /><delete-button label="x" />
</collection>
</div>
<form with="&this.taggings.new" update="tags" reset-form refocus-form param>
<div>
<label for="tagging[tag]" param>Add a tag:</label>
<name-one:tag complete-target="&target" completer="new_tag_name" />
</div>
</form>
</def>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment