SlideShare a Scribd company logo
1 of 16
NoMethodError
Monday, June 10, 13
SUBLIMETEXT MULTIPLE
CURSORS
• CMD+left
• Alt+left
• selection
•Copy/Paste
• CMD+d
•Ctrl+CMD+g
Monday, June 10, 13
GIT REFLOG AKA UNDO ANYTHING
SHIT!
Monday, June 10, 13
‘DEBUGGING’ STUFF
WITHOUT DOCS
export BUNDLER_EDITOR=subl
bundle open rails
use Sublime Find in files
Tudi varianta:
git clone ....
Gemfile:
gem :devise, path:‘/home/user/stuff/devise’
Monday, June 10, 13
rake db:create db:migrate db:seed
or use Zeus and don’t care
Monday, June 10, 13
MEMOIZATIONTRICKS
def data
@data ||= begin
data = fetch_data("http://www.com")
JSON.load(data)
rescue Errno::ECONNREFUSED
{ error: 'Connection refused.' }
end
end
###
def data
@data = get_data unless instance_variable_defined?(:@data)
end
def get_data
# ...
rescue
# ...
end
Monday, June 10, 13
rails g model Fart ass:references
rails g model Fart ass:belongs_to
automatically adds index
automatically puts belongs_to into model
class CreateFarts < ActiveRecord::Migration
def change
create_table :farts do |t|
t.references :ass, index: true
t.belongs_to :ass, index: true
t.timestamps
end
end
end
class Fart < ActiveRecord::Base
belongs_to :ass
end
Monday, June 10, 13
RUBY INSTRUCTION
SEQUENCE
Monday, June 10, 13
PRESENT?
def show
@user = User.find(params[:id])
if @user.present?
# ...
end
end
def show
@user = User.find(params[:id])
if @user
# ...
end
end
STOP ABUSING!
Monday, June 10, 13
PRESENCE
"".presence # => nil
"X".presence # => "X"
[].presence # => nil
[1].presence # => [1]
Monday, June 10, 13
ACCEPTS_NESTED_ATTRIBUTES_FOR
bundle open rails
implement custom version in our app
Monday, June 10, 13
ADD METHODS WITH SCOPE
class Fart < ActiveRecord::Base
scope :page, ->(page = 1) { where(page: page) } do
def per(per = 10)
limit(per)
end
end
end
Fart.per(20)
# NoMethodError: undefined method `per'
Fart.page(2).per(20).to_sql
# => "SELECT "farts".* FROM "farts" WHERE "farts"."page" = 2
LIMIT 20"
Kaminari does this: .page(...) adds .per(...)
Monday, June 10, 13
GROUP COUNT
# Useless:
Fart.group(:ass_id).count # => { 1 => 1, 2 => 1 }
# Slow:
Fart.group(:ass_id).count.keys.count # => 2
# Fast + should work for any query:
scope = Fart.group(:ass_id).select("1")
query = "SELECT count(*) AS count_all FROM (#{scope.to_sql}) x"
ActiveRecord::Base.connection.execute(query)["count_all"].to_i # => 2
# Gem: mrbrdo/active_record_group_count
Fart.group(:ass_id).returns_count_sum.count # => 2
# Works with Kaminari
Fart.group(:ass_id).returns_count_sum.page(1).per(10)
Monday, June 10, 13
RAILS 3 ASSIGN_ATTRIBUTES
WITHOUT PROTECTION
PS: use strong_parameters (even in Rails 3), attr_accessible sucks
Fart.new(name: 'lol') # ActiveModel::MassAssignmentSecurity::Error
fart = Fart.new({ name: 'lol' }, without_protection: true)
fart.update_attributes({ name: 'lol' }, without_protection: true)
fart.assign_attributes({ name: 'lol' }, without_protection: true)
be careful
Monday, June 10, 13
RAILS CONSOLE SANDBOX
Monday, June 10, 13
Monday, June 10, 13

More Related Content

What's hot

De 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKDe 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKAdolfo Sanz De Diego
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽taobao.com
 
How to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter KriensHow to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter Kriensmfrancis
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Yuriko IKEDA
 
PHPerのためのPerl入門@ Kansai.pm#12
PHPerのためのPerl入門@ Kansai.pm#12PHPerのためのPerl入門@ Kansai.pm#12
PHPerのためのPerl入門@ Kansai.pm#12Kazuki KOMORI
 
Laporan setting dns
Laporan setting dnsLaporan setting dns
Laporan setting dnsSeptian Adi
 
Python Developer's Daily Routine
Python Developer's Daily RoutinePython Developer's Daily Routine
Python Developer's Daily RoutineMaxim Avanov
 
Noung — Snakes of the Tonle Sap
Noung — Snakes of the Tonle SapNoung — Snakes of the Tonle Sap
Noung — Snakes of the Tonle SapNerd Nite Siem Reap
 
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivostiRiki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivostiDevelcz
 
Plone Conference 2008 Lightning Talk Static Zope Rpx
Plone Conference 2008 Lightning Talk Static Zope RpxPlone Conference 2008 Lightning Talk Static Zope Rpx
Plone Conference 2008 Lightning Talk Static Zope RpxParis, France
 
