Hi,
I'm meeting a problem that is almost the same as Issue 691.
http://code.google.com/p/activescaffold/issues/detail?id=691
+++
...
F, [2009-11-27T18:23:34.281000 #4596] FATAL -- :
ActionView::TemplateError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.status) on line #7 of
vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb:
4: <label for="<%= active_scaffold_input_options(column,
scope)[:id] %>"><%= column.label %></label>
5: </dt>
6: <dd>
7: <%= active_scaffold_input_for column, scope %>
8: <% if column.description -%>
9: <span class="description"><%= column.description %></span>
10: <% end -%>
app/models/topic_item.rb:15:in `page_status'
vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb:7
vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform_record.html.erb:15
...
+++
class TopicItemsController < ApplicationController
...
active_scaffold :topic_items do | config |
...
config.columns << :page_status
...
end
...
end
+++
class TopicItem < ActiveRecord::Base
...
def page_status
page = self.web_page
page.status
end
...
end
+++
I have a Topic model and a TopicItem model and they have a one-to-many
association.
When I click "Edit" of one of the records in /topics/list page, the
error above occured.
The Topic object has 4 TopicItem objects.
I found TopicItem.page_status is called 5 times and the error occurs
at the fifth call since all attributes of the TopicItem object are
nil.
As Andreius mentioned in Issue 691, it must be caused by the new
record in the subform.
Is this behavior expected?
Should I always check nil for an empty model?
Thanks,
ebi
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en.