Created
November 21, 2013 22:30
-
-
Save brycesenz/7590969 to your computer and use it in GitHub Desktop.
Shelby's Presenter example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SquirtlesController < ApplicationController | |
has_scope :shell do |scope, value| | |
(value == 'all') ? scope : scope.where(shell: value) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.squirtlicious { | |
select { width: 10em; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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