The Australian-The Deal Magazine
The Australian-The Deal MagazineThe Australian-The Deal Magazine
The Australian-The Deal Magazinedrocallaghan
 

What's hot (20)

Cpsh sh
Cpsh shCpsh sh
Cpsh sh
 
De 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKDe 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWK
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽
 
How to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter KriensHow to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter Kriens
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境
 
PHPerのためのPerl入門@ Kansai.pm#12
PHPerのためのPerl入門@ Kansai.pm#12PHPerのためのPerl入門@ Kansai.pm#12
PHPerのためのPerl入門@ Kansai.pm#12
 
M.php
M.phpM.php
M.php
 
Laporan setting dns
Laporan setting dnsLaporan setting dns
Laporan setting dns
 
Python Developer's Daily Routine
Python Developer's Daily RoutinePython Developer's Daily Routine
Python Developer's Daily Routine
 
SSLC
SSLCSSLC
SSLC
 
Noung — Snakes of the Tonle Sap
Noung — Snakes of the Tonle SapNoung — Snakes of the Tonle Sap
Noung — Snakes of the Tonle Sap
 
Ruby Robots
Ruby RobotsRuby Robots
Ruby Robots
 
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivostiRiki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
 
Python Menu
Python MenuPython Menu
Python Menu
 
Plone Conference 2008 Lightning Talk Static Zope Rpx
Plone Conference 2008 Lightning Talk Static Zope RpxPlone Conference 2008 Lightning Talk Static Zope Rpx
Plone Conference 2008 Lightning Talk Static Zope Rpx
 
Git avançado
Git avançadoGit avançado
Git avançado
 
Es6 good parts
Es6 good partsEs6 good parts
Es6 good parts
 
Functional php
Functional phpFunctional php
Functional php
 
Clojure入門
Clojure入門Clojure入門
Clojure入門
 
The Australian-The Deal Magazine
The Australian-The Deal MagazineThe Australian-The Deal Magazine
The Australian-The Deal Magazine
 

Viewers also liked

Papeleta SPIDO
Papeleta SPIDOPapeleta SPIDO
Papeleta SPIDOPedro Mqw
 
Dilemas da maternidade apresentacao
Dilemas da maternidade apresentacaoDilemas da maternidade apresentacao
Dilemas da maternidade apresentacaoalinefiamenghi
 
BORM mesa de negociación
BORM mesa de negociaciónBORM mesa de negociación
BORM mesa de negociaciónPedro Mqw
 
Minigrid review
Minigrid reviewMinigrid review
Minigrid reviewuprmady
 
Seminars Slidecast and Professional Reflection
Seminars Slidecast and Professional ReflectionSeminars Slidecast and Professional Reflection
Seminars Slidecast and Professional ReflectionSebastiaan Debou
 
TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1
TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1
TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1FANNY JEM WONG MIÑÁN
 
Concept of energy transmission & distribution
Concept of energy transmission & distribution Concept of energy transmission & distribution
Concept of energy transmission & distribution ZunAib Ali
 

Viewers also liked (10)

Resume 97-2003
Resume 97-2003Resume 97-2003
Resume 97-2003
 
Papeleta SPIDO
Papeleta SPIDOPapeleta SPIDO
Papeleta SPIDO
 
Dilemas da maternidade apresentacao
Dilemas da maternidade apresentacaoDilemas da maternidade apresentacao
Dilemas da maternidade apresentacao
 
BORM mesa de negociación
BORM mesa de negociaciónBORM mesa de negociación
BORM mesa de negociación
 
3.meteo vetta dante
3.meteo vetta dante3.meteo vetta dante
3.meteo vetta dante
 
Image180314132650
Image180314132650Image180314132650
Image180314132650
 
Minigrid review
Minigrid reviewMinigrid review
Minigrid review
 
Seminars Slidecast and Professional Reflection
Seminars Slidecast and Professional ReflectionSeminars Slidecast and Professional Reflection
Seminars Slidecast and Professional Reflection
 
TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1
TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1
TEORIAS DE LA PERSONALIDAD- CARACTER Y TEMPERAMENTO-FANNY JEM WONG- SEMANA 1
 
Concept of energy transmission & distribution
Concept of energy transmission & distribution Concept of energy transmission & distribution
Concept of energy transmission & distribution
 

Similar to Nomethoderror talk

Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosEdgar Suarez
 
D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4Jan Berdajs
 
A Better UJS for Rails
A Better UJS for RailsA Better UJS for Rails
A Better UJS for RailsZack Siri
 
Dtrace и немного магии
Dtrace и немного магииDtrace и немного магии
Dtrace и немного магииDan Kruchinin
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...Functional Thursday
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mateCodemotion
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Peter Higgins
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkBen Scofield
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8Allie Jones
 
Python utan-stodhjul-motorsag
Python utan-stodhjul-motorsagPython utan-stodhjul-motorsag
Python utan-stodhjul-motorsagniklal
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeWim Godden
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Slides changes symfony23
Slides changes symfony23Slides changes symfony23
Slides changes symfony23Javier López
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the newRemy Sharp
 
