I'm sure this is pure amateur hour but I'm trying to debug a multiple
uploads with paperclip issue and I'm not sure what a piece of code
means.
Basically, I'm in a model, called LineSheet.
def new_page_image_attributes=(page_image_attributes)
page_image_attributes.each do |attributes|
page_images.build(attributes)
end
end
this is one of the methods I am supposed to add to this model so I can
add multiple page_images to my line sheets through a js call to a file
with
<div class="page_image">
<% new_or_existing = page_image.new_record? ? 'new' : 'existing' %>
<% prefix = "line_sheet[#{new_or_existing}_page_image_attributes][]" %>
<% fields_for prefix, page_image do |p| %>
<p>
<%= p.label :page_image %><br />
<%= p.file_field :data, :index => nil %>
<%= link_to_function "remove", "$(this).up('.page_image').remove()" %>
</p>
<% end %>
I keep getting the same error,
@line_sheet[new_page_image_attributes]' is not allowed as an instance
variable name
and its driving me crazy. So I've been trying to debug my issue with
the help of script/console. From script/console
>> LineSheet.new.new_page_image_attributes
NoMethodError: undefined method `new_page_image_attributes' for
#<LineSheet:0x42e800c>
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:260:in
`method_missing'
from /usr/local/lib/ruby/gems/1.8/gems/spree-0.8.3/vendor/plugins/attribute_fu/lib/attribute_fu/associations.rb:28:in
`method_missing'
from (irb):3
I know this must have something to do with how the method is being
defined and its just a method definition technique i don't know yet,
but it's driving me crazy not understanding why this method is
throwing a no method error when i call it. Does anyone have it in
their heart to school my undereducated ass on this subject? Thank you
all kindly and have an awesome memorial day weekend.
Regards,
William H. Harle Jr.
Owner, Web Developer
90 Percent Gravity LLC
856.655.2769
http://90percentgravity.com