Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## edit.rhtml
- <h2>Edit <%= @user.login %></h2>
- <% form_for :user, :url => user_path(@user), :html => {:method => :put} do %>
- <%= error_messages_for 'user' %>
- <!--[form:user]-->
- <p><label for="user_login"><b>Login:</b></label> <%= @user.login %></p>
- <p><label for="user_password">Change password:</label><br/>
- <%= password_field 'user', 'password' %></p>
- <p><label for="user_password_confirmation">Confirm:</label><br/>
- <%= password_field 'user', 'password_confirmation' %></p>
- <p><label for="user_type">Type:</label><br/>
- <%= select :user, :type, User::TYPES.map{ |x| [x,x] } %></p>
- <!--[eoform:user]-->
- <%= submit_tag 'Edit' %>
- <% end %>
- <%= link_to 'Show', user_path(@user) %> |
- <%= link_to 'Back', :action => 'index' %>
- ## snip of user.rb
- class User < ActiveRecord::Base
- # define all usertypes here
- TYPES = %w( User Contributor Moderator Admin ).freeze
- ## user table
- class CreateUsers < ActiveRecord::Migration
- def self.up
- create_table "users", :force => true do |t|
- t.column :login, :string
- t.column :email, :string
- t.column :crypted_password, :string, :limit => 40
- t.column :salt, :string, :limit => 40
- t.column :created_at, :datetime
- t.column :updated_at, :datetime
- t.column :remember_token, :string
- t.column :remember_token_expires_at, :datetime
- t.column :type, :string
- end
- end
- def self.down
- drop_table "users"
- end
- end
- ## error
- TypeError in Users#edit
- Showing app/views/users/edit.rhtml where line #16 raised:
- wrong argument type String (expected Module)
- Extracted source (around line #16):
- 13: <%= password_field 'user', 'password_confirmation' %></p>
- 14:
- 15: <p><label for="user_type">Type:</label><br/>
- 16: <%= select :user, :type, User::TYPES.map{ |x| [x,x] } %></p>
- 17:
- 18: <!--[eoform:user]-->
- 19:
- RAILS_ROOT: /home/railsapps/cyshows2/public/../config/..
- Application Trace | Framework Trace | Full Trace
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:116:in `include?'
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:116:in `options_for_select'
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:349:in `inject'
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:114:in `each'
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:114:in `inject'
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:114:in `options_for_select'
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:302:in `to_select_tag'
- /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_options_helper.rb:66:in `select'
- #{RAILS_ROOT}/app/views/users/edit.rhtml:16:in `_run_rhtml_47app47views47users47edit46rhtml'
- #{RAILS_ROOT}/app/views/users/edit.rhtml:3:in `_run_rhtml_47app47views47users47edit46rhtml'
- Request
- Parameters: {"id"=>"1"}
- Show session dump
- Response
- Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
Add Comment
Please, Sign In to add comment