Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Error is:
- NoMethodError in CollectionsController#update
- You have a nil object when you didn't expect it!
- You might have expected an instance of Array.
- The error occurred while evaluating nil.push
- Rails.root: /home/john/Rails/testapp
- Application Trace | Framework Trace | Full Trace
- app/controllers/collections_controller.rb:59:in `block in update'
- app/controllers/collections_controller.rb:58:in `update'
- class Collection
- references_and_referenced_in_many :products
- end
- class Products
- references_and_referenced_in_many :collections
- end
- class CollectionsController < ApplicationController
- # PUT /collections/1
- # PUT /collections/1.xml
- def update
- @collection = Collection.find(params[:id])
- respond_to do |format|
- if @collection.update_attributes(params[:collection])
- format.html { redirect_to(@collection, :notice => 'Collection was successfully updated.') }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @collection.errors, :status => :unprocessable_entity }
- end
- end
- end
- end
- then the form:
- = form_for @collection do |f|
- - for product in @store.products
- #product[product]
- = check_box_tag "collection[products][]", product._id, @collection.products.include?(product)
- = product.name
- = f.submit "Update products"
- if you set the file field to "collection[product_ids][]" it generates the same error too.
Add Comment
Please, Sign In to add comment