Skip to content

Instantly share code, notes, and snippets.

@1990prashant
Created March 16, 2016 06:47
Show Gist options
  • Save 1990prashant/8702d8f4f64b95208dfb to your computer and use it in GitHub Desktop.
Save 1990prashant/8702d8f4f64b95208dfb to your computer and use it in GitHub Desktop.
Render a page through controller
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