Class: Components::NewCommentForm
- Inherits:
-
Base
- Object
- Base
- Components::NewCommentForm
- Includes:
- Phlex::Rails::Helpers::FormFor
- Defined in:
- app/components/new_comment_form.rb
Instance Method Summary collapse
-
#initialize(commentable:) ⇒ NewCommentForm
constructor
A new instance of NewCommentForm.
- #render? ⇒ Boolean
- #view_template ⇒ Object
Constructor Details
#initialize(commentable:) ⇒ NewCommentForm
Returns a new instance of NewCommentForm.
8 9 10 11 |
# File 'app/components/new_comment_form.rb', line 8 def initialize(commentable:) @commentable = commentable @comment = @commentable.comments.new end |
Instance Method Details
#render? ⇒ Boolean
13 14 15 |
# File 'app/components/new_comment_form.rb', line 13 def render? policy(@comment).create? end |
#view_template ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/new_comment_form.rb', line 17 def view_template form_for [@commentable, @comment] do |f| div class: "new-comment-form-component", name: "new-comment" do div(class: "comment-header") do div do Icon(icon: "pen") whitespace span { t("components.new_comment_form.title") } end end div(class: "comment-body") do f.text_area(:comment, class: "form-control", placeholder: translate("components.new_comment_form.placeholder")) end div(class: "comment-footer") do f.submit t("components.new_comment_form.submit") end end end end |