Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. db/migrate/[timestamp]_add_admin_to_users.rb
  2. class AddAdminToUsers < ActiveRecord::Migration
  3. def change
  4. add_column :users, :admin, :boolean, default: false
  5.  
  6. #Start - Adding for gender and dob
  7. add_column :users, :date_of_birth, :datetime
  8. add_column :users, :is_female, :boolean, default: false
  9. #End - Adding for gender and dob
  10.  
  11. end
  12. end
  13.  
  14. class User < ActiveRecord::Base
  15. .
  16. .
  17. GENDER_TYPES = [ ["Male","0"], [ "Female","1" ] ]
  18. validates :is_female, presence: true, inclusion: { in: ["0","1"] }
  19. .
  20. .
  21.  
  22. class UsersController < ApplicationController
  23. .
  24. .
  25. private
  26.  
  27. def user_params
  28. params.require(:user).permit(:name, :email, :password,
  29. :password_confirmation, :is_female, :date_of_birth)
  30. end
  31. .
  32. .
  33.  
  34. Started POST "/users" for 1.39.63.200 at 2014-10-30 12:26:54 +0000
  35. Processing by UsersController#create as HTML
  36. Parameters: {"utf8"=>"_", "authenticity_token"=>"X1CF1B0ds3fn6QbPE4HhD/AAHo9n6D5+e8oHwgyiU4wSzV3hdUeKCE1Mr3PHJKYx7GPhwmpksYVxS/QmqpwjuQ==", "user"=>{"name"=>"Kumar", "email"=>"test12@test.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "is_female"=>"1", "date_of_birth(1i)"=>"2017", "date_of_birth(2i)"=>"10", "date_of_birth(3i)"=>"30"}, "commit"=>"Create my account"}
  37. (0.1ms) begin transaction
  38. User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('test12@test.com') LIMIT 1
  39. (0.1ms) rollback transaction
  40. Rendered shared/_error_messages.html.erb (0.7ms)
  41. Rendered users/new.html.erb within layouts/application (8.0ms)
  42. Rendered layouts/_shim.html.erb (0.1ms)
  43. Rendered layouts/_header.html.erb (0.6ms)
  44. Rendered layouts/_footer.html.erb (0.3ms)
  45. Completed 200 OK in 681ms (Views: 571.3ms | ActiveRecord: 1.5ms)
  46. 1.39.63.200 - - [30/Oct/2014:12:26:55 +0000] "POST /users HTTP/1.1" 200 - 0.7922
  47.  
  48. --- !ruby/hash:ActionController::Parameters
  49. utf8: "✓"
  50. authenticity_token: X1CF1B0ds3fn6QbPE4HhD/AAHo9n6D5+e8oHwgyiU4wSzV3hdUeKCE1Mr3PHJKYx7GPhwmpksYVxS/QmqpwjuQ==
  51. user: !ruby/hash:ActionController::Parameters
  52. name: Kumar
  53. email: test12@test.com
  54. password: testtest
  55. password_confirmation: testtest
  56. is_female: '1'
  57. date_of_birth(1i): '2017'
  58. date_of_birth(2i): '10'
  59. date_of_birth(3i): '30'
  60. commit: Create my account
  61. controller: users
  62. action: create
  63.  
  64. The form contains 1 error.
  65.  
  66. Is female is not included in the list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement