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 'acts_as_markup'
|
||||
gem 'haml'
|
||||
|
||||
gem 'slugtastic'
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
%tr
|
||||
%td= category.name
|
||||
%td= category.slug
|
||||
%td= category.base_colour
|
||||
%td{ :class => :actions }
|
||||
= link_to 'Show', [:admin, category]
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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]
|
||||
|
||||
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.
|
||||
|
||||
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|
|
||||
|
||||
Loading…
Reference in New Issue
Block a user