Skip to content

Instantly share code, notes, and snippets.

@brycesenz
Created November 21, 2013 22:30
Show Gist options
  • Save brycesenz/7590969 to your computer and use it in GitHub Desktop.
Save brycesenz/7590969 to your computer and use it in GitHub Desktop.
Shelby's Presenter example
class PokemonDecorator < Draper::Decorator
def squirtle_scope
h.select_tag("shell", colors(current), class: "squirtlicious")
end
def colors(current)
current = 1
h.options_for_select({
"Blue" => 1,
"Green" => 2,
"Yellow" => 3
}, selected: current)
end
end
class SquirtlesController < ApplicationController
has_scope :shell do |scope, value|
(value == 'all') ? scope : scope.where(shell: value)
end
end
.squirtlicious {
select { width: 10em; }
}
.div.squirtlicious
= pokemon.decorate.squirtle_scope
%table
%tbody
- @squirtles.each do |s|
%tr
%td= s.shell
%td= s.name
%td= s.catch_rate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment