1
0
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:
Dan Barber 2013-05-30 08:09:31 +01:00
parent 2723de6f05
commit 02ab844347
8 changed files with 19 additions and 4 deletions

View File

@ -70,3 +70,5 @@ gem 'rdiscount'
gem 'paperclip'
gem 'acts_as_markup'
gem 'haml'
gem 'slugtastic'

View File

@ -190,6 +190,7 @@ GEM
shoulda-matchers (2.1.0)
activesupport (>= 3.0.0)
slop (3.4.3)
slugtastic (1.2.1)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
@ -253,6 +254,7 @@ DEPENDENCIES
ruby_parser
sass-rails (~> 3.2.0)
shoulda-matchers
slugtastic
sqlite3-ruby
squeel
uglifier

View File

@ -1,3 +1,6 @@
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

View File

@ -1,5 +1,6 @@
%tr
%td= category.name
%td= category.slug
%td= category.base_colour
%td{ :class => :actions }
= link_to 'Show', [:admin, category]

View File

@ -1,3 +1,3 @@
= semantic_form_for [:admin, category] do |f|
= f.inputs :name, :description, :base_colour, :sort
= f.inputs :name, :slug, :description, :base_colour, :sort
= f.actions

View File

@ -4,12 +4,13 @@
%thead
%tr
%th Name
%th Slug
%th Base Colour
%th
%tbody
= render :partial => "category", :collection => @categories
%tfoot
%tr
%td{:colspan => 4}
%td{:colspan => 5}
%br/
= link_to 'New Category', new_admin_category_path, :class => [:button, :new]

View File

@ -0,0 +1,5 @@
class AddSlugToCategories < ActiveRecord::Migration
def change
add_column :categories, :slug, :string
end
end

View File

@ -11,7 +11,7 @@
#
# 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|
t.string "email", :default => "", :null => false
@ -47,6 +47,7 @@ ActiveRecord::Schema.define(:version => 20111030164012) do
t.integer "photo_id"
t.string "base_colour"
t.integer "sort"
t.string "slug"
end
create_table "categories_photos", :id => false, :force => true do |t|