Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for draft creation validation and show contents in the index view #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/spree/snippet.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Spree::Snippet < ActiveRecord::Base
validates :slug, :presence => true, :uniqueness => true
validates :slug, :presence => true, :uniqueness => true, :on => :update
attr_accessible :slug, :content
end
9 changes: 4 additions & 5 deletions app/views/spree/admin/snippets/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<%= stylesheet_link_tag 'formtastic' %>
<%= f.label :slug %>:<br />
<%= f.text_field :slug %><br />

<%= f.inputs do %>
<%= f.input :slug %>
<%= f.input :content, :as => :text %>
<% end %>
<%= f.label :content %>:<br />
<%= f.text_area :content %><br />
2 changes: 1 addition & 1 deletion app/views/spree/admin/snippets/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<%= render "spree/shared/error_messages", :target => @snippet %>

<%= semantic_form_for(:snippet, :url => object_url, :html => { :method => :put }) do |f| %>
<%= form_for(:snippet, :url => object_url, :html => { :method => :put }) do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<p class="form-buttons">
<%= button t("actions.update"), nil, 'submit' %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/spree/admin/snippets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<table class="index">
<tr>
<th><%=t("snippets_slug")%></th>
<th><%=t("contents")%></th>
<th><%=t("action")%></th>
</tr>
<tbody>
Expand All @@ -23,6 +24,9 @@
<%= snippet.slug %>
</td>
<td>
<%= snippet.content %>
</td>
<td>
<%= link_to_edit snippet %> &nbsp;
<%= link_to_delete snippet %>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/snippets/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<%= render "spree/shared/error_messages", :target => @snippet %>

<%= semantic_form_for(:snippet, :url => collection_url) do |f| %>
<%= form_for(:snippet, :url => collection_url) do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<p class="form-buttons">
<%= button t("actions.create"), nil, 'submit' %>
Expand Down
1 change: 0 additions & 1 deletion lib/spree_snippets.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'spree_core'
require 'formtastic'

module SpreeSnippets
class Engine < Rails::Engine
Expand Down
1 change: 0 additions & 1 deletion spree_snippets.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Gem::Specification.new do |s|

s.add_dependency 'spree_core', '>= 1.1.0'
s.add_dependency(%q<spree_editor>, [">= 0.50.0"])
s.add_dependency(%q<formtastic>, [">= 2.0.2"])

s.add_development_dependency 'factory_girl'
s.add_development_dependency 'rspec-rails', '~> 2.8.0.rc1'
Expand Down