noob question : action controller exception

Hi folks, can you spare some time? i could sure use it.

This is the error message :

ArgumentError in Store#save_order

Showing app/views/store/checkout.html.erb where line #10 raised:

interning empty string

Extracted source (around line #10):

7: <h4>All fields marked with * are required</h4>
8:
9: <% form_for :order, :url => { :action => :save_order } do |
form> %>
10: <%= form.error_messages %>
11: <fieldset>
12: <history>
13:

!!i get this error when i try to submit an empty form or any data !!

this is the save_order, mentioned in the error message
def save_order

   @order = Order.new(params[:order])
   if @order.save
     @cart = find_cart
     @order.add_line_items_from_cart(@cart)
     session[:cart] = nil
     flash[:notice]="Order placed successfully! "
     redirect_to :action => 'show_order_details'
   else
      render :action => 'checkout'
   end

end

Might be a problem with your validations in the Order model. Are you
doing any messing around with "humanized_attribute"?

1.thx for the help :slight_smile:
2. what the heck is "humanized_attribute" ??
3. yeah, i'm doing some validation in the Order model, here is the
code, regarding validation :

    PAYMENT_TYPES = [
        #Displayed stored in db
        ["Cash" , "cash"],
        ["Check" , "check"],
        ["Credit card" , "credit card"]
    ]

    ORDER_STATUS_TYPES = [
        #Displayed stored in db
        ["Not shipped" , "not shipped"],
        ["Shipped" , "shipped"]
    ]

validates_presence_of :name, :surname, :adress, :telephone, :email, :pay_type
    validates_format_of :name, :with => /[a-zA-Z]{2,50}/i
    validates_format_of :surname, :with => /[a-zA-Z]{2,50}/i
    validates_format_of :adress, :with => /^[a-zA-
Z0-9&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#216;&#217;&#218;&#219;&#220;&#221;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#241;&#242;&#243;&#244;&#245;&#246;&#248;&#249;&#250;&#251;&#252;&#253;&#255;\.
\,\-\/\']+[a-zA-
Z0-9&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#216;&#217;&#218;&#219;&#220;&#221;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#241;&#242;&#243;&#244;&#245;&#246;&#248;&#249;&#250;&#251;&#252;&#253;&#255;\.
\,\-\/\' ]+$/i

    validates_format_of :telephone, :with => /(?!:\A|\s)(?!(\d{1,6}\s+
\D)|((\d{1,2}\s+){2,2}))(((\+\d{1,3})|(\(\+\d{1,3}\)))\s*)?((\d{1,6})|
(\(\d{1,6}\)))\/?(([ -.]?)\d{1,5}){1,5}((\s*(#|x|(ext))\.?\s*)\d{1,5})?
(?!:(\Z|\w|\b\s))/i

    validates_length_of :email, :within => 2..128,
                        :message => "is not in the range of 2..128
characters."
    validates_uniqueness_of :email, :message => "This email is already
taken.Please supply a new one"
    validates_format_of :email, :with => /\A([\w\.\-\+\_]+)@((?:[-a-
z0-9]+\.)+[a-z]{2,})\z/i,
                        :message => "This is not a valid email
adress.Please renter email"
    #validate_with EmailValidator /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]
{2,})$/i
    validates_inclusion_of :pay_type, :in => PAYMENT_TYPES.map{|disp,
value> value}

Nothing in there jumps out at me as a definite reason why you got the
"interning empty string" error (and of course, I may be barking up the
wrong tree). My first check would be to comment out all the validation
code and try it - if it still fails, the problem's elsewhere. But if
it goes away (or you get DB errors because the validation passes, but
DB constraints get broken) then you at least know it's in there
somewhere.

PS Limiting the characters that people can enter in their names is
going to cause all sorts of frustrations for users

Hi folks, can you spare some time? i could sure use it.

This is the error message :

ArgumentError in Store#save_order

Showing app/views/store/checkout.html.erb where line #10 raised:

interning empty string

Extracted source (around line #10):

7: <h4>All fields marked with * are required</h4>
8:
9: <% form_for :order, :url => { :action => :save_order } do |
form> %>
10: <%= form.error_messages %>
11: <fieldset>
12: <history>
13:

!!i get this error when i try to submit an empty form or any data !!

this is the save_order, mentioned in the error message
def save_order

   @order = Order.new(params[:order])
   if @order.save
     @cart = find_cart
     @order.add_line_items_from_cart(@cart)
     session[:cart] = nil
     flash[:notice]="Order placed successfully! "
     redirect_to :action => 'show_order_details'
   else
      render :action => 'checkout'
   end

end

this is the code's view :

<% form_for :order, :url => { :action => :save_order } do |form| %>
        <%= form.error_messages %>
        <fieldset>
            <history>
                <h4>
                    Total worth of your books is
                    <span style="color:black"><%=
currency_euro(@cart.total_price_of_products) %></span>
                </h4>
            </history>
            <div>
                <%= form.label :name, "*Name " %>
                <%= form.text_field :name, :size => 30 %>
            </div>
            <div>
                <%= form.label :surmane, "*Surname " %>
                <%= form.text_field :surname, :size => 30 %>
            </div>
            <div>
                <%= form.label :adress, "*Adress " %>
                <%= form.text_area :adress, :rows => 4, :cols => 35 %>
            </div>
            <div>
                <%= form.label :telephone, "*Telephone " %>
                <%= form.text_field :telephone, :size => 30 %>
            </div>
            <div>
                <%= form.label :email, "*Email " %>
                <%= form.text_field :email, :size => 30 %>
            </div>
            <div>
                <%= form.label :pay_type,"*Pay type " %>
                <%= form.select :pay_type,Order::PAYMENT_TYPES,:prompt
=> "Select a payment method" %>
            </div>
            <%= submit_tag "Place order", :name => nil, :class =>
"submit" %>
          </fieldset>
    <% end %>

so my question is...what is the message saying, and how should i fix
this problem??

a billion thx in advance,

> Hi folks, can you spare some time? i could sure use it.

> This is the error message :

> ArgumentError in Store#save_order

> Showing app/views/store/checkout.html.erb where line #10 raised:

> interning empty string

> Extracted source (around line #10):

> 7: <h4>All fields marked with * are required</h4>
> 8:
> 9: <% form_for :order, :url => { :action => :save_order } do |
> form> %>
> 10: <%= form.error_messages %>
> 11: <fieldset>
> 12: <history>
> 13:

> !!i get this error when i try to submit an empty form or any data !!

> this is the save_order, mentioned in the error message
> def save_order

> @order = Order.new(params[:order])
> if @order.save
> @cart = find_cart
> @order.add_line_items_from_cart(@cart)
> session[:cart] = nil
> flash[:notice]="Order placed successfully! "
> redirect_to :action => 'show_order_details'
> else
> render :action => 'checkout'
> end

> end
> =========================
> this is the code's view :

> <% form_for :order, :url => { :action => :save_order } do |form| %>
> <%= form.error_messages %>
> <fieldset>
> <history>
> <h4>
> Total worth of your books is
> <span style="color:black"><%=
> currency_euro(@cart.total_price_of_products) %></span>
> </h4>
> </history>
> <div>
> <%= form.label :name, "*Name " %>
> <%= form.text_field :name, :size => 30 %>
> </div>
> <div>
> <%= form.label :surmane, "*Surname " %>
> <%= form.text_field :surname, :size => 30 %>
> </div>
> <div>
> <%= form.label :adress, "*Adress " %>
> <%= form.text_area :adress, :rows => 4, :cols => 35 %>
> </div>
> <div>
> <%= form.label :telephone, "*Telephone " %>
> <%= form.text_field :telephone, :size => 30 %>
> </div>
> <div>
> <%= form.label :email, "*Email " %>
> <%= form.text_field :email, :size => 30 %>
> </div>
> <div>
> <%= form.label :pay_type,"*Pay type " %>
> <%= form.select :pay_type,Order::PAYMENT_TYPES,:prompt
> => "Select a payment method" %>
> </div>
> <%= submit_tag "Place order", :name => nil, :class =>
> "submit" %>
> </fieldset>
> <% end %>
> ===========================================

> so my question is...what is the message saying, and how should i fix
> this problem??

> a billion thx in advance,

----
try adding (to OrdersController)...

 else

--> flash[:notice] = @order.errors.full_messages.join(" ")
render :action => 'checkout'
end

Craig

didn't work, same error, but it doesn't show around which line, the
error is raised, like it used to before having the line flash[:notice]
= @order.errors.full_messages.join(" ")

any other ideas :slight_smile:

a billion thx for your effort,
radu

hey,

found the problem.

is this line: validates_length_of :email, :within => 2..128, :message
=> "is not in the range of 2..128 characters."

when i try to submit email with the value 4, an error like in my first
post appears.

any idea why???

regards,
radu

Remove '.' at the end of the error message

radu puspana wrote: