Q: why is the validation error output

being sent to the Trace-Window?
ActiveRecord::RecordInvalid in UsersController#create

Validation failed: Login can’t be blank, Login is too short (minimum
is 3 characters),



this is what im getting instaed of my layout which is supposed to
flash the errors & notices. is there somethign misconfigured?
thx

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] [email protected]
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!

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

On Mon, Oct 25, 2010 at 11:08 AM, tom [email protected] wrote:

<%= 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] [email protected]

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?

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'

%>

<%= 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] [email protected]
flash[:notice] = “Error SignUp - pls try again - Support has been
contacted!”
redirect_to signup_url
end
end

result is still:

ActiveRecord::RecordInvalid in UsersController#create

Validation failed: Password is too short (minimum is 4 characters)

validation are on login, email & password

thx

On Mon, Oct 25, 2010 at 11:41 AM, radhames brito [email protected]
wrote:

to this

@user.save

fixed a typo, i meant “force an exception”

On Mon, Oct 25, 2010 at 11:42 AM, radhames brito [email protected]
wrote:

On Mon, Oct 25, 2010 at 11:41 AM, radhames brito [email protected]wrote:

remove the ! from the save , when you add a shebang to a rails method you
force an exception, so instead of just outputting the age with is flash
message you are making rails raise and 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!!!

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

flash[:error] [email protected]

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.

try this please


> <% flash.each do |key, msg| %> > <%= content_tag :div, msg, :class => "flash", :id => key %>

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

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

ok, i’ve placed ur snippet in:


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

same behaviour…

On Mon, Oct 25, 2010 at 12:21 PM, radhames brito [email protected]
wrote:

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

setTimeout("new Effect.Fade('<%= key %>');", 10000);            <===

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:

On Mon, Oct 25, 2010 at 12:23 PM, tom [email protected] wrote:

ok, i’ve placed ur snippet in:


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

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

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

On Mon, Oct 25, 2010 at 12:19 PM, radhames brito [email protected]
wrote:

new Effect.Appear('<%= key %>', {duration:

<% 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

i test only with wrong data entered