Guest User

Untitled

a guest
Jun 24th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.75 KB | None | 0 0
  1. ## users_controller.rb
  2. def get_question
  3. #make sure no to send html but text/plain
  4. @user = User.find_by_email(params[:email])
  5. if @user
  6. @question = SecretQuestion.find(@user.secret_question_id)
  7. if @question
  8. data = @question.question
  9. render :text => data.to_json
  10. else
  11. data = { :NotFound => 'true' }
  12. render :text => data.to_json
  13. end
  14. end
  15. end
  16.  
  17. ## routes.rb
  18. map.connect '/get_question/:email', :controller => 'users', :action => 'get_question', :conditions => { :method => :get }
  19.  
  20. ## recover.html.erb
  21. <% content_for :javascript do %>
  22. <script type="text/javascript">
  23. $(document).ready(function() {
  24. alert("ready");
  25. $("#btnGetQuestion").click(function() {
  26. alert("click");
  27. if ($('#user_email').val() != "")
  28. {
  29. var xURL = '<%= url_for(:controller => :users, :action => "") %>get_question/' + $('#user_email').val();
  30. $.getJSON(xURL, function(json){
  31. var myObject = evail(json);
  32. if (myObject['NotFound'] != NULL)
  33. {
  34. $("#QuestionBox").css('display', 'none');
  35. alert('The e-mail address entered was not found in our database.');
  36. }
  37. else
  38. {
  39. $("#QuestionBox").css('display', 'block');
  40. $("#question").html(myObject);
  41. }
  42. });
  43. }
  44. else
  45. {
  46. var url = "<%= url_for(:controller => :users, :action => "") %>get_question", { Email: $('#user_email').val() }
  47. alert(url);
  48.  
  49. }
  50. });
  51. });
  52. </script>
  53. <% end %>
  54.  
  55. ## error
  56. Processing UsersController#get_question (for 127.0.0.1 at 2009-06-04 16:25:54) [POST]
  57. Session ID: BAh7CToMY3NyZl9pZCIlNWRmZTBmNmIwMTY2Y2VmMTYyYzBlMWYxYzJjODZi
  58. NGM6CXVzZXIwIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6
  59. Rmxhc2hIYXNoewAGOgpAdXNlZHsAOg5yZXR1cm5fdG8w--3855c01e3a2bcaca7b7a794f8f5c0b7482697987
  60. Parameters: {"action"=>"get_question", "controller"=>"users", "email"=>"email@blah.com"}
  61. User Columns (0.029844) SHOW FIELDS FROM `users`
  62. User Load (0.005474) SELECT * FROM `users` WHERE (`users`.`email` = 'email@blah.com') LIMIT 1
  63. Rendering template within layouts/application
  64. Rendering users/get_question
  65.  
  66.  
  67. ActionView::MissingTemplate (Missing template users/get_question.html.erb in view path /home/tim/Code/unclaimed/app/views):
  68. /vendor/rails/actionpack/lib/action_view/template.rb:85:in `raise_missing_template_exception'
  69. /vendor/rails/actionpack/lib/action_view/template.rb:78:in `set_extension_and_file_name'
  70. /vendor/rails/actionpack/lib/action_view/template.rb:15:in `initialize'
  71. /vendor/rails/actionpack/lib/action_view/base.rb:245:in `new'
  72. /vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file'
  73. /vendor/rails/actionpack/lib/action_controller/base.rb:1108:in `render_for_file'
  74. /vendor/rails/actionpack/lib/action_controller/base.rb:841:in `render_with_no_layout'
  75. /vendor/rails/actionpack/lib/action_controller/layout.rb:251:in `render_without_benchmark'
  76. /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
  77. /vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
  78. /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
  79. /vendor/rails/actionpack/lib/action_controller/base.rb:1157:in `default_render'
  80. /vendor/rails/actionpack/lib/action_controller/base.rb:1163:in `perform_action_without_filters'
  81. /vendor/rails/actionpack/lib/action_controller/filters.rb:580:in `call_filters'
  82. /vendor/rails/actionpack/lib/action_controller/filters.rb:573:in `perform_action_without_benchmark'
  83. /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  84. /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
  85. /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
  86. /vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
  87. /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
  88. /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
  89. /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
  90. /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
  91. /vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
  92. /vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
  93. /vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
  94. /vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
  95. /vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
  96. /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
  97. /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
  98. /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
  99. /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
  100. /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
  101. /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
  102. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
  103. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
  104. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
  105. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
  106. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
  107. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
  108. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
  109. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
  110. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
  111. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
  112. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
  113. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
  114. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
  115. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
  116. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
  117. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
  118. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
  119. /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
  120. /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
  121. /vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  122. /vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  123. /vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
  124. /vendor/rails/activesupport/lib/active_support/dependencies.rb:502:in `load'
  125. /vendor/rails/railties/lib/commands/servers/mongrel.rb:64
  126. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  127. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  128. /vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
  129. /vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
  130. /vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
  131. /vendor/rails/railties/lib/commands/server.rb:39
  132. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
  133. /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
  134. ./script/server:3
  135.  
  136. Rendering /home/tim/Code/unclaimed/vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.erb (internal_server_error)
Add Comment
Please, Sign In to add comment