diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-31 15:25:33 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-31 15:25:33 -0700 |
| commit | 2a2da0f08f23401426674ba59cc36518beb27864 (patch) | |
| tree | d4240819880b8911a2dead18c5fa0204f056638b /app/controllers | |
| parent | 52b41be14910a4e7f84e105e3a577dac1f988053 (diff) | |
| parent | c64e5008a494d1236e80df5583104bdc3b02bff4 (diff) | |
Merge branch 'master' of github.com:cakeside/cakeside into session-store
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/api/v1/cakes_controller.rb | 22 | ||||
| -rw-r--r-- | app/controllers/cakes_controller.rb | 2 |
2 files changed, 9 insertions, 15 deletions
diff --git a/app/controllers/api/v1/cakes_controller.rb b/app/controllers/api/v1/cakes_controller.rb index 195dcfc7..8888d286 100644 --- a/app/controllers/api/v1/cakes_controller.rb +++ b/app/controllers/api/v1/cakes_controller.rb @@ -10,25 +10,19 @@ module Api end def create - CreateCakeCommand.new(self).run(cake_params, params[:cake][:tags]) - end - - def create_cake_succeeded(cake) - @cake = cake - end - - def create_cake_failed(cake) - @cake = cake + name = cake_params[:name] + category = Category.find(cake_params[:category_id]) + @cake = current_user.create_cake(name: name, category: category) + if @cake.save + one_hour = 1.hour.from_now + PublishToTwitterJob.set(wait_until: one_hour).perform_later(@cake) + end end def update @cake = current_user.creations.find(params[:id]) current_user.tag(@cake, with: params[:cake][:tags], on: :tags) - if @cake.update(cake_params.reject { |key, value| key == "tags" }) - @cake - else - @cake - end + @cake.update!(cake_params.reject { |key, _| key == "tags" }) end def destroy diff --git a/app/controllers/cakes_controller.rb b/app/controllers/cakes_controller.rb index e5396163..2cc418f4 100644 --- a/app/controllers/cakes_controller.rb +++ b/app/controllers/cakes_controller.rb @@ -5,7 +5,7 @@ class CakesController < ApplicationController end def index - @creations = @repository.search_with(params).page(page).per(per_page) + @cakes = @repository.search_with(params).distinct.page(page).per(per_page) end def show |
