際際滷

際際滷Share a Scribd company logo
Loading...
Markdown vs. MongoDB
 A Journey through bleeding edge
          technologies
        for the NeXT Web
RubyMotion vs. Backbone
 A Journey through bleeding edge
          technologies
        for the NeXT Web
Rails OO views
Rails OO views
Rails Views
     for the
OO-savvy Rubyist
M

        V




    C
V




C
Look at: Rails current implementation
def show
 @post = Post.find(params[:id])
 @title = @post.title
end
<h1><%= @post.title %></h1>
<p><%= @post.body %></p>
<html>
 <head><title><%= @title %></title></head>
 <body><%= yield %></body>
</html>
And tell me boy, whats wrong
                    with my @ivars




My names Guybrush threepwood.     Im new in town
Matz told me their only for Objects internal state
Whos in charge here?
Nice talking to you.
So how should
I use @ivars?
When you design a class, you decide
what internal state it has and also
decide how that state is to appear on
the outside (to users of your class).
The internal state is held in instance
variables. The external state is
exposed through methods were call-
ing attributes.
Dave Thomas,
Programming Ruby
Deep in the Rails source...
# Define some internal variables that
# should not be propagated to the view.
self.protected_instance_variables = [
  :@_status, :@_headers, :@_params, :@_env,
  :@_response, :@_request, :@_view_runtime,
  :@_stream, :@_url_options, :@_action_has_layout
]
# Define some internal variables that
# should not be propagated to the view.
self.protected_instance_variables = [
  :@_status, :@_headers, :@_params, :@_env,
  :@_response, :@_request, :@_view_runtime,
  :@_stream, :@_url_options, :@_action_has_layout
]
protected instance variables
protected - instance - variables
And tell me boy, what ya
                 doing about this?




Ill stick with "helper_method".
Give me some "decent_exposure"?
Its "obviews"!
Im made of rubber, youre made of glue.
helper_method
pros: rails standard
cons: verbose, bad semantics,
class level
helper_method
pros: rails standard
cons: verbose, bad semantics,
class level
helper_method
pros: rails standard
cons: verbose, bad semantics,
class level
decent_exposure
pros: easy syntax, good defaults
cons: class level
decent_exposure
pros: easy syntax, good defaults
cons: class level
decent_exposure
pros: easy syntax, good defaults
cons: class level
obviews
pros: easy syntax, action level
cons: unpublished
obviews
pros: easy syntax, action level
cons: unpublished
obviews
pros: easy syntax, action level
cons: unpublished!
We want examples!
We want examples!




class PostsController < ApplicationController
 expose :posts
 def posts; Post.all; end
end
We want examples!




def show
 expose post
end
def post; posts.find(params[:id]) end
We want examples!




def show
 expose post: posts.find(params[:id])
end
We want examples!




<h1><%= pos title %></h1>
           t.
<p><%= post.body %></p>
Rails OO views
Obviews
Obviews
on rubygems shipping today!
Thank you !1
twitter:   @elia
github:    @elia
blog:      dev.mikamai.com
blog:      elia.schito.me


                     MIKAMAI


 No monkeys were harmed during
    the making of this keynote
twitter:   @elia
github:    @elia
blog:      dev.mikamai.com
blog:      elia.schito.me


                     MIKAMAI


 No monkeys were harmed during
    the making of this keynote
Ad

Recommended