Workflow para desenvolvimento Web & Mobile usando grunt.js
Workflow para desenvolvimento Web & Mobile usando grunt.jsWorkflow para desenvolvimento Web & Mobile usando grunt.js
Workflow para desenvolvimento Web & Mobile usando grunt.jsDavidson Fellipe
 

Similar to Nomethoderror talk (20)

Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutos
 
D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4
 
Migrating legacy data
Migrating legacy dataMigrating legacy data
Migrating legacy data
 
A Better UJS for Rails
A Better UJS for RailsA Better UJS for Rails
A Better UJS for Rails
 
Dtrace и немного магии
Dtrace и немного магииDtrace и немного магии
Dtrace и немного магии
 
[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...[FT-7][snowmantw] How to make a new functional language and make the world be...
[FT-7][snowmantw] How to make a new functional language and make the world be...
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8
 
Python utan-stodhjul-motorsag
Python utan-stodhjul-motorsagPython utan-stodhjul-motorsag
Python utan-stodhjul-motorsag
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Slides changes symfony23
Slides changes symfony23Slides changes symfony23
Slides changes symfony23
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
 
Django quickstart
Django quickstartDjango quickstart
Django quickstart
 
Workflow para desenvolvimento Web & Mobile usando grunt.js
Workflow para desenvolvimento Web & Mobile usando grunt.jsWorkflow para desenvolvimento Web & Mobile usando grunt.js
Workflow para desenvolvimento Web & Mobile usando grunt.js
 

Recently uploaded

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Nomethoderror talk

  • 2. SUBLIMETEXT MULTIPLE CURSORS • CMD+left • Alt+left • selection •Copy/Paste • CMD+d •Ctrl+CMD+g Monday, June 10, 13
  • 3. GIT REFLOG AKA UNDO ANYTHING SHIT! Monday, June 10, 13
  • 4. ‘DEBUGGING’ STUFF WITHOUT DOCS export BUNDLER_EDITOR=subl bundle open rails use Sublime Find in files Tudi varianta: git clone .... Gemfile: gem :devise, path:‘/home/user/stuff/devise’ Monday, June 10, 13
  • 5. rake db:create db:migrate db:seed or use Zeus and don’t care Monday, June 10, 13
  • 6. MEMOIZATIONTRICKS def data @data ||= begin data = fetch_data("http://www.com") JSON.load(data) rescue Errno::ECONNREFUSED { error: 'Connection refused.' } end end ### def data @data = get_data unless instance_variable_defined?(:@data) end def get_data # ... rescue # ... end Monday, June 10, 13
  • 7. rails g model Fart ass:references rails g model Fart ass:belongs_to automatically adds index automatically puts belongs_to into model class CreateFarts < ActiveRecord::Migration def change create_table :farts do |t| t.references :ass, index: true t.belongs_to :ass, index: true t.timestamps end end end class Fart < ActiveRecord::Base belongs_to :ass end Monday, June 10, 13
  • 9. PRESENT? def show @user = User.find(params[:id]) if @user.present? # ... end end def show @user = User.find(params[:id]) if @user # ... end end STOP ABUSING! Monday, June 10, 13
  • 10. PRESENCE "".presence # => nil "X".presence # => "X" [].presence # => nil [1].presence # => [1] Monday, June 10, 13
  • 11. ACCEPTS_NESTED_ATTRIBUTES_FOR bundle open rails implement custom version in our app Monday, June 10, 13
  • 12. ADD METHODS WITH SCOPE class Fart < ActiveRecord::Base scope :page, ->(page = 1) { where(page: page) } do def per(per = 10) limit(per) end end end Fart.per(20) # NoMethodError: undefined method `per' Fart.page(2).per(20).to_sql # => "SELECT "farts".* FROM "farts" WHERE "farts"."page" = 2 LIMIT 20" Kaminari does this: .page(...) adds .per(...) Monday, June 10, 13
  • 13. GROUP COUNT # Useless: Fart.group(:ass_id).count # => { 1 => 1, 2 => 1 } # Slow: Fart.group(:ass_id).count.keys.count # => 2 # Fast + should work for any query: scope = Fart.group(:ass_id).select("1") query = "SELECT count(*) AS count_all FROM (#{scope.to_sql}) x" ActiveRecord::Base.connection.execute(query)["count_all"].to_i # => 2 # Gem: mrbrdo/active_record_group_count Fart.group(:ass_id).returns_count_sum.count # => 2 # Works with Kaminari Fart.group(:ass_id).returns_count_sum.page(1).per(10) Monday, June 10, 13
  • 14. RAILS 3 ASSIGN_ATTRIBUTES WITHOUT PROTECTION PS: use strong_parameters (even in Rails 3), attr_accessible sucks Fart.new(name: 'lol') # ActiveModel::MassAssignmentSecurity::Error fart = Fart.new({ name: 'lol' }, without_protection: true) fart.update_attributes({ name: 'lol' }, without_protection: true) fart.assign_attributes({ name: 'lol' }, without_protection: true) be careful Monday, June 10, 13