Class: Kwipper::PostFavoritesController

Inherits:
Controller
  • Object
show all
Defined in:
app/controllers/post_favorites_controller.rb

Constant Summary

Constants inherited from Controller

Controller::ROUTES

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

#render

Constructor Details

This class inherits a constructor from Kwipper::Controller

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/post_favorites_controller.rb', line 5

def create
  require_login!
  
  post = Post.find params['id']
  fave = PostFavorite.create({
    'user_id' => current_user.id,
    'post_id' => post.id
  })

  redirect "/kwips/show?id=#{post.id}"
end