tags

How to fix duplicate taggings?

前提是你 提交于 2020-02-01 08:23:55
问题 Users can submit tags for Habits, Goals, Values, and Stats. When a user clicks on a tag in the tag_cloud he is redirected to the home page with all the instances of that tag, but for some reason the instances that fall under Habits are duplicating. Any ideas on why this is? pages_controller @habits = current_user.habits.tagged_with(params[:tag]) habit.rb class Habit < ActiveRecord::Base belongs_to :user acts_as_taggable before_save :set_tag_owner def set_tag_owner # Set the owner of some tags

How to remove all git origin and local tags?

青春壹個敷衍的年華 提交于 2020-01-30 13:43:26
问题 How do you remove a git tag that has already been pushed? Delete all git remote (origin) tags and Delete all git local tags. 回答1: 1. Delete All local tags. (Optional Recommended) git tag -d $(git tag -l) 2. Fetch remote All tags. (Optional Recommended) git fetch 3. Delete All remote tags. git push origin --delete $(git tag -l) # Pushing once should be faster than multiple times 4. Delete All local tags. git tag -d $(git tag -l) 回答2: For windows using command prompt: Deleting local tags: for

Read php tags inside a non-php file and execute

蓝咒 提交于 2020-01-30 06:27:24
问题 What I'm trying to achieve is build a simple and lightweight theme engine, where anyone will be able to create his own template easily, I have managed to do this using PHP, and for example, if someone wants to input the logo, all they have to do is use: {logo} , and etc. The template files extensions are '.inc'.. My problem is, i don't know how to allow users to still execute php code, using PHP (< ?php ?>) tags. I have tried both adding this in my htaccess: AddType application/x-httpd-php

How can I “merge” two HTML tags via JavaScript

你离开我真会死。 提交于 2020-01-25 20:22:08
问题 Here is my HTML "sandbox": <p>1 2 3</p> <span id="myid"> <span id="mytext"> <p>4 5 6</p> <p>7 8 9</p> <p>10 11 12</p> </span> </span> <p>13 14 15</p> I would like to "merge" the p tags accordingly: (To make it easier to see I've added a minus sign where I've made the changes:) <p>1 2 3 - <span id="myid"> <span id="mytext"> - 4 5 6</p> <p>7 8 9</p> <p>10 11 12 - </span> </span> - 13 14 15</p> Every place I've added a minus sign, I have actually stripped a <p> or </p> tag making a merge between

Find tags with articles

强颜欢笑 提交于 2020-01-24 23:34:25
问题 On blog app I want to display list of tags with articles. class Article < AR::B has_and_belongs_to_many :tags end class Tag < AR::B has_and_belongs_to_many :articles end What would Tag scope look like? Tag.joins(:articles) ... # should return tags associated to at least 1 article 回答1: One way to do this with Ruby/Rails would be this one. Tag.includes(:articles).select { |tag| tag.articles.any? } .includes makes sure that the articles are loaded alongside the tags, which is more efficient than

Parsing specific HTML tags in Javascript

丶灬走出姿态 提交于 2020-01-24 17:12:06
问题 I'm looking for the Javascript to parse the following HTML: <p>random text random text random text random text</p> <kbd><h2>Heading One</h2>Body text Body text Body text Body text</kbd> <p>random text random text random text random text</p> ... and return just: Heading One In other words, I'd like to strip all tags and Body Text from within the <kbd> tags. Any ideas would be greatly appreciated! 回答1: var input = /* that HTML string here */; var div = document.createElement('div'); div

Wordpress - Delete all tags by Post ID

为君一笑 提交于 2020-01-24 16:30:46
问题 I've got a function to add a tag by post ID, but now I would like to delete all the current tags for that ID before adding my new tags? Does anyone know a built in function or wordpress query to do this? -Hudson 回答1: If you can access the database directly (PhpMyAdmin), the quickest way is a SQL request. Look at the database schema in the codex : DELETE FROM wp_term_relationships WHERE wp_term_relationships.object_id = 'yourPostId' AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy

Wordpress - Delete all tags by Post ID

醉酒当歌 提交于 2020-01-24 16:30:05
问题 I've got a function to add a tag by post ID, but now I would like to delete all the current tags for that ID before adding my new tags? Does anyone know a built in function or wordpress query to do this? -Hudson 回答1: If you can access the database directly (PhpMyAdmin), the quickest way is a SQL request. Look at the database schema in the codex : DELETE FROM wp_term_relationships WHERE wp_term_relationships.object_id = 'yourPostId' AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy

Using python/BeautifulSoup to replace HTML tag pair with a different one

China☆狼群 提交于 2020-01-23 23:10:53
问题 I need to replace a matching pair of HTML tags by another tag. Probably BeautifulSoup (4) would be suitable for the task, but I've never used it before and haven't found a suitable example anywhere, can someone give me a hint? For example, this HTML code: <font color="red">this text is red</font> Should be changed to this: <span style="color: red;">this text is red</span> The beginning and ending HTML tags may not be in the same line. 回答1: Use replace_with() to replace elements. Adapting the

Control for tags with auto-completion in Winforms?

偶尔善良 提交于 2020-01-23 08:42:10
问题 I am seeking a WinForm control that would provide an autocomplete behavior for multiple space-separated - exactly ala del.icio.us (or stackoverflow.com for that matter). Does anyone knows how to do that within a .NET 2.0 WinForm application? 回答1: ComboBox can autocomplete, but only one word at a time. If you want to have each word separately autocompleted, you have to write your own. I already did, hope it's not too long. It's not 100% exactly what you want, this was used for autocompleting