diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-17 12:15:19 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-17 12:15:19 -0700 |
| commit | 980df161d60df14af98733057649cdd6ba98deca (patch) | |
| tree | d1e6f078400a283a486bcbaa8fa309f8d1f2a305 /app/controllers | |
| parent | 6dfba2b4603e2711a40c909361057677d65c72b1 (diff) | |
inline handler to add a cake to someones favorites.
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/favorites_controller.rb | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index a8b56bdc..095cc23a 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -1,11 +1,6 @@ class FavoritesController < ApplicationController before_action :authenticate! - def initialize(command_bus = Spank::IOC.resolve(:command_bus)) - @bus = command_bus - super() - end - def index @creation = Creation.find(params[:cake_id]) @favorites = @creation.favorites @@ -13,11 +8,8 @@ class FavoritesController < ApplicationController def create cake = Creation.find(params[:cake_id]) - bus.publish(:add_cake_to_favorites, { user_id: current_user.id, cake_id: cake.id }) + current_user.add_favorite(cake) + redirect_to cake_path(cake), notice: "This has been added to your favorites" end - - private - - attr_reader :bus end |
