mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Add slug to categories.
This commit is contained in:
parent
2723de6f05
commit
02ab844347
2
Gemfile
2
Gemfile
@ -70,3 +70,5 @@ gem 'rdiscount'
|
|||||||
gem 'paperclip'
|
gem 'paperclip'
|
||||||
gem 'acts_as_markup'
|
gem 'acts_as_markup'
|
||||||
gem 'haml'
|
gem 'haml'
|
||||||
|
|
||||||
|
gem 'slugtastic'
|
||||||
|
|||||||
@ -190,6 +190,7 @@ GEM
|
|||||||
shoulda-matchers (2.1.0)
|
shoulda-matchers (2.1.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
slop (3.4.3)
|
slop (3.4.3)
|
||||||
|
slugtastic (1.2.1)
|
||||||
sprockets (2.2.2)
|
sprockets (2.2.2)
|
||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
@ -253,6 +254,7 @@ DEPENDENCIES
|
|||||||
ruby_parser
|
ruby_parser
|
||||||
sass-rails (~> 3.2.0)
|
sass-rails (~> 3.2.0)
|
||||||
shoulda-matchers
|
shoulda-matchers
|
||||||
|
slugtastic
|
||||||
sqlite3-ruby
|
sqlite3-ruby
|
||||||
squeel
|
squeel
|
||||||
uglifier
|
uglifier
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
class Category < ActiveRecord::Base
|
class Category < ActiveRecord::Base
|
||||||
has_and_belongs_to_many :photos
|
has_and_belongs_to_many :photos
|
||||||
|
validates_presence_of :name, :slug
|
||||||
|
|
||||||
|
has_slug :slug, from: :name
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
%tr
|
%tr
|
||||||
%td= category.name
|
%td= category.name
|
||||||
|
%td= category.slug
|
||||||
%td= category.base_colour
|
%td= category.base_colour
|
||||||
%td{ :class => :actions }
|
%td{ :class => :actions }
|
||||||
= link_to 'Show', [:admin, category]
|
= link_to 'Show', [:admin, category]
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
= semantic_form_for [:admin, category] do |f|
|
= semantic_form_for [:admin, category] do |f|
|
||||||
= f.inputs :name, :description, :base_colour, :sort
|
= f.inputs :name, :slug, :description, :base_colour, :sort
|
||||||
= f.actions
|
= f.actions
|
||||||
|
|||||||
@ -4,12 +4,13 @@
|
|||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th Name
|
%th Name
|
||||||
|
%th Slug
|
||||||
%th Base Colour
|
%th Base Colour
|
||||||
%th
|
%th
|
||||||
%tbody
|
%tbody
|
||||||
= render :partial => "category", :collection => @categories
|
= render :partial => "category", :collection => @categories
|
||||||
%tfoot
|
%tfoot
|
||||||
%tr
|
%tr
|
||||||
%td{:colspan => 4}
|
%td{:colspan => 5}
|
||||||
%br/
|
%br/
|
||||||
= link_to 'New Category', new_admin_category_path, :class => [:button, :new]
|
= link_to 'New Category', new_admin_category_path, :class => [:button, :new]
|
||||||
|
|||||||
5
db/migrate/20130522071132_add_slug_to_categories.rb
Normal file
5
db/migrate/20130522071132_add_slug_to_categories.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddSlugToCategories < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :categories, :slug, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20111030164012) do
|
ActiveRecord::Schema.define(:version => 20130522071132) do
|
||||||
|
|
||||||
create_table "admin_users", :force => true do |t|
|
create_table "admin_users", :force => true do |t|
|
||||||
t.string "email", :default => "", :null => false
|
t.string "email", :default => "", :null => false
|
||||||
@ -47,6 +47,7 @@ ActiveRecord::Schema.define(:version => 20111030164012) do
|
|||||||
t.integer "photo_id"
|
t.integer "photo_id"
|
||||||
t.string "base_colour"
|
t.string "base_colour"
|
||||||
t.integer "sort"
|
t.integer "sort"
|
||||||
|
t.string "slug"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "categories_photos", :id => false, :force => true do |t|
|
create_table "categories_photos", :id => false, :force => true do |t|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user