The Ransack gem provides us with a powerful, flexible, easy-to-integrate search/filter form.
In your Gemfile, include
gem 'ransack'
Our apps are nothing more than a collection of URLs that we decide to allow users to access:
mydomain.com/products
mydomain.com/photos/193
mydomain.com/signin
So remember: everything always starts with a route between a URL we want to support and a Ruby method that will be responsible for generating a response to the user's browser.
The "print working directory" command:
Sign up for a Heroku account and install the toolbelt if you haven't already.
In your Gemfile, add
We're going to use GitHub for all of our code-sharing and submission.
All of our apps are just a folder with some files (maybe some HTML files, some CSS files, etc) and other folders in it. We call the top-level folder a "repository". You'll find the list of the repositories we'll work on during this course on the organization page (your course org is probably called something like appdevwinter2017
):
We will be using the [Devise gem][2] to help us get started with authentication (are you who you say you are?) and authorization (are you allowed to do/see this?).
gem 'devise'
to your Gemfile and bundle
rails g devise:install
Devise will give you some setup instructions. We don't need to worry about most of them, but we do need to set a root URL. Usually, you will point the root URL to the index action of some important resource in your application: In config/routes.rb
:
Here is a quick reference on how to insert, retrieve, update, and delete rows from your database tables using our ActiveRecord-backed Ruby classes.
First, we need a Ruby class to represent the real-world thing we're trying to model, and we need an underlying database table to store information about each individual thing.
Rails includes an easy generator to help us get set up with both of these things quickly. Supposed I wanted to create a table to store instructors, with two string columns first_name
and last_name
. I could use this shortcut from the Command Line: