hummingbird-me/hummingbird

View on GitHub
app/views/quotes/_new.html.haml

Summary

Maintainability
Test Coverage
:css
  .twitter-typeahead .tt-dropdown-menu {
    left: 0px !important;
    width: 100% !important;
    top: 32px !important;
  }

%h3 New "#{@anime.canonical_title(current_user)}" quote

= form_for Quote.new, :url => anime_quotes_path(@anime) do |f|
  = f.label :content
  = f.text_area :content, rows: 5

  = f.label :character
  = f.text_field :character_name, class: "#{@anime.slug}_character_name"

  = f.submit class: "button padded"

:javascript
  $("input.#{@anime.slug}_character_name").typeahead({
    name: '#{@anime.slug}_character_name',
    prefetch: '#{anime_casts_url(@anime, type: 'character_names', format: :json)}',
    local: #{@anime.castings.where(featured: true).includes(:character).select {|x| x.character_id }.map {|x| x.character.name }.map {|x| x.strip }.uniq.to_json}
  });