I have created original method and trying to pass newly instantiated
object to ERB file, but encountering NoMethodError in ERB file with the
following error message.
NoMethodError in Products#lookup
Showing app/views/products/lookup.html.erb where line #3 raised:
You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.
Extracted source (around line #3):
3: <% form_for(@product) do |f| %>
4: <%= f.error_messages %>
result = Amazon::Ecs.item_lookup(params[:id]).first_item
@product = AmazonProduct.new(
<% form_for(@product) do |f| %>
<%= f.error_messages %>
<%= f.label :id %>: <%= @product.amazon_asin %>
When viewing @product variable by running this flow in Aptana debug mode
and stop it at erb source code, @product seems to have information and
not nil (See attached). I was trying to copy standard rails
controller/erb approach for other method, but it’s not working well for
this. May I have any advice? Thank you.