-
-
Save andreapavoni/6062010 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
#commit model | |
class Commit < ActiveRecord::Base | |
# 1) We don't need a provider based Commit subclass, a String field | |
# should be enough. In case, we can associate a Provider model | |
# (1 to 1 relation) that represents a specific provider | |
# 2) we might want to use commit IDs, then build the commit URL at runtime | |
# (perhaps an URL template specific to the provider should be specified in Provider model) | |
# this shuould prevent eventual URL changes by providers :-) | |
attr_accessible :commit_url, :author, :commit_message, :provider | |
end | |
#story model | |
class Story < ActiveRecord::Base | |
has_many :notes | |
has_many :commits | |
end | |
#view | |
# I'd split notes and commits because they should be two separate contexts | |
# In case, we can merge them in a unique Array and do a sort by timestamp, so | |
# they can appear mixed with proper ordering | |
<% story.notes.each do |note| %> | |
<%= render partial: :note %> | |
<% end %> | |
<% story.commits.each do |commit| %> | |
<%= render partial: commit.provider %> | |
<% end %> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment