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:

All fields marked with * are required


8:
9: <% form_for :order, :url => { :action => :save_order } do |
form| %>
10: <%= form.error_messages %>
11:
12:
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 %>



Total worth of your books is
<%=
currency_euro(@cart.total_price_of_products) %>




<%= form.label :name, "*Name " %>
<%= form.text_field :name, :size => 30 %>


<%= form.label :surmane, "*Surname " %>
<%= form.text_field :surname, :size => 30 %>


<%= form.label :adress, "*Adress " %>
<%= form.text_area :adress, :rows => 4, :cols => 35 %>


<%= form.label :telephone, "*Telephone " %>
<%= form.text_field :telephone, :size => 30 %>


<%= form.label :email, “*Email " %>
<%= form.text_field :email, :size => 30 %>


<%= form.label :pay_type,”*Pay type " %>
<%= form.select :pay_type,Order::PAYMENT_TYPES,:prompt
=> “Select a payment method” %>

<%= submit_tag “Place order”, :name => nil, :class =>
“submit” %>

<% end %>

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

a billion thx in advance,
radu

On 13 February 2010 18:12, radu puspana [email protected] wrote:

interning empty string

Extracted source (around line #10):

10: <%= form.error_messages %>

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

On Feb 13, 8:15 pm, Michael P. [email protected] wrote:

On 13 February 2010 18:12, radu puspana [email protected] wrote:

interning empty string

Extracted source (around line #10):

10: <%= form.error_messages %>

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ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ.
,-/’]+[a-zA-
Z0-9ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ.
,-/’ ]+$/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}

hope u can make some sense of it :slight_smile: and help me

a billion thx in advance,
radu

On Sat, 2010-02-13 at 10:12 -0800, radu puspana wrote:

Extracted source (around line #10):
!!i get this error when i try to submit an empty form or any data !!
redirect_to :action => ‘show_order_details’


<%= form.text_field :telephone, :size => 30 %>
<%= submit_tag “Place order”, :name => nil, :class =>
“submit” %>

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


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

On 13 February 2010 18:21, radu puspana [email protected] wrote:

  1. yeah, i’m doing some validation in the Order model, here is the
    code, regarding validation :

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

On Feb 13, 8:51 pm, Craig W. [email protected] wrote:

 flash[:notice]="Order placed successfully! "
    <%= form.error_messages %>
            <%= form.text_field :name, :size => 30 %>
            <%= form.label :telephone, "*Telephone " %>
        </div>

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

Remove ‘.’ at the end of the error message

radu puspana wrote:

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs