Guest User

Untitled

a guest
Mar 4th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. ## edit.rhtml
  2. <h2>Edit <%= @user.login %></h2>
  3.  
  4. <% form_for :user, :url => user_path(@user), :html => {:method => :put} do %>
  5. <%= error_messages_for 'user' %>
  6.  
  7. <!--[form:user]-->
  8. <p><label for="user_login"><b>Login:</b></label> <%= @user.login %></p>
  9.  
  10. <p><label for="user_password">Change password:</label><br/>
  11. <%= password_field 'user', 'password' %></p>
  12.  
  13. <p><label for="user_password_confirmation">Confirm:</label><br/>
  14. <%= password_field 'user', 'password_confirmation' %></p>
  15.  
  16. <p><label for="user_type">Type:</label><br/>
  17. <%= select :user, :type, User::TYPES.map{ |x| [x,x] } %></p>
  18.  
  19. <!--[eoform:user]-->
  20.  
  21. <%= submit_tag 'Edit' %>
  22. <% end %>
  23.  
  24. <%= link_to 'Show', user_path(@user) %> |
  25. <%= link_to 'Back', :action => 'index' %>
  26.  
  27. ## snip of user.rb
  28. class User < ActiveRecord::Base
  29. # define all usertypes here
  30. TYPES = %w( User Contributor Moderator Admin ).freeze
  31.  
  32. ## user table
  33. class CreateUsers < ActiveRecord::Migration
  34. def self.up
  35. create_table "users", :force => true do |t|
  36. t.column :login, :string
  37. t.column :email, :string
  38. t.column :crypted_password, :string, :limit => 40
  39. t.column :salt, :string, :limit => 40
  40. t.column :created_at, :datetime
  41. t.column :updated_at, :datetime
  42. t.column :remember_token, :string
  43. t.column :remember_token_expires_at, :datetime
  44. t.column :type, :string
  45.  
  46. end
  47. end
  48.  
  49. def self.down
  50. drop_table "users"
  51. end
  52. end
  53.  
  54. ## error
  55. TypeError in Users#edit
  56. Showing app/views/users/edit.rhtml where line #16 raised:
  57. wrong argument type String (expected Module)
  58. Extracted source (around line #16):
  59. 13: <%= password_field 'user', 'password_confirmation' %></p>
  60. 14:
  61. 15: <p><label for="user_type">Type:</label><br/>
  62. 16: <%= select :user, :type, User::TYPES.map{ |x| [x,x] } %></p>
  63. 17:
  64. 18: <!--[eoform:user]-->
  65. 19:
  66.  
  67. RAILS_ROOT: /home/railsapps/cyshows2/public/../config/..
  68. Application Trace | Framework Trace | Full Trace
  69. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:116:in `include?'
  70. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:116:in `options_for_select'
  71. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:349:in `inject'
  72. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:114:in `each'
  73. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:114:in `inject'
  74. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:114:in `options_for_select'
  75. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:302:in `to_select_tag'
  76. /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:66:in `select'
  77. #{RAILS_ROOT}/app/views/users/edit.rhtml:16:in `_run_rhtml_47app47views47users47edit46rhtml'
  78. #{RAILS_ROOT}/app/views/users/edit.rhtml:3:in `_run_rhtml_47app47views47users47edit46rhtml'
  79. Request
  80. Parameters: {"id"=>"1"}
  81. Show session dump
  82. Response
  83. Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
Add Comment
Please, Sign In to add comment