Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Image < ActiveRecord::Base
- attr_accessible :description, :name, :size, :image, :tag_ids
- has_many :taggings, :dependent => :destroy
- has_many :tags, :through => :taggings
- end
- class Tag < ActiveRecord::Base
- attr_accessible :name
- has_many :taggings, :dependent => :destroy
- has_many :images, :through => :taggings
- end
- resources :images do
- get 'confirm_destroy', :on => :member
- end
- resources :tags
- - @tags.each do |tag|
- = link_to(tag.name, tag)
- class Tag < ActiveRecord::Base
- attr_accessible :name
- has_many :taggings, :dependent => :destroy
- has_many :images, :through => :taggings
- def to_param
- name
- end
- end
- class TagsController < ApplicationController
- def show
- @tag = Tag.find_by_name(params[:id])
- end
- ...
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement