Skip to content

Instantly share code, notes, and snippets.

@theconektd
Created February 6, 2009 17:17
Show Gist options
  • Select an option

  • Save theconektd/59505 to your computer and use it in GitHub Desktop.

Select an option

Save theconektd/59505 to your computer and use it in GitHub Desktop.
## 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