-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added condition for inheriting controller from frontend #27
base: 2024
Are you sure you want to change the base?
Conversation
…horized and unauthorized accesses
* Admin view for question settings * Unique products in pending questions
@@ -1,24 +1,26 @@ | |||
class Spree::ProductQuestionsController < Spree::Api::V2::ResourceController | |||
before_action :load_data | |||
if Spree::Core::Engine.frontend_available? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will run into issue while running into problem as it is expected that class name is defined according to name of controller..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module Spree
if Spree::Core::Engine.frontend_available?
class ProductQuestionsController < StoreController
before_action :load_data
def create
question = @product.product_questions.new(allowed_params)
question.user_id = current_spree_user.id
if question.save
flash[:notice] = t('question.sent')
redirect_to @product
else
flash[:error] = question.errors.full_messages.to_sentence
redirect_to @product
end
end
private
def load_data
@product = Spree::Product.find(allowed_params[:product_id])
end
def allowed_params
params.require(:product_question).permit(:content, :product_id)
end
end
else
class ProductQuestionsController
# Dummy class to satisfy Zeitwerk autoloading
end
end
end
@mausamp I think this kind of approach would be better so we dont violate zeitwerk autoloading as well..
let me know your thoughts, here we are defining dummy ProductQuestionsController when frontend is not available in the project
@mausamp please take care of merge conflicts |
No description provided.