SlideShare une entreprise Scribd logo
1  sur  14
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?

Contenu connexe

Tendances

Growing Grails Software, Driven by Domain
Growing Grails Software, Driven by DomainGrowing Grails Software, Driven by Domain
Growing Grails Software, Driven by DomainYukei Wachi
 
17 nov 2020 nofollow backlinks
17 nov 2020 nofollow backlinks17 nov 2020 nofollow backlinks
17 nov 2020 nofollow backlinksEmmaRose49
 
Tools for Self-Awareness
Tools for Self-AwarenessTools for Self-Awareness
Tools for Self-AwarenessLori Cotten
 
Patterns in your Pastry
Patterns in your PastryPatterns in your Pastry
Patterns in your PastryJames Watts
 
Photoshop's New Groove
Photoshop's New GroovePhotoshop's New Groove
Photoshop's New GrooveDan Rose
 
Dom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kindDom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kindBishan Singh
 
My i spy
My i spyMy i spy
My i spyEthan
 
Connecting the Open Social Web with OStatus (#FOWA2010)
Connecting the Open Social Web with OStatus (#FOWA2010)Connecting the Open Social Web with OStatus (#FOWA2010)
Connecting the Open Social Web with OStatus (#FOWA2010)Jon Phillips
 
Top 10 free image websites
Top 10 free image websites Top 10 free image websites
Top 10 free image websites KanikaGrover13
 

Tendances (11)

Growing Grails Software, Driven by Domain
Growing Grails Software, Driven by DomainGrowing Grails Software, Driven by Domain
Growing Grails Software, Driven by Domain
 
17 nov 2020 nofollow backlinks
17 nov 2020 nofollow backlinks17 nov 2020 nofollow backlinks
17 nov 2020 nofollow backlinks
 
Tools for Self-Awareness
Tools for Self-AwarenessTools for Self-Awareness
Tools for Self-Awareness
 
Patterns in your Pastry
Patterns in your PastryPatterns in your Pastry
Patterns in your Pastry
 
iCrocco
iCroccoiCrocco
iCrocco
 
Photoshop's New Groove
Photoshop's New GroovePhotoshop's New Groove
Photoshop's New Groove
 
Dom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kindDom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kind
 
My i spy
My i spyMy i spy
My i spy
 
Oow08slides
Oow08slidesOow08slides
Oow08slides
 
Connecting the Open Social Web with OStatus (#FOWA2010)
Connecting the Open Social Web with OStatus (#FOWA2010)Connecting the Open Social Web with OStatus (#FOWA2010)
Connecting the Open Social Web with OStatus (#FOWA2010)
 
Top 10 free image websites
Top 10 free image websites Top 10 free image websites
Top 10 free image websites
 

En vedette

Braida seminario catas 12 giugno 2013 versione proiezione
Braida   seminario catas 12 giugno 2013 versione proiezioneBraida   seminario catas 12 giugno 2013 versione proiezione
Braida seminario catas 12 giugno 2013 versione proiezioneAlessandro Braida
 
Linkedinpowerpointfinal 124053772884 Phpapp02
Linkedinpowerpointfinal 124053772884 Phpapp02Linkedinpowerpointfinal 124053772884 Phpapp02
Linkedinpowerpointfinal 124053772884 Phpapp02jellez
 
The 1-2 Punch for Better Boards
The 1-2 Punch for Better BoardsThe 1-2 Punch for Better Boards
The 1-2 Punch for Better BoardsRolf Crocker
 
Business grammar
Business grammarBusiness grammar
Business grammarAdina Badea
 
Theres No 'I' in Team
Theres No 'I' in TeamTheres No 'I' in Team
Theres No 'I' in TeamRolf Crocker
 
Los secretos mejor guardados de Madrid
Los secretos mejor guardados de MadridLos secretos mejor guardados de Madrid
Los secretos mejor guardados de MadridAdina Badea
 

En vedette (6)

Braida seminario catas 12 giugno 2013 versione proiezione
Braida   seminario catas 12 giugno 2013 versione proiezioneBraida   seminario catas 12 giugno 2013 versione proiezione
Braida seminario catas 12 giugno 2013 versione proiezione
 
Linkedinpowerpointfinal 124053772884 Phpapp02
Linkedinpowerpointfinal 124053772884 Phpapp02Linkedinpowerpointfinal 124053772884 Phpapp02
Linkedinpowerpointfinal 124053772884 Phpapp02
 
The 1-2 Punch for Better Boards
The 1-2 Punch for Better BoardsThe 1-2 Punch for Better Boards
The 1-2 Punch for Better Boards
 
Business grammar
Business grammarBusiness grammar
Business grammar
 
Theres No 'I' in Team
Theres No 'I' in TeamTheres No 'I' in Team
Theres No 'I' in Team
 
Los secretos mejor guardados de Madrid
Los secretos mejor guardados de MadridLos secretos mejor guardados de Madrid
Los secretos mejor guardados de Madrid
 

Dernier

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Add Reviews to Models with Acts As Reviewable

Notes de l'éditeur

  1. Apresentação tomando como base explicação em artigo de cowboycoded
  2. Criar um &apos;plugin&apos; que permita fazer reviews de um produto ou qualquer outra coisa
  3. 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