mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-14 11:15:48 -04:00
Rubocop
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class LikesController < ApplicationController
|
||||
before_action :authenticate_member!, :except => :index
|
||||
|
||||
before_action :authenticate_member!, except: :index
|
||||
|
||||
respond_to :html, :json
|
||||
|
||||
def create
|
||||
@@ -11,19 +11,19 @@ class LikesController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @like.save
|
||||
format.html { redirect_to @like.likeable }
|
||||
format.json {
|
||||
render({
|
||||
format.json do
|
||||
render(
|
||||
json: {
|
||||
id: @like.likeable.id,
|
||||
liked_by_member: true,
|
||||
description: ActionController::Base.helpers.pluralize(@like.likeable.likes.count, "like"),
|
||||
url: like_path(@like, format: :json)
|
||||
},
|
||||
},
|
||||
status: 201
|
||||
})
|
||||
}
|
||||
)
|
||||
end
|
||||
else
|
||||
format.html do
|
||||
format.html do
|
||||
flash[:error] = 'Unable to like'
|
||||
redirect_to @like.likeable
|
||||
end
|
||||
@@ -37,17 +37,17 @@ class LikesController < ApplicationController
|
||||
respond_to do |format|
|
||||
if like.destroy
|
||||
format.html { redirect_to likeable }
|
||||
format.json {
|
||||
render({
|
||||
format.json do
|
||||
render(
|
||||
json: {
|
||||
id: likeable.id,
|
||||
liked_by_member: false,
|
||||
description: ActionController::Base.helpers.pluralize(likeable.likes.count, "like"),
|
||||
url: likes_path(Like.new, "#{likeable.class.name.underscore}_id", likeable.id, format: :json)
|
||||
},
|
||||
},
|
||||
status: 200
|
||||
})
|
||||
}
|
||||
)
|
||||
end
|
||||
else
|
||||
format.html do
|
||||
flash[:error] = 'Unable to unlike'
|
||||
@@ -61,14 +61,11 @@ class LikesController < ApplicationController
|
||||
|
||||
def find_likeable
|
||||
params.each do |name, value|
|
||||
if name =~ /(.+)_id$/
|
||||
return $1.classify.constantize.find(value)
|
||||
end
|
||||
return $1.classify.constantize.find(value) if name =~ /(.+)_id$/
|
||||
end
|
||||
end
|
||||
|
||||
def like_params
|
||||
params.require(:like).permit(:member, :likeable)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user