Plugging into plugins
Plugging into plugins
Josh Harrison
Building Dynamic Navigation in your Rails 4 Layout
Building Dynamic Navigation in your Rails 4 Layout
Alexander Miller
Hooked on WordPress: WordCamp Columbus
Hooked on WordPress: WordCamp Columbus
Shawn Hooper
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
Joseph Wilk
Cucumber Ru09 Web
Cucumber Ru09 Web
Joseph Wilk
RSpec User Stories
RSpec User Stories
rahoulb
Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)
Bruce Li
Zero to Testing in JavaScript
Zero to Testing in JavaScript
pamselle
MidwestJS Zero to Testing
MidwestJS Zero to Testing
pamselle
Copycopter Presentation by Joe Ferris at BostonRB
Copycopter Presentation by Joe Ferris at BostonRB
bostonrb
You're Doing It Wrong
You're Doing It Wrong
bostonrb
Ruby on Rails - UNISO
Ruby on Rails - UNISO
Lucas Renan
Scaling Complexity in WordPress Enterprise Apps
Scaling Complexity in WordPress Enterprise Apps
Mike Schinkel
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
imoneytech
Unit Tests Aren't Enough
Unit Tests Aren't Enough
Trotter Cashion
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
Tse-Ching Ho
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Bruce Li
RSpec. Part 2
RSpec. Part 2
Vladimir Dementyev
Rails Awesome Email
Rails Awesome Email
imedo.de
RSpec. Part 1
RSpec. Part 1
Vladimir Dementyev
Performance
Performance
Derek Kraan
Haml in 5 minutes
Haml in 5 minutes
cameronbot
Tests in Javascript using Jasmine and Testacular
Tests in Javascript using Jasmine and Testacular
Paulo Cesar Ortins Brito
Reasons To Love Ruby
Reasons To Love Ruby
Ben Scheirman
Mistakes
Mistakes
joren de groof
Mistakes I've made in Ruby and Rails
Mistakes I've made in Ruby and Rails
Bert Goethals
Concurrent PHP in the Etsy API
Concurrent PHP in the Etsy API
Matt Graham
Telling Stories With RSpec
Telling Stories With RSpec
rahoulb
Barcamp Auckland Rails3 presentation
Barcamp Auckland Rails3 presentation
Sociable
Getting started with Rails (2), Season 2
Getting started with Rails (2), Season 2
RORLAB

More Related Content

What's hot (20)

MidwestJS Zero to Testing
MidwestJS Zero to Testing
pamselle
Copycopter Presentation by Joe Ferris at BostonRB
Copycopter Presentation by Joe Ferris at BostonRB
bostonrb
You're Doing It Wrong
You're Doing It Wrong
bostonrb
Ruby on Rails - UNISO
Ruby on Rails - UNISO
Lucas Renan
Scaling Complexity in WordPress Enterprise Apps
Scaling Complexity in WordPress Enterprise Apps
Mike Schinkel
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
imoneytech
Unit Tests Aren't Enough
Unit Tests Aren't Enough
Trotter Cashion
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
Tse-Ching Ho
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Bruce Li
RSpec. Part 2
RSpec. Part 2
Vladimir Dementyev
Rails Awesome Email
Rails Awesome Email
imedo.de
RSpec. Part 1
RSpec. Part 1
Vladimir Dementyev
Performance
Performance
Derek Kraan
Haml in 5 minutes
Haml in 5 minutes
cameronbot
Tests in Javascript using Jasmine and Testacular
Tests in Javascript using Jasmine and Testacular
Paulo Cesar Ortins Brito
Reasons To Love Ruby
Reasons To Love Ruby
Ben Scheirman
Mistakes
Mistakes
joren de groof
Mistakes I've made in Ruby and Rails
Mistakes I've made in Ruby and Rails
Bert Goethals
Concurrent PHP in the Etsy API
Concurrent PHP in the Etsy API
Matt Graham
Telling Stories With RSpec
Telling Stories With RSpec
rahoulb
MidwestJS Zero to Testing
MidwestJS Zero to Testing
pamselle
Copycopter Presentation by Joe Ferris at BostonRB
Copycopter Presentation by Joe Ferris at BostonRB
bostonrb
You're Doing It Wrong
You're Doing It Wrong
bostonrb
Ruby on Rails - UNISO
Ruby on Rails - UNISO
Lucas Renan
Scaling Complexity in WordPress Enterprise Apps
Scaling Complexity in WordPress Enterprise Apps
Mike Schinkel
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
imoneytech
Unit Tests Aren't Enough
Unit Tests Aren't Enough
Trotter Cashion
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
Tse-Ching Ho
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Bruce Li
Rails Awesome Email
Rails Awesome Email
imedo.de
Haml in 5 minutes
Haml in 5 minutes
cameronbot
Tests in Javascript using Jasmine and Testacular
Tests in Javascript using Jasmine and Testacular
Paulo Cesar Ortins Brito
Reasons To Love Ruby
Reasons To Love Ruby
Ben Scheirman
Mistakes I've made in Ruby and Rails
Mistakes I've made in Ruby and Rails
Bert Goethals
Concurrent PHP in the Etsy API
Concurrent PHP in the Etsy API
Matt Graham
Telling Stories With RSpec
Telling Stories With RSpec
rahoulb

