Class: Kwipper::CommentsController
- Inherits:
-
Controller
- Object
- Controller
- Kwipper::CommentsController
- Defined in:
- app/controllers/comments_controller.rb
Constant Summary
Constants inherited from Controller
Constants included from RendersViews
RendersViews::VIEWS_PATH, RendersViews::VIEW_EXT
Instance Attribute Summary
Attributes inherited from Controller
#action, #app, #request, #response
Instance Method Summary collapse
Methods inherited from Controller
add_routes, #home, #initialize, #process
Methods included from RendersViews
Constructor Details
This class inherits a constructor from Kwipper::Controller
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/comments_controller.rb', line 14 def create require_login! post = Post.find params['id'] comment = Comment.new({ 'user_id' => current_user.id, 'post_id' => post.id, 'created_at' => Time.now.httpdate, 'content' => params['content'] }) if comment.save redirect "/kwips/show?id=#{post.id}" else redirect "/kwips/comments/new?id=#{post.id}", :bad_request end end |