ROR e コマースを初めて使用し、製品の有効化に問題があります。概要と入力ボックスに保存されて表示される説明を入力しましたが、説明エディタのプレビューには表示されません。製品をアクティブ化しようとすると、「アクティブ化する前に説明を追加してください」というフラッシュ エラーが表示されます。説明は引き続き入力ボックスに表示されますが、プレビューではその下には表示されません。
product_controller から:
def activate
@product = Product.find(params[:id])
@product.deleted_at = nil
if @product.save
redirect_to admin_merchandise_product_url(@product)
else
flash[:alert] = "Please add a description before Activating."
redirect_to edit_admin_merchandise_products_description_url(@product)
end
end
製品モデルから:
before_save :create_content
...
validates :description_markup,presence: true, length: { maximum: 2255 }, if: :active
...
def create_content
self.description = BlueCloth.new(self.description_markup).to_html unless self.description_markup.blank?
end
ルビー -v 2.0.0p247
レール -v 4.0.2
ブルークロス2.2.0
私が追加した唯一の宝石はtherubyracerでした
私の投稿を読んでくれてありがとう。