Permalink
Please sign in to comment.
Showing
with
118 additions
and 12 deletions.
- +21 −0 app/assets/stylesheets/application.css
- +8 −0 app/controllers/comments_controller.rb
- +2 −2 app/controllers/stories_controller.rb
- +1 −0 app/models/comment.rb
- +29 −0 app/models/hat.rb
- +1 −0 app/models/user.rb
- +13 −9 app/views/comments/_comment.html.erb
- +9 −0 app/views/comments/_commentbox.html.erb
- +10 −0 app/views/users/show.html.erb
- +13 −0 db/migrate/20141114184921_add_hats.rb
- +11 −1 db/schema.rb
| @@ -0,0 +1,29 @@ | ||
| class Hat < ActiveRecord::Base | ||
| belongs_to :user | ||
| belongs_to :granted_by_user, | ||
| :class_name => "User" | ||
| validates :user, :presence => true | ||
| validates :granted_by_user, :presence => true | ||
| def to_html_label | ||
| h = "<span class=\"hat\" title=\"Granted by " << | ||
| "#{self.granted_by_user.username} on " << | ||
| "#{self.created_at.strftime("%Y-%m-%d")}\">" << | ||
| "<span class=\"crown\">" | ||
| if self.link.present? | ||
| h << "<a href=\"#{self.link}\" target=\"_blank\">" | ||
| end | ||
| h << self.hat | ||
| if self.link.present? | ||
| h << "</a>" | ||
| end | ||
| h << "</span></span>" | ||
| h.html_safe | ||
| end | ||
| end |
| @@ -0,0 +1,13 @@ | ||
| class AddHats < ActiveRecord::Migration | ||
| def change | ||
| create_table :hats do |t| | ||
| t.timestamps | ||
| t.integer :user_id | ||
| t.integer :granted_by_user_id | ||
| t.string :hat | ||
| t.string :link | ||
| end | ||
| add_column :comments, :hat_id, :integer | ||
| end | ||
| end |
0 comments on commit
31d4e97