mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-22 23:14:28 -04:00
Rubocop fix up
This commit is contained in:
1 parent
0759ca9039
commit
f1ad9cc3c7
6 files changed
+24
-10
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,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,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
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user