Guest User

Untitled

a guest
Jan 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. # I think this might be a better abstraction
  2. class ThingController < ApplicationController
  3.  
  4. def create
  5. seller = Seller.new(current_user)
  6. @thing = seller.list_thing(params[:thing])
  7. if @thing.valid?
  8. redirect_to(user_thing_path(@thing.seller, @thing))
  9. else
  10. render :new
  11. end
  12. end
  13.  
  14. end
  15.  
  16. class Seller
  17. initialize(user)
  18. @user = user
  19. end
  20.  
  21. def list_thing(thing_attrs)
  22. @user.things.create(thing_attrs)
  23. end
  24. end
Add Comment
Please, Sign In to add comment