相册、照片 - 相册分页
好吧,我在这里需要一些专家的建议...
我有一个相册,里面有很多照片...常见的东西对吧?
我需要专家建议的地方是我希望用户单击所需的相册...然后一次查看一张照片...
这一切都应该在相册控制器中发生吗?这就是我现在的样子,但它变得混乱,因为我想添加评论
这是我当前的默认显示:
class PhotoAlbumsController < ApplicationController
#Need to activate the Nav
@space = Space.find(params[:space_id])
@photoalbum = PhotoAlbum.find(params[:id])
@photos = @photoalbum.photos.paginate :page => params[:page], :per_page => 1
@photo = @photos
@comments = @photoalbum.comments.roots.order("created_at DESC")
respond_to do |format|
format.html
end
end
.
.
然后在视图中:
<%= image_tag @photos.first.photo.url %>
<%= render :partial => 'comments/index',:locals => {:commentable=> @photo.first,:comments => @comments}%>
这里的问题是照片评论正在显示相册的评论,但将其记录为照片......
我想要每张照片的评论 - 不是相册.. 并认为我的控制器设置可能很时髦?
谢谢你!
Ok I need some expert advise here....
I have a Photo Album that has_many Photos... Common stuff right?
Where I need expert advise is I want the use to click the desired photo album... and then see one photo at a time...
Should that all be happening in the PhotoAlbum Controller? that's how I have it now but it's getting messy as I want to add comments
Here's my current def show:
class PhotoAlbumsController < ApplicationController
#Need to activate the Nav
@space = Space.find(params[:space_id])
@photoalbum = PhotoAlbum.find(params[:id])
@photos = @photoalbum.photos.paginate :page => params[:page], :per_page => 1
@photo = @photos
@comments = @photoalbum.comments.roots.order("created_at DESC")
respond_to do |format|
format.html
end
end
.
.
Then in the View:
<%= image_tag @photos.first.photo.url %>
<%= render :partial => 'comments/index',:locals => {:commentable=> @photo.first,:comments => @comments}%>
Problem here is Photo comments is showing Comments for the Album, but recording it for the photo...
I want comments per Photo - Not Album.. and think maybe my controller setup is funky?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在控制器中,您将传递给局部的 @comments 定义为相册上的评论数组:
然后将局部中的可评论对象设置为相册中的第一张照片。
所以,是的,您在对照片发布新评论的同时列出了相册的评论。将@comments 更改为照片的评论。
In your controller, you define @comments passed to the partial as the array of comments on your photo album:
And then set the commentable object in your partial to the first photo in your album.
So yes, you are listing an album's comments while posting new comments to a photo. Change @comments to comments for a photo.