Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### TABLES ####
- =# \d orders
- Table "orders"
- Column | Type | Modifiers
- ------------+-----------------------------+-----------------------------------------------------------
- id | integer | not null default nextval('orders_id_seq'::regclass)
- approved | integer |
- removed | integer |
- created_at | timestamp without time zone |
- updated_at | timestamp without time zone |
- Indexes:
- "orders_pkey" PRIMARY KEY, btree (id)
- =# select id,approved from orders limit 3;
- id | approved
- ----+----------
- 1 | 1
- 2 | 1
- 3 | 1
- =# \d customers
- Table "customers"
- Column | Type | Modifiers
- ------------+-----------------------------+-----------------------------------------------------------
- id | integer | not null default nextval('customers_id_seq'::regclass)
- name | character varying(255) |
- ...
- =# select id from customers;
- id
- ----
- 1
- (1 row)
- !!!! Only 1 record with ID = 1 !!!!
- ##### DEF #####
- class Order < ActiveRecord::Base
- validates_presence_of :quote
- belongs_to :approved, :class_name => "Customer", :foreign_key => "id"
- # has_one :remover, :class_name => "Customer", :foreign_key => "id"
- end
- .. Somewhere in .erb ..
- <% @orders.each do |order| %>
- ...
- <%=h order.approved.name %>
- ...
- #### RESULT: LOG ####
- ...
- Rendering template within layouts/orders
- Rendering orders/index
- Admin Load (0.5ms) SELECT * FROM "customers" WHERE ("customers"."id" = 1)
- Admin Load (0.2ms) SELECT * FROM "customers" WHERE ("customers"."id" = 2)
- ActionView::TemplateError (You have a nil object when you didn't expect it!
- #### RESULT : WEB #####
- Showing app/views/orders/index.html.erb where line #8 raised:
- You have a nil object when you didn't expect it!
- The error occurred while evaluating nil.nick
- Extracted source (around line #8):
- ...
- 8: <span class="approver">Approved by <%=h quote.approved.name %></span>
- ....
Add Comment
Please, Sign In to add comment