Created
February 6, 2009 17:17
-
-
Save andyferra/59505 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
## app/helpers/movies_helper.rb | |
module MoviesHelper | |
link_to_movie(movie) | |
case movie.type | |
when 'internal': internal_movie_link(movie) | |
when 'external': external_movie_link(movie) | |
else normal_movie_link(movie) | |
end | |
end | |
def internal_movie_link(movie) | |
# ... | |
end | |
def external_movie_link(movie) | |
# ... | |
end | |
def normal_movie_link(movie) | |
# ... | |
end | |
end | |
## app/views/movies/index.html.erb | |
<% @movies.each do |movie| %> | |
<%= link_to_movie(movie) %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment