Advertisement
sas2job

Untitled

Feb 28th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. def update
  2. @datum = OtherDatum.friendly.find_or_initialize_by(slug: params[:id]) do |data|
  3. data.title = params[:other_datum][:title]
  4. data.number = params[:other_datum][:number]
  5. data.roles = params[:other_datum][:roles]
  6. end
  7. byebug
  8. # if @datum.update(other_datum_params.merge(slug: params[:id]))
  9. if @datum.valid?
  10. # @datum.save
  11. # redirect_to({:action => :index}, {:notice => 'Data updated'})
  12. else
  13. # puts @datum.object_id
  14. byebug
  15. render :edit
  16. end
  17. end
  18.  
  19. def other_datum_params
  20. params.require(:other_datum).permit(:title, :number, :roles, :slug)
  21. end
  22.  
  23.  
  24. Log:
  25.  
  26.  
  27. [22, 31] in /home/usr/Dropbox/tech/tech/app/controllers/admin/other_data_controller.rb
  28. 22: data.number = params[:other_datum][:number]
  29. 23: data.roles = params[:other_datum][:roles]
  30. 24: end
  31. 25: byebug
  32. 26: # if @datum.update(other_datum_params.merge(slug: params[:id]))
  33. => 27: if @datum.valid?
  34. 28: # @datum.save
  35. 29: # redirect_to({:action => :index}, {:notice => 'Data updated'})
  36. 30: else
  37. 31: # puts @datum.object_id
  38. (byebug) @datum
  39. #<OtherDatum id: nil, title: "Тест", number: nil, created_at: nil, updated_at: nil, slug: "satellite", roles: [""]>
  40. (byebug) c
  41.  
  42. [28, 37] in /home/usr/Dropbox/tech/tech/app/controllers/admin/other_data_controller.rb
  43. 28: # @datum.save
  44. 29: # redirect_to({:action => :index}, {:notice => 'Data updated'})
  45. 30: else
  46. 31: # puts @datum.object_id
  47. 32: byebug
  48. => 33: render :edit
  49. 34: end
  50. 35: end
  51. 36:
  52. 37: def other_datum_params
  53. (byebug) @datum
  54. #<OtherDatum id: nil, title: "Тест", number: nil, created_at: nil, updated_at: nil, slug: nil, roles: [""]>
  55. (byebug) I, [2020-02-28T17:09:56.302596 #5738] INFO -- : SIGWINCH ignored because we're not daemonized
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement