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/models/post.rb | |
class Post < ActiveRecord::Base | |
include Commentable | |
end |
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/models/concerns/commentable.rb | |
module Commentable | |
def self.include(base) | |
base.class_eval do | |
has_many :comment, as: :commentable | |
end | |
end | |
def comment_by_user(id) | |
comments.where(user_id: id) |
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/models/comment.rb | |
class Comment < ActiveRecord::Base | |
belongs_to :commentable, polymorphic: true | |
end |
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/models/image.rb | |
class Image < ActiveRecord::Base | |
has_many :comments, as: :commentable | |
def comment_by_user(id) | |
comments.where(user_id: id) | |
end | |
end |
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/models/post.rb | |
class Post < ActiveRecord::Base | |
has_many :comments, as: :commentable | |
def comment_by_user(id) | |
comments.where(user_id: id) | |
end | |
end |
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
# -*- encoding: utf-8 -*- | |
require File.expand_path('../lib/coconut/version', __FILE__) | |
Gem::Specification.new do |gem| | |
gem.authors = ["Eky Fauzi"] | |
gem.email = ["[email protected]"] | |
gem.description = %q{This is my first gem} | |
gem.summary = %q{I love to code with gem!} | |
gem.homepage = "" | |
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
// Autoheight for element with class .autoheight to be 100% height | |
$('.autoheight').css({ height: $(window).innerHeight() }); | |
// Auto resize height if window resize | |
$(window).resize(function(){ | |
$('.autoheight').css({ height: $(window).innerHeight() }); | |
}); |
NewerOlder