SlideShare a Scribd company logo
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

What's hot

Growing Grails Software, Driven by Domain
Growing Grails Software, Driven by DomainGrowing Grails Software, Driven by Domain
Growing Grails Software, Driven by Domain
Yukei Wachi
 
17 nov 2020 nofollow backlinks
17 nov 2020 nofollow backlinks17 nov 2020 nofollow backlinks
17 nov 2020 nofollow backlinks
EmmaRose49
 
Tools for Self-Awareness
Tools for Self-AwarenessTools for Self-Awareness
Tools for Self-Awareness
Lori Cotten
 
Patterns in your Pastry
Patterns in your PastryPatterns in your Pastry
Patterns in your Pastry
James Watts
 
iCrocco
iCroccoiCrocco
iCrocco
Dario Violi
 
Photoshop's New Groove
Photoshop's New GroovePhotoshop's New Groove
Photoshop's New Groove
Dan Rose
 
Dom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kindDom XSS: Encounters of the3rd kind
Dom XSS: Encounters of the3rd kind
Bishan Singh
 
My i spy
My i spyMy i spy
My i spy
Ethan
 
Oow08slides
Oow08slidesOow08slides
Oow08slides
Jake Kuramoto
 
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
 

What's hot (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
 

Viewers also liked

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 Phpapp02
jellez
 
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
Rolf Crocker
 
Business grammar
Business grammarBusiness grammar
Business grammar
Adina Badea
 
Theres No 'I' in Team
Theres No 'I' in TeamTheres No 'I' in Team
Theres No 'I' in Team
Rolf Crocker
 
Los secretos mejor guardados de Madrid
Los secretos mejor guardados de MadridLos secretos mejor guardados de Madrid
Los secretos mejor guardados de Madrid
Adina Badea
 

Viewers also liked (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
 

Recently uploaded

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 

Recently uploaded (20)

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 

Act as

Editor's Notes

  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