Guest User

Untitled

a guest
Jun 16th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. ##Log Results
  2. 1) Error:
  3. test_should_get_edit(UsersControllerTest):
  4. ActionView::TemplateError: Called id for nil, which would mistakenly be 4 -- if
  5. you really wanted the id of nil, use object_id
  6. On line #3 of app/views/users/edit.html.erb
  7.  
  8. 1: <h1>Editing user</h1>
  9. 2:
  10. 3: <% form_for(@user) do |f| %>
  11. 4: <%= f.error_messages %>
  12. 5:
  13. 6: <p>
  14.  
  15. app/views/users/edit.html.erb:3
  16. /test/functional/users_controller_test.rb:29:in `test_should_get_edit'
  17. C:/Ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
  18. C:/Ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
  19. C:/Ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
  20. C:/Ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
  21. C:/Ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
  22. C:/Ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
  23. C:/Ruby/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite
  24. '
  25. C:/Ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in `start_med
  26. iator'
  27. C:/Ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in `start'
  28. C:/Ruby/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in `run'
  29. C:/Ruby/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
  30. C:/Ruby/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
  31. C:/Ruby/lib/ruby/1.8/test/unit.rb:278
  32. rake (0.8.4) lib/rake/rake_test_loader.rb:5
  33.  
  34. ##UsersControllerTest
  35. test "should get edit" do
  36. get :edit, :id => users(:one).to_param
  37. assert_response :success
  38. end
  39.  
  40.  
  41. ##UserController
  42. class UsersController < ApplicationController
  43. def login
  44. @user = User.new
  45. @user.email = params[:email]
  46. end
  47.  
  48. def process_login
  49. if user = User.authenticate(params[:user])
  50. session[:id] = user.id # Remember the user's id during this session
  51. redirect_to session[:return_to] || '/'
  52. else
  53. flash[:error] = 'Invalid login.'
  54. redirect_to :action => 'login', :email => params[:user][:email]
  55. end
  56. end
  57.  
  58. def logout
  59. reset_session
  60. flash[:message] = 'Logged out.'
  61. redirect_to :action => 'login'
  62. end
  63.  
  64. def my_account
  65. end
  66. end
  67.  
  68. ##Users.yml
  69. one:
  70. id: 1
  71. password: MyString
  72. email: MyString
  73.  
  74. ##User view
  75. <h1>Editing user</h1>
  76.  
  77. <% form_for(@user) do |f| %>
  78. <%= f.error_messages %>
  79.  
  80. <p>
  81. <%= f.label :password %><br />
  82. <%= f.text_field :password %>
  83. </p>
  84. <p>
  85. <%= f.label :email %><br />
  86. <%= f.text_field :email %>
  87. </p>
  88. <p>
  89. <%= f.submit 'Update' %>
  90. </p>
  91. <% end %>
  92.  
  93. <%= link_to 'Show', @user %> |
  94. <%= link_to 'Back', users_path %>
Add Comment
Please, Sign In to add comment