开发者

problems with registration

开发者 https://www.devze.com 2023-02-20 11:43 出处:网络
I\'m a newbie and I\'m having problems in implementing a photo gallery. When I go to the show page, this error appears:

I'm a newbie and I'm having problems in implementing a photo gallery. When I go to the show page, this error appears:

Couldn't find GalleryPhoto without an ID

I don't know what is going on, I suppose that it's somthing's wrong with my create method. Anyway, here is the code of my galleries_controller.rb, _form.html.erb and show page: https://gist.github.com/888236

开发者_运维百科

Update: Yes, there is a reference to gallery in the gallery_photo.rb


I'd change this line:

@gallery_photo = @gallery.gallery_photos.find(params[:all])

To this:

@gallery_photo = @gallery.gallery_photos

Of course, I assume you have correct associations in your models.

#models/galleryphoto.rb
belongs_to :gallery

#models/gallery.id
has_many :gallery_photos

EDIT AFTER NEW INFO
If you have an exception "undefined local variable or method", check if gallery_photo model has field gallery_id.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号