Forum: Ruby on Rails error_messages_for >> Cannot convert Array into String

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fc582698581884352e745d1d4c64699d?d=identicon&s=25 Joshua Muheim (josh)
on 2006-01-12 00:39
Hi all

I have the following Model:

Member(id, username, first_name, last_name, hashed_password,
password_salt)

Now I want to allow users to register for an account using the following
form:

---
		<%= form_tag %>
			<%= error_messages_for 'member' %>
			<p><%= _('Username') %>: <%= text_field('member', 'username') %></p>
			<p><%= _('E-Mail') %>: <%= text_field('member', 'email', :id =>
'asdf') %></p>
			<p><%= _('Password') %>: <%= password_field('member', 'password')
%></p>
			<p><%= _('Password confirmation') %>: <%= password_field('member',
'password_confirmation') %></p>
			<p><%= submit_tag(_('Register!')) %></p>
		<%= end_form_tag %>
---

The register action looks like this (the password encryption with salt
is not built in yet):

---
  def register
    if request.get?
      @member = Member.new
    else
      @member = Member.new(params[:member])
      flash[:notice] = "You account was successfully created! Please
login now."
      redirect_to :action => "login" if @member.save
    end
  end
---

When I press the submit button, then I get the following error:

---
 TypeError in Member#register

Showing app/views/member/register.rhtml where line #11 raised:

cannot convert Array into String

Extracted source (around line #11):

8: 	<fieldset>
9: 		<legend>Register</legend>
10: 		<%= form_tag %>
11: 			<%= error_messages_for 'member' %>
12: 			<p><%= _('Username') %>: <%= text_field('member', 'username')
%></p>
13: 			<p><%= _('E-Mail') %>: <%= text_field('member', 'email', :id =>
'asdf') %></p>
14: 			<p><%= _('Password') %>: <%= password_field('member', 'password')
%></p>

---

What did I wrong? Thanks for help.

Greetings,
Josh
This topic is locked and can not be replied to.