Crazy votes tallying

@jmileham @samandmoore 

Add votes table, remove votes columns from other tables.

Calculate votes scoped to parent, front page only shows the top tags w/o parents. (haven't built the query  that calculate global votes yet...)

weirdness: every tag exists as a top level tag
also, if i go to /foo/bar, where foo and bar have not been created before it will:
create foo top level tag, mapping, and a vote for that mapping
create bar top level tag, mapping, and vote for that mapping
create mapping of bar to parent foo, with a vote for that mapping

#HASHTAGFTW

Sgtm
On Jul 20, 2014 2:38 PM, "Harris Effron" <notifications@github.com> wrote:

> In app/models/mapping.rb:
>
> > +    parent_string = params[:parent_content] || ''
> > +
> > +    parent = Tag.where(content: parent_string.downcase).first_or_create
> > +    tag = Tag.where(content: params[:content].downcase).first_or_create
> > +
> > +    mapping = Mapping.where(parent: parent, tag: tag).first_or_initialize
> > +
> > +    mapping
> > +  end
> > +
> > +  def content
> > +    tag && tag.content
> > +  end
> > +
> > +  def score
> > +    votes.size
>
>
> http://apidock.com/rails/ActiveRecord/Associations/AssociationCollection/size
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/effron/hashtags/pull/4/files#r15151203>.
>