Rails Crash Course: A No-Nonsense Guide to Rails Development

Rails Crash Course: A No-Nonsense Guide to Rails Development

Language: English

Pages: 296

ISBN: 1593275722

Format: PDF / Kindle (mobi) / ePub


Rails is a robust, flexible development platform that lets you build complex websites quickly. Major websites like GitHub, Hulu, and Twitter have run Rails under the hood, and if you know just enough HTML and CSS to be dangerous, Rails Crash Course will teach you to harness Rails for your own projects and create web applications that are fast, stable, and secure.

In Part I, you'll learn Ruby and Rails fundamentals and then dive straight into models, controllers, views, and deployment. As you work through the basics, you'll learn how to:

  • Craft persistent models with Active Record
  • Build view templates with Embedded Ruby
  • Use Git to roll back to previous versions of your code base
  • Deploy applications to Heroku

In Part II, you'll take your skills to the next level as you build a social networking app with more advanced Ruby tools, such as modules and metaprogramming, and advanced data modeling techniques within Rails's Active Record. You'll learn how to:

  • Implement an authentication system to identify authorized users
  • Write your own automated tests and refactor your code with confidence
  • Maximize performance with the asset pipeline and turbolinks
  • Secure your app against SQL injection and cross-site scripting
  • Set up a server and deploy applications with Capistrano

Each chapter is packed with hands-on examples and exercises to reinforce what you've learned. Whether you're completely new to Ruby or you've been mucking around for a bit, Rails Crash Course will take you from the basics to shipping your first Rails application, fast.

Social Media Mining with R

Genetic Programming Theory and Practice X (Genetic and Evolutionary Computation)

The C Programming Language (2nd Edition)

Classic Operating Systems: From Batch Processing to Distributed Systems

Modern Computer Algebra (3rd Edition)

 

 

 

 

 

 

 

 

 

 

Print its value.” Unlike an if statement, Ruby’s unless statement executes code when the expression evaluates to false. irb(main):057:0> name = "Tony" => "" irb(main):058:0> unless name.empty? irb(main):059:1> puts name irb(main):060:1> end => nil That still seems a little wordy to me. For one-line expressions such as this, Ruby lets you put the conditional at the end of the line: irb(main):061:0> name = "Tony" => "" irb(main):062:0> puts name unless name.empty? => nil This example is concise.

Created_at and updated_at are timestamps set for you by Rails. The body column is set to NULL since no value was passed for it. The create method is a shortcut for instantiating a new Post object, assigning values, and saving it to the database. If you don’t want to take the shortcut, you could also write a separate line of code for each action: 2.1.0 :002 > post = Post.new => # 2.1.0 :003 > post.title = "Second Post" => "Second Post" 2.1.0 :004 > post.save => true.

Is a client-server software architecture introduced in 2000 by Dr. Roy Fielding, one of the authors of the HTTP specification. REST deals with the representation of resources, and in Rails, resources correspond to models. In RESTful architectures, clients initiate requests to servers. Servers process those requests and return Routing Setting up all of these URLs and mapping actions to verbs might sound pretty complicated, but luckily, Rails routing handles all of this for you. Routes connect.

Destroy action in the CommentsController, similar to the destroy action for posts. Finally, add a link to this action at the bottom of app/ views/comments/_comment.html.erb: <%= link_to 'Destroy', [comment.post, comment], method: :delete, data: { confirm: 'Are you sure?' } %> 74   Chapter 5 6 De ploy me n t Now that you’ve built an application, let’s put it on the Web for everyone to see. Rails applications can be deployed in many ways. Rails runs on everything from simple shared hosting to.

The same email address. In your application, anonymous users are only allowed to see pages for logging in or signing up for a new account. Every other page should be restricted. Post Index and Show Before you start building the authentication system, you need data to protect from anonymous users. Let’s add the index and show pages for the Post models created in the last chapter. First, you need to add controller actions. Open the file app/controllers/posts_controller.rb in your editor and add.

Download sample

Download