Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. class Image < ActiveRecord::Base
  2. attr_accessible :description, :name, :size, :image, :tag_ids
  3.  
  4. has_many :taggings, :dependent => :destroy
  5. has_many :tags, :through => :taggings
  6. end
  7.  
  8. class Tag < ActiveRecord::Base
  9. attr_accessible :name
  10. has_many :taggings, :dependent => :destroy
  11. has_many :images, :through => :taggings
  12.  
  13. end
  14.  
  15. resources :images do
  16. get 'confirm_destroy', :on => :member
  17. end
  18. resources :tags
  19.  
  20. - @tags.each do |tag|
  21. = link_to(tag.name, tag)
  22.  
  23. class Tag < ActiveRecord::Base
  24. attr_accessible :name
  25. has_many :taggings, :dependent => :destroy
  26. has_many :images, :through => :taggings
  27.  
  28. def to_param
  29. name
  30. end
  31. end
  32.  
  33. class TagsController < ApplicationController
  34.  
  35. def show
  36. @tag = Tag.find_by_name(params[:id])
  37. end
  38.  
  39. ...
  40.  
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement