Created
March 16, 2016 06:47
-
-
Save 1990prashant/8702d8f4f64b95208dfb to your computer and use it in GitHub Desktop.
Render a page through controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def comment | |
@comment = Spree::Post.new(post_params) | |
@comment.attributes = {user_id: current_spree_user.id} | |
if @comment.save | |
render json: { | |
success: true, | |
comment: render_to_string((@comment.parent_id.blank? ? 'spree/shared/_previous_comments' : 'spree/shared/_comment_line_item'), :layout => false, :locals => { :comment => @comment }) | |
} | |
else | |
render json: { | |
success: false, | |
errors: @comment.errors.full_messages.join(", ") | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment