Guest User

Untitled

a guest
Jun 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. def create1
  2. # is this unsecure? should we grab user_id from the session
  3. params[:venue]['user_id'] = params[:user_id]
  4.  
  5. begin
  6. venue = Venue.create(params[:venue])
  7. @user_venues = @user.venues
  8. render :partial => 'venue_select_box', :success => true, :status => :ok
  9. rescue ActiveRecord::RecordInvalid
  10. render :text => 'Put errors in here', :success => false, :status => :unprocessable_entity
  11. end
  12. end
  13.  
  14. def create2
  15. # is this unsecure? should we grab user_id from the session
  16. params[:venue]['user_id'] = params[:user_id]
  17.  
  18. venue = Venue.new(params[:venue])
  19. if venue.save
  20. @user_venues = @user.venues
  21. render :partial => 'venue_select_box', :success => true, :status => :ok
  22. else
  23. render :text => 'Put errors in here', :success => false, :status => :unprocessable_entity
  24. end
  25. end
  26.  
  27. class VenuesController < ApplicationController
  28. def create
  29. @venue = @user.venues.create!(params[:venue])
  30. render :partial => 'venue_select_box', :success => true, :status => :ok
  31. end
  32.  
  33. rescue_from ActiveRecord::RecordInvalid do
  34. render :text => 'Put errors in here', :success => false, :status => :unprocessable_entity
  35. end
  36. end
Add Comment
Please, Sign In to add comment