q: why is the validation error output

being sent to the Trace-Window?

you have to post some of your layout code , but it seems like there is a problem with your login form and is getting submitted when you try to access the page, but to be sure we have to see some of the lay out code and we have to know it the login form can be triggered by JS

user-controller:

flash[:error] =@user.errors
flash[:notice] = “Error SignUp - pls try again - Support has been contacted!”

application.html

<% if flash[:notice] -%> <%= flash[:notice]%> <%= flash[:error]%> <% end -%>

#i reduced it to the minimum. the user signup form is just a regular form…

what else can i provide?

thx for ur help!

user-controller:

flash[:error] =@user.errors
flash[:notice] = “Error SignUp - pls try again - Support has been contacted!”

application.html

<% if flash[:notice] -%>
<%= flash[:notice]%>
<%= flash[:error]%>
<% end -%>

first change this mess to this

<% message.each do |name, msg| %>
<% = content_tag :div, msg, :id => “flash_#{name}” %>

#i reduced it to the minimum. the user signup form is just a regular form…

what else can i provide?

thx for ur help!

now look at this

flash[:error] =@user.errors

this is what you are seen, so what i want to know is,

  1. do you see this when you try to login or just by trying to access the root page?
  2. what are you using for authentication?
  3. can you post the login form?

ActionView::TemplateError (undefined local variable or method `message’ for #ActionView::Base:0xb6080e74) on line #32 of app/views/layouts/application.html.erb:
29:
30:
31:
32: <% message.each do |name, msg| %>
33: <%= content_tag :div, msg, :id => “flash_#{name}” %>
34: <% end %>

1)the problem occurs after hitting the submit button, meaning after the validation failes
2)old rails app > restful_authentication
3)login form is more or less basic functionailty, but quite a few fields. ill stripp it down later.

thx

31:

32: <% message.each do |name, msg| %>
33: <%= content_tag :div, msg, :id => “flash_#{name}” %>
34: <% end %>

sorry i strackted that from a partial it should look like this

<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => “flash_#{name}” %>

just minimized everything down to:
<% form_for (@user) do |f| -%>

<%= f.error_messages %>

Login

<%= f.text_field :login, :class=>‘input_signup’ %>

<p><label for="email">Email</label><br/>
<%= f.text_field :email, :class=>'input_signup' %></p>

<p><label for="password">Password</label><br/>
<%= f.password_field :password, :class=>'input_signup' %></p>

<p><label for="password_confirmation">Confirm Password</label><br/>
<%= f.password_field :password_confirmation, :class=>'input_signup' %></p>

<%= submit_tag 'Sign up' %>

<% end -%>

def create
@user = User.new(params[:user])
@user.save!

if @user.errors.empty?
    flash[:notice] = "Thanks for signing up! Please check your email to activate your account." 
else
  p @user.errors
  flash[:error] =@user.errors
  flash[:notice] = "Error SignUp - pls try again - Support has been contacted!" 
  redirect_to signup_url
end

end

result is still:

remove the ! from the save , when you add a shebang to a rails method you force and exception, so instead of just outputting the age with is flash message you are making rails raise and exception

change this

@user.save!

to this

@user.save

fixed a typo, i meant “force an exception”

another typo on “page” i wrote age

argh - u got very good eyes. oh man - i was so blind…and not thinking cleary. thank u soo much!!!

flash[:error] =@user.errors

I think this will cause an error since you are passing a collection to a hash that takes a string, let the form helper handle this and dont use many flashes with the loop or you will only see the last flash set

i think u r right.
i got rid of the @user.errors, but im getting nothing back right now… let me check.

now i have this:
1)
@user.save
if @user.errors.empty?
flash[:notice] = “Thanks for signing up! Please check your email to activate your account.”
else
redirect_to signup_url
end
2)
validation via model are al set


<% flash.each do |key, msg| %> <%= content_tag :div, msg, :class => "flash", :id => key %> <% content_tag :script, :type => "text/javascript" do %> $('<%= key %>').style.display = 'none'; new Effect.Appear('<%= key %>', {duration: 3}); <% end %>

<% content_tag :script, :type => “text/javascript” do %>
setTimeout(“new Effect.Fade(’<%= key %>’);”, 10000);
<% end %>
<% end %>


<%= yield :layout %>

but the only thing i see is this:

'Input

literally, the string “'Input” is being displayed between the hr tags…
im confused

try this please

for some reason i forgot this is ERB :stuck_out_tongue: so this $(’<%= key %>’) does makes sense, but still the output is not what you expect since you will be getting flash_error, flash_notice and such and not just error and notice which is the key

ok, i’ve placed ur snippet in:


<% flash.each do |name, msg| %> <%= content_tag :div, msg, :id => "flash_#{name}" %> <% end -%>
<%= yield :layout %>

try this please


<% flash.each do |key, msg| %>

<%= content_tag :div, msg, :class => “flash”, :id => key %>

<% content_tag :script, :type => “text/javascript” do %>

$(’<%= key %>’).style.display = ‘none’; <=== this makes no sense the selector never sees anything with <% %> since this never

new Effect.Appear('<%= key %>', {duration: 3});                               gets to the browser also the content tag generates this flash_error, flash_notice, etc

<% end %>

<% content_tag :script, :type => “text/javascript” do %>

setTimeout(“new Effect.Fade(’<%= key %>’);”, 10000); <=== again try to select something with <% %>

<% end %>

<% end %>

<%= yield :layout %>

for some reason i forgot this is ERB :stuck_out_tongue: so this $(’<%= key %>’) does makes sense, but still the output is not what you expect since you will be getting flash_error, flash_notice and such and not just error and notice which is the key

thats ok, i would b happy to see anything :wink:

:confused: i didnt notice when you changed the original code…

you see this “input” when validation fails or always?

i test only with wrong data entered