Rubocop fix up

This commit is contained in:
Brenda Wallace committed 2019-02-04 20:55:04 +13:00
1 parent 0759ca9039
commit f1ad9cc3c7
6 files changed
+24 -10

No files matched your search

+1 -1
View File
@@ -51,7 +51,7 @@ class CropsController < ApplicationController
def show
@crop = Crop.includes(:scientific_names, plantings: :photos).find_by!(slug: params[:slug])
@posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page])
@photos = Photo.joins(:photographings).where(photographings: {crop: @crop})
@photos = Photo.joins(:photographings).where(photographings: { crop: @crop })
# respond_with(@crop)
respond_to do |format|
format.html
+2 -2
View File
@@ -6,14 +6,14 @@ class PhotosController < ApplicationController
responders :flash
def show
@crops = Crop.distinct.joins(:photographings).where(photographings: { photo: @photo})
@crops = Crop.distinct.joins(:photographings).where(photographings: { photo: @photo })
respond_with(@photo)
end
def index
if params[:crop_slug]
@crop = Crop.find params[:crop_slug]
@photos = Photo.joins(:photographings).where(photographings: {crop: @crop})
@photos = Photo.joins(:photographings).where(photographings: { crop: @crop })
else
@photos = Photo.all
end
+1
View File
@@ -107,6 +107,7 @@ class Crop < ApplicationRecord
def seed_photos
Photo.joins(:seeds).where("seeds.crop_id": id)
end
# update the Elasticsearch index (only if we're using it in this
# environment)
def update_index(_name_obj)
-1
View File
@@ -1,7 +1,6 @@
class Photo < ApplicationRecord
include Ownable
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed).freeze
has_many :photographings, foreign_key: :photo_id, dependent: :destroy, inverse_of: :photo
+4 -6
View File
@@ -4,23 +4,21 @@ class Photographing < ApplicationRecord
belongs_to :crop, optional: true
validate :photo_and_item_have_same_owner
##
## Triggers
before_save :set_crop
def item
self.find_by!(photographable_id: photographable_id, photographable_type: photographable_type).photographable
find_by!(photographable_id: photographable_id, photographable_type: photographable_type).photographable
end
def self.item(item_id, item_type)
find_by!(photographable_id: item_id, photographable_type: item_type).photographable
end
def set_crop
if ['Planting', 'Seed', 'Harvest'].include?(photographable_type)
self.crop_id = photographable.crop_id
end
self.crop_id = photographable.crop_id if %w(Planting Seed Harvest).include?(photographable_type)
end
private
+16
View File
@@ -1 +1,17 @@
-# - if planting.crop.perennial
-# = render "plantings/progress_bar", status: "perennial", progress: nil
-# - elsif !planting.planted?
-# - if show_explanation
-# %p= t('.progress_0_not_planted_yet')
-# = render "plantings/progress_bar", status: "not planted", progress: 0
-# - elsif planting.finished?
-# = render "plantings/progress_bar", status: 'finished', progress: 100
-# - elsif planting.finish_predicted_at.nil?
-# - if show_explanation == true
-# %p Progress: Not enough data
-# = render "plantings/progress_bar", status: "unknown", progress: nil
-# - else
-# = render "plantings/progress_bar", status: 'growing', progress: planting.percentage_grown
= render "plantings/progress_bar", status: planting_status(planting), progress: planting_progress(planting)