omarzina / substruct

Automatically exported from code.google.com/p/substruct
0 stars 0 forks source link

admin/orders/new not working - throwing a nil object error #158

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Downloaded 1-0-a6 (latest release)
2. Modified database.yml to point at my previous install
3. Logged in and selected an existing order
4. Selected the option in the right sidebar to create a new order.  This is
a link to admin/orders/new

What is the expected output? What do you see instead?

Got the following error ...

Processing OrdersController#new (for 127.0.0.1 at 2008-12-31 12:47:21) [GET]
  Session ID: ca5f7e90648e506a11680d6d15c2f80b
  Parameters: {"action"=>"new", "controller"=>"admin/orders"}
  Preference Load (0.000172)   SELECT * FROM `preferences` WHERE
(`preferences`.`name` = 'store_name') LIMIT 1
  Tag Load (0.000231)   SELECT * FROM `tags` WHERE (parent_id IS NULL OR
parent_id = 0) ORDER BY -rank DESC
  OrderUser Load (0.000124)   SELECT * FROM `order_users` WHERE
(`order_users`.`id` IS NULL) LIMIT 1
  User Load (0.000136)   SELECT * FROM `users` WHERE (`users`.`id` = 2) 
  Join Table Columns (0.001508)   SHOW FIELDS FROM `roles_users`
  Role Load (0.001828)   SELECT * FROM `roles` INNER JOIN `roles_users` ON
`roles`.id = `roles_users`.role_id WHERE (`roles_users`.user_id = 2 ) ORDER
BY name ASC
  Join Table Columns (0.001562)   SHOW FIELDS FROM `rights_roles`
  Right Load (0.000798)   SELECT * FROM `rights` INNER JOIN `rights_roles`
ON `rights`.id = `rights_roles`.right_id WHERE (`rights_roles`.role_id = 1
) ORDER BY name ASC
[AUTH] content_nodes - *
[AUTH] files - *
[AUTH] orders - *
Rendering template within layouts/admin
Rendering admin/orders/new
Rendered admin/orders/_user (0.00019)

ActionView::TemplateError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.country) on line #43 of
admin/orders/_address.rhtml:
40:     </div>
41:     <div class="floatHalf">
42:     <%
43:             country = instance_variable_get("@#{address_type}_address").country
44:             if country
45:                 selected_country = country.id 
46:             else

    vendor/plugins/substruct/app/views/admin/orders/_address.rhtml:43:in
`_run_erb_47vendor47plugins47substruct47app47views47admin47orders47_address46rht
ml'
    vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
    vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'

What version of the product are you using? On what operating system?

substruct_rel_1-0-a6

Running in Development mode on a MacBook Pro, with OS/X Leopard.  Got a
number of rails apps running fine on the this development box.

Please provide any additional information below.

I downloaded a stock standard build and simply ran it in development mode
using script/server ... to eliminate any of my changes.  The only other
thing that 'may' influence things is of course the data in my database ...
the few dummy orders I've played with ... but it's a new order I'm trying,
as admin, so I can't figure how old orders would affect things ?.

Other things seem to be fine, though I've only done a cursory check thus far.

This is the first time I've tried this option, so I can't say I've ever
seen it work.

Looks to be the billing_address is nil, but I don't know why it should
matter, since it's supposed to be a new order isn't it ?

Any ideas ?.  Can anyone confirm that it's working for them ?, in which
case I'll dig deeper.

Original issue reported on code.google.com by attila.m...@gmail.com on 31 Dec 2008 at 1:06

GoogleCodeExporter commented 8 years ago
If you had a previous install, make sure you're updating using the directions 
in the
CHANGELOG file under the substruct folder.

More than likely you have to do a DB migration, and need to ensure you updated 
any
custom files you modified with the previous install.

Original comment by subim...@gmail.com on 2 Jan 2009 at 9:47

GoogleCodeExporter commented 8 years ago
Sorry, didn't give this a good look when I first read it. The admin/orders/new
function has been phased out. The best way to create an order is through the 
storefront.

I don't see the value in duplicating order creation code on the admin / public 
side.

Original comment by subim...@gmail.com on 5 Jan 2009 at 10:31

GoogleCodeExporter commented 8 years ago
Hi.  The problem I suppose comes down to ...

1. Either remove altogether the 'What can I do ..." links that are defunct, or
2. Provide functionality behind the link

As it happens, I did a little more digging over the weekend and it seems the 
whole 'new' action in the 
controller was missing.  Once I added it, by scavenging similar code from the 
normal order creation controller, 
it seemed to work just fine.

The reason the functionality attracted me was because I wanted to be able to 
act as proxy for the purchasing 
client, as an admin user.  The situation being ... to take orders over the 
phone, using the same system as if 
they'd ordered on-line.

In any case, there is a bug there, and from what your saying, the solution is 
to remove the defunct link(s) and 
the supporting code (if any) from the mainline :0))

Cheers ... and thanks ... for both the response and the substruct package 
itself.  It looks like something I can 
use for several online shops that I see coming up in my neck of the woods :0).  
Once I get stuck in, I can see 
myself quite happy to contribute back to the code base.

Original comment by attila.m...@gmail.com on 6 Jan 2009 at 9:47

GoogleCodeExporter commented 8 years ago
Yes it should be removed all together.

I run a few shops, and it's really best for you to place orders taken over the 
phone
by using the same system your customers would use. It doesn't make sense at all 
to
duplicate the code or the UI for that particular action. It's not like as an 
admin
you're going to have special order-placing options.

Original comment by subim...@gmail.com on 7 Jan 2009 at 12:47