Similar to Rails OO views (20)

Barcamp Auckland Rails3 presentation
Barcamp Auckland Rails3 presentation
Sociable
Getting started with Rails (2), Season 2
Getting started with Rails (2), Season 2
RORLAB
HES2011 - joernchen - Ruby on Rails from a Code Auditor Perspective
HES2011 - joernchen - Ruby on Rails from a Code Auditor Perspective
Hackito Ergo Sum
Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11
Pedro Cunha
Ruby On Rails Introduction
Ruby On Rails Introduction
Thomas Fuchs
Finding Restfulness - Madrid.rb April 2014
Finding Restfulness - Madrid.rb April 2014
samlown
Rails 4.0
Rails 4.0
Robert Gogolok
Ruby on Rails
Ruby on Rails
bryanbibat
Ruby on Rails for media
Ruby on Rails for media
Werner Ramaekers
Rails 3 Beautiful Code
Rails 3 Beautiful Code
GreggPollack
Rails2 Pr
Rails2 Pr
xibbar
Debugging on rails
Debugging on rails
Mykhaylo Sorochan
Rail3 intro 29th_sep_surendran
Rail3 intro 29th_sep_surendran
SPRITLE SOFTWARE PRIVATE LIMIT ED
Intro to Rails 4
Intro to Rails 4
Kartik Sahoo
Ruby on rails RAD
Ruby on rails RAD
Alina Danila
Debugging on Rails. Mykhaylo Sorochan
Debugging on Rails. Mykhaylo Sorochan
Sphere Consulting Inc
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Yasuko Ohba
Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7
Brian Hogan
Say Goodbye to Procedural Programming - Nick Sutterer
Say Goodbye to Procedural Programming - Nick Sutterer
Ruby Meditation
悋愕 惡惘惘愕 悋惘惡 惘慍
悋愕 惡惘惘愕 悋惘惡 惘慍
railsbootcamp
Barcamp Auckland Rails3 presentation
Barcamp Auckland Rails3 presentation
Sociable
Getting started with Rails (2), Season 2
Getting started with Rails (2), Season 2
RORLAB
HES2011 - joernchen - Ruby on Rails from a Code Auditor Perspective
HES2011 - joernchen - Ruby on Rails from a Code Auditor Perspective
Hackito Ergo Sum
Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11
Pedro Cunha
Ruby On Rails Introduction
Ruby On Rails Introduction
Thomas Fuchs
Finding Restfulness - Madrid.rb April 2014
Finding Restfulness - Madrid.rb April 2014
samlown
Ruby on Rails
Ruby on Rails
bryanbibat
Ruby on Rails for media
Ruby on Rails for media
Werner Ramaekers
Rails 3 Beautiful Code
Rails 3 Beautiful Code
GreggPollack
Rails2 Pr
Rails2 Pr
xibbar
Intro to Rails 4
Intro to Rails 4
Kartik Sahoo
Ruby on rails RAD
Ruby on rails RAD
Alina Danila
Debugging on Rails. Mykhaylo Sorochan
Debugging on Rails. Mykhaylo Sorochan
Sphere Consulting Inc
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Yasuko Ohba
Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7
Brian Hogan
Say Goodbye to Procedural Programming - Nick Sutterer
Say Goodbye to Procedural Programming - Nick Sutterer
Ruby Meditation
悋愕 惡惘惘愕 悋惘惡 惘慍
悋愕 惡惘惘愕 悋惘惡 惘慍
railsbootcamp
Ad

Recently uploaded (20)

Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
Ad

Rails OO views