ACTS AS André Tagliati @tagliati http://www.tagliati.com.br [email_address]
Tagliati E @makotovh papagaio de pirata
http://www.cowboycoded.com/tag/acts_as/   http://www.flickr.com/photos/loop_oh/3338084111/
DRY DONT REPEAT YOURSELF DRY http://www.flickr.com/photos/vorty/850290006/
Review Ou Acts as Reviewable REVIEWABLE
Hands On Vamos ver como é isso. HANDS ON  http://www.flickr.com/photos/jurvetson/489257240/
rails g model  review review_text:text t.references  :reviewable ,  :polymorphic  =>  true
Ali! No teto!  Polymorphic!!!! Me enganei.  É só um PomboRanger.
class  Review < ActiveRecord::Base belongs_to  :reviewable ,  :polymorphic => true end module  Reviewable def  is_reviewable has_many  :reviews ,  :as => :reviewable ,  :dependent => :destroy include InstanceMethods end module  InstanceMethods def  reviewable? true end end end ActiveRecord::Base.extend Reviewable
class  Produto < ActiveRecord::Base is_reviewable end class  Categoria < ActiveRecord::Base is_reviewable end class  Artigo < ActiveRecord::Base is_reviewable end
http://www.flickr.com/photos/80835774@N00/5442336248/ hehaEHAEHaeHe haHeAHeAHeAHe HAEhae Assim fica fácil!
product = Product.new => # product.reviewable? => true product.reviews => []  #nenhum review ainda product.save product.reviews.create(review_text: &quot;test&quot;) => #<Review id: 1, reviewable_type: &quot;Product&quot;, reviewable_id: 101 ....> product.reviews.size => 1
BLOCOS
Dúvidas?

More Related Content

PDF
Intro to Laravel 4 : By Chris Moore
PPTX
Mantendo e mails sobre controle
PDF
JavaScript as a First Class Language
PPT
Libpunk0.01
PDF
Think Like An Entrepreneur (for GoToWebinar)
PPTX
Social Media Tools That Work
PPTX
My i spy
PPT
Our students won_t_research_the_way_we_did
Intro to Laravel 4 : By Chris Moore
Mantendo e mails sobre controle
JavaScript as a First Class Language
Libpunk0.01
Think Like An Entrepreneur (for GoToWebinar)
Social Media Tools That Work
My i spy
Our students won_t_research_the_way_we_did

What's hot (11)

PDF
Growing Grails Software, Driven by Domain
PDF
17 nov 2020 nofollow backlinks
PPTX
Tools for Self-Awareness
PDF
Patterns in your Pastry
PDF
iCrocco
PDF
Photoshop's New Groove
PPTX
Dom XSS: Encounters of the3rd kind
PPTX
My i spy
PPT
Oow08slides
ODP
Connecting the Open Social Web with OStatus (#FOWA2010)
PDF
Top 10 free image websites
Growing Grails Software, Driven by Domain
17 nov 2020 nofollow backlinks
Tools for Self-Awareness
Patterns in your Pastry
iCrocco
Photoshop's New Groove
Dom XSS: Encounters of the3rd kind
My i spy
Oow08slides
Connecting the Open Social Web with OStatus (#FOWA2010)
Top 10 free image websites
Ad

Viewers also liked (6)

PPT
Braida seminario catas 12 giugno 2013 versione proiezione
PPT
Linkedinpowerpointfinal 124053772884 Phpapp02
PPT
The 1-2 Punch for Better Boards
PDF
Business grammar
PPT
Theres No 'I' in Team
PDF
Los secretos mejor guardados de Madrid
Braida seminario catas 12 giugno 2013 versione proiezione
Linkedinpowerpointfinal 124053772884 Phpapp02
The 1-2 Punch for Better Boards
Business grammar
Theres No 'I' in Team
Los secretos mejor guardados de Madrid
Ad

Recently uploaded (20)

PPTX
Chapter 5: Probability Theory and Statistics
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Architecture types and enterprise applications.pdf
PDF
CloudStack 4.21: First Look Webinar slides
PPTX
Modernising the Digital Integration Hub
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Hybrid model detection and classification of lung cancer
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Unlock new opportunities with location data.pdf
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPT
Geologic Time for studying geology for geologist
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Benefits of Physical activity for teenagers.pptx
Chapter 5: Probability Theory and Statistics
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Architecture types and enterprise applications.pdf
CloudStack 4.21: First Look Webinar slides
Modernising the Digital Integration Hub
WOOl fibre morphology and structure.pdf for textiles
A novel scalable deep ensemble learning framework for big data classification...
Hybrid model detection and classification of lung cancer
Taming the Chaos: How to Turn Unstructured Data into Decisions
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Unlock new opportunities with location data.pdf
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Enhancing emotion recognition model for a student engagement use case through...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Geologic Time for studying geology for geologist
Zenith AI: Advanced Artificial Intelligence
observCloud-Native Containerability and monitoring.pptx
Benefits of Physical activity for teenagers.pptx

Act as

Editor's Notes

  • #4: Apresentação tomando como base explicação em artigo de cowboycoded
  • #6: Criar um &apos;plugin&apos; que permita fazer reviews de um produto ou qualquer outra coisa
  • #9: Polymorphic relationships allow you to have a single model that can be associated to an arbitrary number of other model types. Example For instance, let&apos;s say you have a contacts database utilizing two models, Person and Company. Both people and companies have addresses that you want to store in the database, and you want to be able to query against all addresses at once (say for a location-based search). Polymorphic associations make this easy in Rails. Let&apos;s assume that you already have your Person and Company models created and are just creating your Address model. When you create your migration you will denote the polymorphic relationship using references: http://wiki.rubyonrails.org/howtos/db-relationships/polymorphic