Displaying 2 results from an estimated 2 matches for "contents_tags".
Did you mean:
content_tag
2006 Mar 13
5
Displaying related entries by tags - HELP!
...li><%= related.title %><br /></li>
<% end %>
#controller (how do I pass the tag_id and the content_id?)
@contents_related = Content.show_related_entries(?,?)
#model
def self.show_related_entries(t_id, c_id)
find_by_sql("select c.title from contents c inner join contents_tags
ct on c.id = ct.content_id where ct.tag_id = #{t_id} and c.id !=
#{c_id}")
end
The function works if I manually pass a content_id (for my entry) and a
tag id (for a tag of that entry). Now, how can I dynamically pull out
the single content_id for the post, but execute the function for...
2012 Apr 18
1
has_and_belongs_to_many: Item Already in Collection?
I''m putting together what should be a simple app using content and
tags
using has_and_belongs_to_many for each.
create_table :contents_tags, :id => false do |t|
t.references :content
t.references :tag
end
When a user tries to add a new tag, I''m trying to detect if the
content already has the tag.
So ... I grab the tag like this:
tag = Tag.where("name = ?", tag_name)
Then I''m trying...