-
-
Save h-lame/279963 to your computer and use it in GitHub Desktop.
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 SomeController | |
before_filter :find_product | |
before_filter :sanitise_segment | |
def show | |
@product.reviews.for_segment(@segment).order_by(sort_order) | |
end | |
def show_extended_detail | |
@product.reviews.for_segment(@segment).order_by(sort_order) | |
… | |
end | |
protected | |
def sort_order | |
# Google was indexing "random" search orders, it parsed our javascript, badly. | |
SORT_METHODS[params[:sort_order]] or raise_redirect_to(@product, :status => 301) | |
end | |
def find_product | |
@product = … | |
end | |
def sanitise_segment | |
@segment = params[:segment] | |
@segment = @segment.to_sym if %w[all other].include?(@segment) | |
@segment = nil if @segment == :all | |
# Bad or expired segments need 301ing | |
redirect_to(@product, :status => 301) if @segment === String and [email protected]?(segment) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment