Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes brfore performing pull operation

  • Loading branch information...
commit 22c7673a8e8a7f29bab3e075642df918596f7932 1 parent 60d2893
@dharasydnia authored
View
10 app/controllers/galleries_controller.rb
@@ -14,17 +14,23 @@ def index
# GET /galleries/1.json
def show
+ #@gallery = Gallery.find(params[:id])
+
@gallery = Gallery.find(params[:id])
+
+ @images = @gallery.images
=begin
-@images = Image.find(:all,
+ @images = Image.find(:all,
:joins=>" INNER JOIN galleries ON galleries.id = images.gallery_id",
- :include=>:gallery)
+ :include=>:gallery,
+ :conditions => { :images => { :gallery_id => @gallery.id } })
=end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @gallery }
+ format.json { render json: @images }
end
end
View
1  app/models/gallery.rb
@@ -1,2 +1,3 @@
class Gallery < ActiveRecord::Base
+ has_many :images
end
View
2  app/models/image.rb
@@ -1,5 +1,7 @@
class Image < ActiveRecord::Base
has_attached_file :img, :styles => { :thumb => "75x75", :small => "150x150" }
+ belongs_to :gallery
+
validates :gallery_id, :presence => true
end
View
7 app/views/galleries/show.html.erb
@@ -6,7 +6,12 @@
<%= @gallery.description %>
</p>
-<a href="/images/new">Add Image</a>
+<p>
+ <% @images.each do |image| %>
+ <a rel="example_group" href="<%= image.img.url(:original) %>" class="fancybox"><%= (image_tag image.img.url(:thumb), :border => "0") %></a>
+ <% end %>
+</p>
+<a href="/images/new">Add Image</a> |
<%= link_to 'Edit', edit_gallery_path(@gallery) %> |
<%= link_to 'Back', galleries_path %>
Please sign in to comment.
Something went wrong with that request. Please try again.