RailsCasts Pro episodes are now free!

Learn more or hide this

Reza Ardestani's Profile

GitHub User: reardestani

Comments by Reza Ardestani

Avatar

If you are going to use :histroy with friendly_id 5 you should consider the new change in slugs' regenrations. As version 5 the slugs are not updated on save unless you set them to nill first.

Updating a product
  def update
    @product.slug = nil
    respond_to do |format|
      if @product.update(product_params)
        format.html { redirect_to @product, notice: 'Product was successfully updated.' }
        format.json { render :show, status: :ok, location: @product }
      else
        format.html { render :edit }
        format.json { render json: @product.errors, status: :unprocessable_entity }
      end
    end
  end