Update subset of my data

Please can someone put me out of my misery…
I am missing the point here:

I have a table of albums called: dealers
I have a table of images: popp_images

each dealer has 6 popp_images linked by foriegn key: albumid

Each dealer can login using user_engine engine
I restrict viewing for each dealer to their own images by assigning each
dealer their own albumid.

I list their images with:

in my controller:

def list
@dealers = Dealer.find_all
@dealer = current_user.albumid
@popp_image_pages, @popp_images = paginate :popp_images, :per_page
=> 10
end

in my view:

<%
odd_or_even = 0
for popp_image in @popp_images
odd_or_even = 1 - odd_or_even
%>
<% if (@dealer == nil) || (@dealer == popp_image.albumid)%>

this works fine.

I am stuck on updating multiple pop_images i.e the whole six in the
album (dealer)
here’s what I have:

def update

 # @dealer assign to current users albumid
 @dealer = current_user.albumid
 @dealers = Dealer.find(params[:id], :include => :dealer)
 @dealer_images = PoppImage.find(params[:id], :include => :dealers)

if @popp_image.update_attributes(params[:popp_image])
  flash[:notice] = 'Your image was successfully updated.'
  redirect_to :action => 'show', :id => @popp_image
else
  render :action => 'edit'
end

end

I get: Couldn’t find Dealer without an ID

probably dumb but…
any ideas?
thanks

Peter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs