Skip to content

Instantly share code, notes, and snippets.

@peterberkenbosch
Created August 18, 2014 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterberkenbosch/f0cd8463b790bc2eec10 to your computer and use it in GitHub Desktop.
Save peterberkenbosch/f0cd8463b790bc2eec10 to your computer and use it in GitHub Desktop.
add additional content for products

Extend the product sample

Generate migration to add the columns:

bundle exec rails g migration AddExtraContentToProducts
class AddExtraContentToProducts < ActiveRecord::Migration
  def change
    add_column :spree_products, :extra_content, :text
  end
end

then run the migration

bundle exec rake db:migrate

Write a deface override for backend

Read more about deface here

app/overrides/spree/admin/products/_form/add_content_field.html.erb.deface

<!-- insert_bottom "[data-hook='admin_product_form_additional_fields']" -->
<%= f.field_container :extra_content do %>
  <%= f.label :extra_content, Spree.t(:extra_content) %>
  <%= f.text_area :extra_content, :class => 'fullwidth' %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment