This document provides instructions for migrating legacy Rails apps to Rails 3. It discusses updating the Rails version and dependencies using Bundler, upgrading plugins to gems, refactoring controllers to be RESTful, and addressing deprecation warnings. The rails_upgrade plugin helps analyze apps and generate a Gemfile to ease the upgrade process. Key steps include running checks and generating backups before upgrading code to Rails 3 features.
A year ago, I was a committed VPS and dedicated-machine deployer. I thought the cloud imposed silly restrictions - how dare you take away my shell account! Whaddya mean I can't save files locally? Since then, I've had some interesting experiences. I've worked on big cloud-deployed systems, and certain large traditionally-deployed systems, and I've seen how a lot of the decisions that you're ... encouraged to make when designing an app to run in the cloud. Most interestingly, I've discovered how those same decisions can make for a much better app regardless of where it'll end up. In this talk, I'll share those architectural patterns with you, and show why they work. Hopefully, I'll convince all of you to build cloud castles -- even if you've got your foundation firmly on the ground.
PECL Picks - Extensions to make your life betterZendCon
One of the biggest strengths of PHP is its "glue" power. Take any C library and with a little magic and a compiler you have a fantastic extension. These extensions hide in PECL, but few people can tell the good from the unmaintained or just plain broken. Find the best extensions for your project, learn about PECL, and find out how to become a part of the PECL developer community.
Cooking Perl with Chef: Real World Tutorial with JitterbugDavid Golden
This tutorial provides a command-by-command walk-through for deploying the Jitterbug continuous integration application using the Chef configuration management tool
"The road to Ember.js 2.0" by Lucio Grenzi
Why should I use Ember.js? JavaScript MVC frameworks are plentiful. In this presentation I will give you some compelling reasons to consider Ember,and the the new parts coming from the upcoming version 2.0. Different from other framework the new vesion does not brings a far new world because the dev team has planned continuos releases in order to improve backward compatibility. But there are new parts, like in React, the "virtual DOM" to improve performance. In this talk I will go through the new parts of EmberJS 2.0
A year ago, I was a committed VPS and dedicated-machine deployer. I thought the cloud imposed silly restrictions - how dare you take away my shell account! Whaddya mean I can't save files locally? Since then, I've had some interesting experiences. I've worked on big cloud-deployed systems, and certain large traditionally-deployed systems, and I've seen how a lot of the decisions that you're ... encouraged to make when designing an app to run in the cloud. Most interestingly, I've discovered how those same decisions can make for a much better app regardless of where it'll end up. In this talk, I'll share those architectural patterns with you, and show why they work. Hopefully, I'll convince all of you to build cloud castles -- even if you've got your foundation firmly on the ground.
PECL Picks - Extensions to make your life betterZendCon
One of the biggest strengths of PHP is its "glue" power. Take any C library and with a little magic and a compiler you have a fantastic extension. These extensions hide in PECL, but few people can tell the good from the unmaintained or just plain broken. Find the best extensions for your project, learn about PECL, and find out how to become a part of the PECL developer community.
Cooking Perl with Chef: Real World Tutorial with JitterbugDavid Golden
This tutorial provides a command-by-command walk-through for deploying the Jitterbug continuous integration application using the Chef configuration management tool
"The road to Ember.js 2.0" by Lucio Grenzi
Why should I use Ember.js? JavaScript MVC frameworks are plentiful. In this presentation I will give you some compelling reasons to consider Ember,and the the new parts coming from the upcoming version 2.0. Different from other framework the new vesion does not brings a far new world because the dev team has planned continuos releases in order to improve backward compatibility. But there are new parts, like in React, the "virtual DOM" to improve performance. In this talk I will go through the new parts of EmberJS 2.0
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017Ryan Weaver
What is Symfony *really*? It's a collection of *35* independent libraries, and
Drupal uses less than *half* of them! That means that there's a *ton* of other
good stuff that you can bring into your project to solve common problems... as
long as you know how, and what those components do!
In this talk, we'll have some fun: taking a tour of the Symfony components, how
to install them (into Drupal, or anywhere) and how to use some of my *favorite*,
lesser-known components. By the end, you'll have a better appreciation of what
Symfony *really* is, and some new tools to use immediately.
Symfony: Your Next Microframework (SymfonyCon 2015)Ryan Weaver
Microservices are a huge trend, and microframeworks are perfect for them: put together just a few files, write some code, and your done!
But Symfony is a big framework, right? Wrong! Symfony can be as small as a single file!
In this talk, we'll learn how to use Symfony as a micro-framework for your next project. Your app will stay small and clear, but without needing to give up the features or third-party bundles that you love. And if the project grows, it can evolve naturally into a full Symfony project.
So yes, Symfony can also be a microframework. Tell the world!
A quick overview of tips, tricks and code snippets for developers using Symfony and all its ecosystem, from Monolog to Doctrine. Learn how to become more productive and discover some rarely used options and features.
"Puppet at Pinterest", by Ryan Park, Operations Engineer at Pinterest. Talk from PuppetConf 2012.
Video of "Puppet at Pinterest": http://youtu.be/aU-bCbBq8zs
Learn more about Puppet: http://bit.ly/QQoAP1
Abstract: A case study of how Pinterest uses Puppet to manage its infrastructure. Pinterest has hundreds of Amazon EC2 virtual servers and uses Puppet Dashboard as the “source of truth” about its server inventory. Pinterest built a REST API for this database, which powers tools and automated scripts that integrate Puppet with internal systems and with Amazon Web Services.
Speaker Bio: Ryan Park leads operations and infrastructure at Pinterest, one of 2012’s fastest growing web sites. Pinterest’s entire infrastructure is in the cloud, built atop hundreds of Amazon EC2 virtual server instances. Ryan introduced Puppet to their infrastructure as soon as he joined the company, and they now use Puppet as the primary tool for managing their infrastructure. Prior to joining Pinterest, Ryan was the Head of Operations at PBworks, an online team collaboration service.
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017Ryan Weaver
What is Symfony *really*? It's a collection of *35* independent libraries, and
Drupal uses less than *half* of them! That means that there's a *ton* of other
good stuff that you can bring into your project to solve common problems... as
long as you know how, and what those components do!
In this talk, we'll have some fun: taking a tour of the Symfony components, how
to install them (into Drupal, or anywhere) and how to use some of my *favorite*,
lesser-known components. By the end, you'll have a better appreciation of what
Symfony *really* is, and some new tools to use immediately.
Symfony: Your Next Microframework (SymfonyCon 2015)Ryan Weaver
Microservices are a huge trend, and microframeworks are perfect for them: put together just a few files, write some code, and your done!
But Symfony is a big framework, right? Wrong! Symfony can be as small as a single file!
In this talk, we'll learn how to use Symfony as a micro-framework for your next project. Your app will stay small and clear, but without needing to give up the features or third-party bundles that you love. And if the project grows, it can evolve naturally into a full Symfony project.
So yes, Symfony can also be a microframework. Tell the world!
A quick overview of tips, tricks and code snippets for developers using Symfony and all its ecosystem, from Monolog to Doctrine. Learn how to become more productive and discover some rarely used options and features.
"Puppet at Pinterest", by Ryan Park, Operations Engineer at Pinterest. Talk from PuppetConf 2012.
Video of "Puppet at Pinterest": http://youtu.be/aU-bCbBq8zs
Learn more about Puppet: http://bit.ly/QQoAP1
Abstract: A case study of how Pinterest uses Puppet to manage its infrastructure. Pinterest has hundreds of Amazon EC2 virtual servers and uses Puppet Dashboard as the “source of truth” about its server inventory. Pinterest built a REST API for this database, which powers tools and automated scripts that integrate Puppet with internal systems and with Amazon Web Services.
Speaker Bio: Ryan Park leads operations and infrastructure at Pinterest, one of 2012’s fastest growing web sites. Pinterest’s entire infrastructure is in the cloud, built atop hundreds of Amazon EC2 virtual server instances. Ryan introduced Puppet to their infrastructure as soon as he joined the company, and they now use Puppet as the primary tool for managing their infrastructure. Prior to joining Pinterest, Ryan was the Head of Operations at PBworks, an online team collaboration service.
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Yevgeniy Brikman
This is a talk about managing your software and infrastructure-as-code that walks through a real-world example of deploying microservices on AWS using Docker, Terraform, and ECS.
Take a look at what Rails 5 has in store for you. We go through all the new features and improvements across development, testing, caching and much more. So let's dive in.
HTML 5 provides us with all sorts of new abilities as web designers. We have new tags and attributes, richer form fields, client-side storage, and more. We’ll talk about how you can start using these features today and how to use them in a cross-browser friendly manner.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
3. Top 10 reasons to upgrade
10. The new ARel syntax is sweet.
9. You can use jQuery.
8. Bundler is fun!
7. Easier to hire new developers.
6. Get ready for Rails 4.
4. Top 10 reasons to upgrade
5. Way faster than Rails 2.*
4. ActiveModel lets you treat everything like
ActiveRecord.
3. You don’t have to use ActiveRecord.
2. Cut your controllers down to size with
respond_to.
1. You don’t have to get up for a 9 AM tutorial.
6. “How do I figure out which new Rails 3
features are worth upgrading to (above
and beyond the minimum to attain
compatibility)? Maybe none and I should
just start using them as I write new code.”
7. Rails 2.3.11
Remember to run rake rails:update.
Getting rid of all deprecations should get
you ready for Rails 3.
Install rails_xss plugin and fix views.
And if you still have .rhtml, .rxml,
and .rjs files, rename them.
8. RailsXSS
Safe strings are copied into the output,
unsafe strings are escaped
Strings are not safe by default
String interpolation always makes strings not safe
Built-in helpers emit safe strings
.html_safe marks strings as safe
raw copies strings verbatim
No need for h any more
9. module ApplicationHelper
def clippy(text, bgcolor='#FFFFFF')
html = <<-‐EOF
<object classid="clsid:d27cdb6e-‐ae6d-‐11cf-‐96b8"
id="clippy" >
<param name="movie" value="/clippy.swf"/>
<param NAME="FlashVars" value="text=#{text}">
<param name="bgcolor" value="#{bgcolor}">
<embed src="/clippy.swf"
name="clippy"
FlashVars="text=#{text}"
bgcolor="#{bgcolor}"
/>
</object>
EOF
end
end
Not safe
11. Localization
If you have HTML in your YAML locale
files (config/locales/), make sure all
keys pointing to HTML end in _html.
Rails 3 will auto-escape these values
otherwise.
12. fake_arel
Hat tip to Grant Ammons
https://github.com/gammons/fake_arel
Uses named scopes and a few patches
to give you the new ARel syntax
Not really “fake”: actually lazily loaded
14. RESTful Controllers
Now is a great time to refactor your
controllers to be RESTful.
The new routes syntax in Rails 3 works
great with RESTful controllers.
15. Other improvements
Use YAJL for JSON processing if
installed: gem install yajl-‐ruby
Flash: alert and notice promoted
Object#presence: returns the object
if it’s #present? otherwise returns
nil.
16. flash[:notice] = 'Post was created'
redirect_to(@post)
# becomes:
redirect_to(@post, :notice => 'Post was created')
class ActionController::Base
# Convenience accessor for flash[:alert]
def alert
flash[:alert]
end
# Convenience accessor for flash[:alert]=
def alert=(message)
flash[:alert] = message
end
end
17. def display_name
if name.present?
name
elsif login.present?
login
else
"Anonymous user"
end
end
# OR
def display_name
name.present? ? name :
(login.present? ? login : "Anonymous user")
end
# becomes:
def display_name
name.presence || login
end
18. Other improvements
Object#returning is removed in Rails 3.
Change your code to use Object#tap.
Putting non-ActiveRecord fixtures in
test/fixtures/ will break in Rails 3.
Move those out of there.
19. returning([]) do |guitarists|
guitarists << "Eddie Van Halen"
guitarists << "Buzz Osborne"
guitarists << "Vernon Reid"
end
[].tap do |guitarists|
guitarists << "Eddie Van Halen"
guitarists << "Buzz Osborne"
guitarists << "Vernon Reid"
end
# => ["Eddie Van Halen", "Buzz Osborne",
"Vernon Reid"]
20. # Another cool trick with .tap
@guitars = Musicians.where(instrument: 'guitar')
.map { |dude| dude.instrument_name }
.uniq
## Me debugging this normally
musicians = Musicians.where(instrument: 'guitar')
p musicians
all_names = musicians.map { |dude| dude.instrument_name }
p all_names
@guitars = all_names.uniq
## The power of .tap
@guitars = Musicians.where(instrument: 'guitar')
.tap { |ms| p ms.all }
.map { |dude| dude.instrument_name }
.tap { |names| p names }
.uniq
22. Bundler: not that scary
Bundler was a little shaky at first, but is
rock-solid now.
Worth doing before an upgrade to
Rails 3.
Auto-generate your initial Gemfile
using the rails_upgrade plugin and
rake rails:upgrade:gems
23. Can specify
source 'http://rubygems.org'
versions
gem 'rails', '2.3.11'
gem 'pg'
gem 'domainatrix'
group :development, :test do
gem 'rspec-‐rails', '< 2.0' Assign gems to
end
groups
group :development do
gem 'query_reviewer',
:git => 'git://github.com/nesquena/query_reviewer.git'
end
group :test do
gem 'capybara'
end Get gem from VCS
24. Using Bundler effectively
Install gems locally instead of into
system location:
bundle install -‐-‐path vendor
Package gems:
bundle package
Check your Gemfile.lock into
version control
25. alias be='bundle exec'
alias bi='bundle install -‐-‐path vendor'
alias bp='bundle package'
alias bu='bundle update'
alias binit='bi && bp &&
echo "vendor/ruby" >> .gitignore'
26. Plugins & gems
Many popular plugins are now released
in gem form.
Replace plugins with gems so that
Bundler can manage them and
upgrading is easier.
If you’ve edited code in vendor/
plugins, put your version into VCS
and pull in Gemfile.
28. rails_upgrade
Written by Jeremy McAnally,
maintained by Rails Core
script/plugin install git://github.com/
rails/rails_upgrade.git
or
rails plugin install git://github.com/
rails/rails_upgrade.git
30. > rake rails:upgrade:check
Old router API
The router API has totally changed.
More information: http://yehudakatz.com/2009/12/26/the-‐
rails-‐3-‐router-‐rack-‐it-‐up/
The culprits:
-‐ config/routes.rb
Deprecated constant(s)
Constants like RAILS_ENV, RAILS_ROOT, and
RAILS_DEFAULT_LOGGER are now deprecated.
More information: http://litanyagainstfear.com/blog/
2010/02/03/the-‐rails-‐module/
The culprits:
-‐ lib/tasks/rspec.rake
-‐ app/models/link.rb
31. rake rails:upgrade:backup
Copies all files likely to be overwritten
and adds a .rails2 extension.
Not that necessary, given the use of a
good VCS.
32. > rake rails:upgrade:backup
* backing up .gitignore to .gitignore.rails2
* backing up app/controllers/application_controller.rb to app/
controllers/application_controller.rb.rails2
* backing up app/helpers/application_helper.rb to app/helpers/
application_helper.rb.rails2
* backing up config/routes.rb to config/routes.rb.rails2
* backing up config/environment.rb to config/environment.rb.rails2
* backing up config/environments/development.rb to config/environments/
development.rb.rails2
* backing up config/environments/production.rb to config/environments/
production.rb.rails2
* backing up config/database.yml to config/database.yml.rails2
* backing up doc/README_FOR_APP to doc/README_FOR_APP.rails2
* backing up test/test_helper.rb to test/test_helper.rb.rails2
This is a list of the files analyzed and backed up (if they existed);
you will probably not want the generator to replace them since
you probably modified them (but now they're safe if you accidentally
do!).
33. rake rails:upgrade:gems
Checks config/environment.rb for
config.gem lines and then spits out a
Gemfile.
Doesn’t check config/environments/*.rb
files.
35. rake rails:upgrade:routes
Automatically converts all old-style
routes to Rails 3-style routes.
Old syntax deprecated, but works for
now in Rails 3.
Not perfect.
37. # Output from rake rails:upgrade:routes
Rubyurl::Application.routes.draw do
match '' => 'links#index' should be
root :to => 'links#index'
match 'rubyurl/remote' => 'links#create'
match 'about' => 'links#about'
match 'api' => 'links#api'
match 'report-‐abuse' => 'links#report'
match 'home' => 'links#home'
resources :links new optional route
segments cause a problem
match '/:controller(/:action(/:id))'
match ':token' => 'links#redirect'
end
40. Generate a new Rails app
Run “rails new . -‐d <database>”.
Will prompt you about overwriting files.
This is where a good VCS comes in handy.
41. > rails new . -‐d sqlite3
conflict README
Overwrite README? (enter "h" for help) [Ynaqdh] y
force README
conflict Rakefile
Overwrite Rakefile? (enter "h" for help) [Ynaqdh] y
force Rakefile
create config.ru
conflict .gitignore
Overwrite .gitignore? (enter "h" for help) [Ynaqdh] y
force .gitignore
create Gemfile
exist app
conflict app/controllers/application_controller.rb
Overwrite app/controllers/application_controller.rb?
(enter "h" for help) [Ynaqdh] y
42. > git add -‐-‐patch
diff -‐-‐git a/app/controllers/application_controller.rb
b/app/controllers/application_controller.rb
index dd5e2ff..e8065d9 100644
-‐-‐-‐ a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -‐1,11 +1,3 @@
class ApplicationController < ActionController::Base
-‐ before_filter :calculate_links
-‐
-‐ # refactor to some sort of cache tool
-‐ def calculate_links
-‐ @cached_data = {:link_count => Link.count}
-‐ end
+ protect_from_forgery
end
Stage this hunk [y,n,q,a,d,/,s,e,?]?
43. git add --patch
Prompts you interactively about each
change.
Choose ‘s’ for split to break up changes.
For finer control, use “git add -‐-‐edit”.
44. Immediate fixes
Remove preinitializer.rb if you were
using Bundler before.
lib/ directory not autoloaded by default:
config.load_paths += %W(#{config.root}/lib)
45. JavaScript fixes
Rails 3 has moved to unobtrusive JS.
To make everything work, call
javascript_include_tag :defaults
in view.
Add csrf_meta_tag inside <head>.
46. Removed in Rails 3: Replaced:
button_to_remote link_to_remote
submit_to_remote form_remote_tag
observe_field form_remote_for
observe_form remote_form_for
periodically_call_remote
To get these back:
gem 'prototype_legacy_helper', :git =>
'git://github.com/rails/prototype_legacy_helper.git'
48. More form fixes
Gone:
error_messages_for :model
form.error_messages
input('model', 'field')
form('model')
Install dynamic_form gem to get them back.
Or, use simple_form and be happy.
49. RAILS_*
RAILS_* constants are deprecated in
favor of a Rails module.
RAILS_ENV -‐> Rails.env
RAILS_ROOT -‐> Rails.root
There’s a lot of cool things you can do
with the new Rails module.
50. ActiveRecord
named_scope is now scope.
ActiveRecord::Errors now has an
array-like syntax instead of .on.
Whole new query syntax.
52. View deprecations
All helpers that emit text, even ones
that take blocks use <%= now.
53. <%= form_for @link, :url => links_url do |f| %>
<label for="link_website_url">
Create a RubyURL
</label>
<%= f.text_field :website_url %>
<%= submit_tag 'Go!', :class => 'go' -‐%>
<% end %>
54. Mailers
Mailers have a completely new syntax
and a new place to live: app/mailers/.
The old syntax works, but is deprecated.
Mailers now based off ActionController,
which lets you do some neat stuff.
55. # Rails 2
class UserMailer < ActionMailer::Base
def password_reset(user)
recipients user.email
from "info@spkrtown.com"
subject "Password Reset Instructions"
body :user => user
end
end
# Rails 3
class UserMailer < ActionMailer::Base
default :from => "info@spkrtown.com"
def password_reset(user)
@user = user
mail(:to => user.email,
:subject => "Password Reset Instructions")
end
end
56. # Multipart emails
class UserMailer < ActionMailer::Base
default :from => "info@spkrtown.com"
def password_reset(user)
@user = user
attachments['sorry.pdf'] = File.read('/path/sorry.pdf')
mail(:to => user.email,
:subject => "Password Reset Instructions") do |format|
format.html { render 'password_reset' }
format.text { render 'password_reset' }
end
end
end
59. RSpec
Instead of
require 'spec'
require 'spec/rails'
use
require 'rspec'
require 'rspec/rails'
You also need to upgrade to rspec 2.
60. RSpec - spec_helper.rb
Old configuration:
Spec::Runner.configure do |config|
# ...
end
New configuration:
RSpec.configure do |config|
# ...
end
61. RSpec
Two other changes to make:
Make sure rspec-‐rails is in the
development and test groups in your
Gemfile.
Cucumber no longer uses its own
environment - uses test instead.
62. RSpec view matchers
If you use view matchers in RSpec:
it "should display Here you go in a h1 tag" do
rendered.should have_tag('dt', :text => 'Here you go')
end
then you need to install
rspec2-‐rails-‐views-‐matchers.
64. will_paginate
There is a rails3 branch of
will_paginate on GitHub.
A good replacement: kaminari.
65. Searchlogic
Searchlogic is busted with Rails 3.
But you don’t need it!
New ARel syntax gets you part of the
way.
MetaSearch is a gem that can do
everything Searchlogic can and has
similar syntax.
67. / Same syntax for Searchlogic and MetaSearch
= form_for @search do |f|
= f.label :name_like, 'Name'
= f.text_field :title_like, :size => 15
= f.submit "Search"
= "#{@search.count} matches"
68. Authlogic
Authlogic 3 is compatible with Rails 3.
Many people recommend Devise.
Check it out.
69. AttachmentFu
Bad news: doesn’t work easily.
There are some instructions out there
you can try.
Paperclip is one option.
CarrierWave is a more radical option.