RailsConf 2013

Rails for Zombies: Parts 1 & 2

Workshop with Christopher Greene & Aimee Simone

Help us caption & translate this video!

http://amara.org/v/FGa2/

RailsConf 2013

00:00:16.070 in order for this video to make sense
00:00:17.780 you're gonna need to know a little bit
00:00:19.160 about the Ruby language if you don't
00:00:21.200 know anything yet
00:00:21.950 pause this video go to try Ruby org go
00:00:24.950 through that tutorial and then come back
00:00:26.570 and start the video so in this first
00:00:29.390 episode we're going to be deep in the
00:00:32.000 crud we're gonna be talking about crud
00:00:33.920 now bear with me if you're an expert in
00:00:36.320 you know some of these languages and
00:00:37.879 some of these concepts um we'll get to
00:00:39.620 the advanced stuff soon enough but we
00:00:41.090 need to make sure everyone's on the same
00:00:42.260 page so we're gonna be creating Twitter
00:00:45.739 for zombies that's our application if
00:00:48.470 you don't know why go back to the front
00:00:50.210 page and watch the intro but let's jump
00:00:51.860 into it for now so here we have our
00:00:56.210 first database table kind of looks like
00:00:58.970 a spreadsheet we're calling it tweets it
00:01:01.670 has four rows and it has three columns
00:01:06.610 now we might put a label on each of
00:01:09.020 these columns the first one is the ID
00:01:10.840 the second one is status and the third
00:01:14.240 one represents the zombie like Ash Bob
00:01:17.510 Jim these are our zombies now our first
00:01:21.290 zombie challenge is going to be to
00:01:23.090 retrieve a hash of the tweet with ID
00:01:25.130 equals three now I'm not going to show
00:01:27.500 you the solution what I'm going to show
00:01:29.210 you first is the result what we want to
00:01:31.850 get back from the database in this case
00:01:33.560 we want to get back to hash which looks
00:01:35.720 like this now you should be familiar
00:01:40.010 with what a hash is but here's a small
00:01:42.050 recap so if we do puts B status we're
00:01:45.200 going to get back I just ate some
00:01:46.460 delicious brains if we do puts B zombie
00:01:49.340 we're gonna get back Jim and if we do
00:01:51.500 this at the bottom we're gonna get back
00:01:53.180 Jim said I ate some delicious brains
00:01:55.730 because you know zombies love eating the
00:01:59.060 brains now let's get back to our
00:02:02.450 database table and our challenge so
00:02:06.050 there's our challenge again now I'm
00:02:07.580 going to show you the actual solution
00:02:09.560 the code that we want to write we want
00:02:11.659 to write T equals tweet dot find three
00:02:14.480 so what that's gonna do is get us back
00:02:16.909 that hash and we can then do put CID
00:02:19.489 gets us three puts T status gets I just
00:02:22.700 ate some delicious brains and puts T
00:02:25.519 zombie gets us back Jim now there's
00:02:28.579 another way we can
00:02:29.630 right this in rails instead of puts tid
00:02:33.440 we can do put sticky dot ID put ste
00:02:37.010 status we can have puts T dot status and
00:02:40.090 so on and so forth so we can use these
00:02:43.130 to find our solution instead of using
00:02:45.140 the hash keys here's what our answer
00:02:47.840 might look like with those pieces of
00:02:49.220 code there's one rails convention here
00:02:51.440 that I want you to notice notice we have
00:02:53.990 capital T in tweets in the code solution
00:02:57.230 and what's happening on the back end
00:02:59.150 here is that it's going to lower case
00:03:00.800 that PluralEyes it and then it's looking
00:03:02.960 for a table called tweets in our
00:03:05.390 database it's time to jump in to the
00:03:09.740 crud and by crud I mean create read
00:03:13.010 update and delete now let's figure out
00:03:16.370 how we can do each of these inside our
00:03:18.470 rails application first in the create we
00:03:21.950 do tweet new we can then set the status
00:03:24.830 and call T Save to save the item for
00:03:28.250 reading we then do tweet dot find three
00:03:31.220 just like you saw a moment ago for
00:03:33.410 updating we're going to find the tweet
00:03:34.970 then we can set values on it and save it
00:03:38.660 and then for delete we can find the
00:03:41.540 tweet and call T dot destroy to delete
00:03:44.270 it out of the database now we're going
00:03:46.310 to go through each of these in a little
00:03:47.690 bit more detail and I'm going to show
00:03:49.160 you some alternate syntaxes but first
00:03:51.410 with create notice that we're not
00:03:52.970 setting the ID on the object here
00:03:55.820 that's because rails is going to take
00:03:57.500 care of that for us and properly
00:03:59.180 increment the ID and soar that in the
00:04:01.430 database another way we can create a new
00:04:03.709 tweet is simply by sending in a hash of
00:04:06.650 the items that we want to set we can
00:04:09.500 then save that we can also write this
00:04:12.230 all in one line by calling tweet create
00:04:14.630 so that's going to set these attributes
00:04:17.359 and save the object next up for reading
00:04:22.880 there's lots of ways we can read data
00:04:24.710 out of the database we can find a
00:04:26.870 particular item with an ID number we can
00:04:29.270 find a bunch of items and it will return
00:04:31.370 an array we can find the first one we
00:04:34.160 can find the last one we can find all of
00:04:36.710 them we can count them and the
00:04:38.870 interesting thing about count here is
00:04:40.520 that it's actually doing this the
00:04:41.930 correct way it's not going to the
00:04:43.130 database
00:04:43.550 pulling everything out and then counting
00:04:45.470 it it's actually going to be doing a
00:04:47.030 count query on the database and
00:04:48.710 returning that number we can also get
00:04:50.390 all the zombies and order them by the
00:04:52.100 zombie name we can limit the number to
00:04:54.470 ten we can say get us all a zombies
00:04:56.540 where the zombie name equals ash or we
00:04:59.090 can put all these different methods
00:05:00.140 together to do something we like to call
00:05:02.050 method chaining next up we have update
00:05:06.290 so remember with update we find the
00:05:08.300 tweet we set something and then we save
00:05:09.860 it alternatively we can set the
00:05:12.380 atributes value and send it in a hash
00:05:14.840 and then save it we can also call T dot
00:05:18.530 update attributes which not only will
00:05:20.570 set the items but it will also save it
00:05:24.280 next up is destroyed because zombies
00:05:26.990 like destroying things especially brains
00:05:29.170 so as you saw before we can find an item
00:05:31.940 and destroy it we can also write this on
00:05:34.550 a single line and lastly if you want to
00:05:38.600 destroy all the tweets we can just call
00:05:40.790 tweet dot destroy all so we've already
00:05:44.780 reached zombie lab 1 this is where you
00:05:46.400 get to start coding and implement some
00:05:48.350 of the stuff we've already learned so go
00:05:50.330 and have some fun with your new zombie
00:05:51.950 friends
00:06:14.620 welcome to rails for zombies - level 1
00:06:17.570 in this episode we're gonna be going
00:06:19.400 over some of the things we left out in
00:06:21.200 the first set of rails for zombies
00:06:22.370 videos covering things like creating a
00:06:24.620 rails app the command line database
00:06:26.480 migrations the Ruby 1/9 of bundler and
00:06:30.680 database configuration if you haven't
00:06:32.900 yet I highly recommend you get rails
00:06:34.430 installed in your laptop or in your
00:06:36.590 computer whatever you're using so that
00:06:38.510 you can run some commands and follow
00:06:39.980 along as we teach them
00:06:43.230 I'm not going to go into the
00:06:45.100 nitty-gritty details of installing rails
00:06:46.780 on every platform I'm just gonna mention
00:06:49.120 that if you're on Windows and you don't
00:06:50.770 have it installed yet head over to rails
00:06:52.480 install org there's instructions there a
00:06:54.370 downloader you'll be up and running in
00:06:55.720 no time if however you're running OS 10
00:06:58.450 or Linux I highly recommend going over
00:07:01.180 to rails tutorial org and just going
00:07:03.970 through the first chapter it'll get
00:07:05.710 everything installed for you you'll even
00:07:07.540 get an application deployed on Heroku so
00:07:11.680 once you have rails installed if you run
00:07:13.300 rails from any particular directory
00:07:15.490 that's not a rails app it's gonna give
00:07:17.560 you the syntax on how to create any
00:07:19.420 rails app with a bunch of different
00:07:20.800 options you can skip active record
00:07:22.900 specify what database you want to use
00:07:24.730 specify what JavaScript framework you
00:07:26.770 want to use a couple runtime options and
00:07:29.050 then finally we'll give you an example
00:07:30.310 of how to create the rails app
00:07:33.340 let's go ahead and create our first
00:07:34.750 rails out by running rails new Twitter
00:07:37.660 for zombies when we run that command
00:07:39.640 it's going to create a bunch of files
00:07:41.830 for us and a bunch of directories some
00:07:45.070 of these directories should look
00:07:46.000 familiar from rails for zombies one like
00:07:47.860 your controllers models and views
00:07:49.600 directory at the end that's going to run
00:07:51.940 bundle install what bundle install is
00:07:54.400 going to do is go out to the internet
00:07:56.020 and download any external dependencies
00:07:58.180 that your rails application depends on
00:08:00.130 you don't need to worry about this too
00:08:02.020 much we'll come back around and talk
00:08:03.310 about bundler later so we've created our
00:08:07.690 rails app now let's jump into the
00:08:09.130 directory so we're going to CD into the
00:08:10.720 directory and if we run rails from
00:08:12.700 inside the directory we're going to be
00:08:14.710 given a list of commands that we can run
00:08:16.240 on a rails app starting with the
00:08:18.160 generate command to generates a new code
00:08:19.930 the console command which we will use to
00:08:22.030 debug a little bit later the server
00:08:24.130 command of course to start our local
00:08:25.750 development server and the DB console
00:08:28.030 command to jump into a console for our
00:08:29.740 database if we want more information
00:08:31.660 about any of these commands we can run
00:08:33.820 them with the dash H option but first
00:08:36.850 things first let's get our development
00:08:38.410 server running so we're gonna run rails
00:08:40.480 server it's gonna give us some output
00:08:43.030 and if we go to localhost 3000 in a
00:08:45.250 browser we're gonna get the welcome to
00:08:47.140 rails screen we can also run rails
00:08:49.810 server H for more options like if we
00:08:51.700 wanted to run the server on a different
00:08:53.020 port the shortcut for this command which
00:08:55.480 we'll probably be running more often is
00:08:56.920 just rails s next up let's take a closer
00:09:02.890 look at the rails generate command if we
00:09:04.870 run it without any options we're given a
00:09:06.850 list of generators which we can use to
00:09:08.800 generate some source for our rails app
00:09:10.630 the shortcut for generate as rails G and
00:09:13.360 let's go ahead and use that to generate
00:09:14.740 a scaffold so a scaffold if you're not
00:09:17.650 familiar is the basic building block for
00:09:19.840 most of our rails apps we specify a
00:09:21.970 resource and it builds us a view to list
00:09:24.850 out the items edit the items create new
00:09:27.040 items and delete the items so here's the
00:09:30.070 syntax
00:09:31.910 and we're gonna go ahead and create
00:09:33.840 rails G scaffold the zombie because we
00:09:36.600 want to create zombies we're gonna give
00:09:38.400 it a name which is a string a bio which
00:09:41.370 is a text type and an age which is an
00:09:44.280 integer
00:09:45.200 when I say types I'm referring to
00:09:47.430 database types and here's a list of all
00:09:50.190 the other database types which we might
00:09:51.540 find useful here when we generate a
00:09:54.510 scaffold it's going to create a bunch of
00:09:56.310 files for us let's take a look at a few
00:09:58.410 you can see here it's generating a
00:10:00.120 migration for us the zombie model it's
00:10:03.390 gonna add resources Amba to our routes
00:10:05.190 dot RB it's gonna create our zombies
00:10:08.550 controller it's also going to create our
00:10:11.340 views which should look familiar from
00:10:12.870 rails for zombies 1 you have our index
00:10:15.270 view edit show and new there are a
00:10:19.380 couple other files that's going to
00:10:20.370 create like helpers tests and assets and
00:10:22.650 we'll see some of those later but first
00:10:24.420 let's jump in and take a closer look at
00:10:26.130 that migration when we say migration
00:10:30.270 what we're talking about our database
00:10:32.190 migrations this is how we make changes
00:10:34.290 to our database from inside rails and if
00:10:37.350 you remember from rails for zombies 1
00:10:38.790 where else is going to automatically
00:10:40.260 create for us a primary key called ID it
00:10:43.590 doesn't even show that the migration
00:10:45.060 it's just sort of assumed that every
00:10:46.800 table is gonna have a primary key of ID
00:10:48.630 the last thing you'll see in this
00:10:50.130 migration is this T dot timestamps this
00:10:53.520 T dot I of stamps line is the same as
00:10:55.620 saying date/time created at and
00:10:57.750 date/time updated app these are magical
00:11:00.450 fields and rails they get populated for
00:11:02.370 you automatically and you can use them
00:11:03.810 in your views when a model is created
00:11:05.400 the Creator that gets set and every time
00:11:07.470 it's updated that updated gets set for
00:11:09.420 you
00:11:11.000 to give you a better idea why migrations
00:11:12.890 are so useful here's a commercial I
00:11:14.900 created back in my rails Envy days hi
00:11:17.720 I'm Ruby on ramp and that PHP what you
00:11:20.360 got there oh these are a bunch of sequel
00:11:22.220 files all the developers on the team set
00:11:24.020 out and I'm really frustrated because
00:11:27.230 they just overall my database changes it
00:11:31.220 sucks yeah you feel my pain right
00:11:33.110 well actually Ruby on Rails uses
00:11:35.270 something called migrations this allows
00:11:37.340 developers to make database changes
00:11:39.050 independently without stepping on
00:11:40.970 anybody's toes you still have to write
00:11:42.650 tons of sequel though right
00:11:43.910 well no migrations actually use Ruby
00:11:47.480 so it's database independent wow that
00:11:50.300 sounds really good I think I'll give
00:11:51.620 that a try actually you know what on my
00:11:53.900 way home from work tonight
00:11:54.830 I'll stop by Toys R Us and pick one of
00:11:56.570 those up while I'm there I'll get Barbie
00:12:00.560 to give me a ride in her pink Cadillac
00:12:01.930 all the way your offices in the land of
00:12:04.580 make-believe where you can help us
00:12:06.350 finish up my application and we'll all
00:12:07.760 live happily ever after
00:12:10.060 so database migrations are how we
00:12:12.500 version our database keep track of
00:12:15.140 changes so we don't have to send around
00:12:16.790 sequel scripts and end up stepping on
00:12:18.860 each other's toes so back in our rails
00:12:21.320 app we have this migration if we start
00:12:24.110 up the server at this point uh-oh we're
00:12:26.480 gonna get an error it's not gonna work
00:12:28.310 it gives us an error it gives us the
00:12:30.260 line of code where there's an error if
00:12:31.760 we looked at that line of code we would
00:12:32.990 see zombies equal zombie all OH
00:12:36.440 so it's according for the zombies table
00:12:38.240 but it's not yet in the database ah well
00:12:40.970 we forgot to run that migration file to
00:12:43.730 run migration files we run rake DB
00:12:46.220 migrate not only is that going to run
00:12:48.380 our current migration but if there's any
00:12:50.180 other migrations that other people in
00:12:51.890 our project committed it's also going to
00:12:53.780 run all of those here's the output we
00:12:56.060 would see from our migration and if we
00:12:57.650 run our rail server again now if we go
00:12:59.780 to slash zombies we can get a list of
00:13:01.700 the zombies and start creating them
00:13:05.670 now that we have a zombie table and a
00:13:07.960 zombie model let's jump into the console
00:13:10.240 and play around with it
00:13:11.350 so we use the console of debug our
00:13:13.390 application so we can go in here and
00:13:14.920 just start running rails commands so
00:13:17.020 here you can see I'm running zombie
00:13:18.430 create named Eric alum age 27 that's
00:13:23.170 gonna actually show us the sequel that's
00:13:24.790 going to be running inside of our rails
00:13:26.110 app and it's gonna give us back the
00:13:27.700 zombie object to create it now remember
00:13:30.070 when you use try Ruby org everything in
00:13:32.740 Ruby has a return value that's that hash
00:13:35.650 rocket symbol you see right up there you
00:13:37.420 can see that this command returns an
00:13:39.430 instance of the zombie we can then run
00:13:41.950 zombie first to get back the first
00:13:43.390 zombie which in case is the zombie we
00:13:45.070 just created we can change the name of
00:13:47.920 the zombie and then finally we can save
00:13:50.230 the zombie is going to show us the
00:13:51.430 sequel that it uses to do that and it's
00:13:53.470 going to return true because it's
00:13:55.090 successfully saved the zombie
00:13:59.710 now you may have noticed when we created
00:14:02.330 this zombie Eric here that we used a
00:14:04.460 slightly different syntax we actually
00:14:07.670 used a different hash syntax remember a
00:14:09.740 hash is a collection of key value pairs
00:14:12.140 and a key can be almost anything a key
00:14:15.560 can be a string here's the old syntax
00:14:17.780 with a hash rocket the key can be a
00:14:20.090 number a key can more commonly be a
00:14:23.960 symbol you'll notice all of these
00:14:25.880 different syntax as I showed you here
00:14:27.230 are compatible with both Ruby 1 8 and 1
00:14:29.540 9 and if we're using a ruby 1-9 this
00:14:32.120 last hash can also be written as named :
00:14:36.560 it's a little bit of a shorter syntax
00:14:38.870 two less characters and throughout this
00:14:41.210 entire tutorial we're going to be using
00:14:42.920 this new ruby 119 tax if you're just
00:14:45.500 getting into Rails now you should be
00:14:47.360 using Ruby 1/9 don't even bother through
00:14:49.430 b18 just use ruby 1/9 and then you'll
00:14:52.190 get access to this hash syntax you see
00:14:54.110 here as well
00:14:56.650 so here again is the code to create
00:14:58.760 zombie Eric using the Ruby 119 tax and
00:15:02.810 here it is using the Ruby 1:8 syntax but
00:15:06.380 really it's not Ruby 1:8 syntax you can
00:15:09.050 still use the same syntax this is sort
00:15:11.660 of old hash syntax in either Ruby 1 8 or
00:15:14.600 1 9 it's up to you which one you like
00:15:16.640 better you can use either but in this
00:15:19.160 tutorial like I said we're going to use
00:15:20.810 the new way if you take a look inside
00:15:23.330 the controller that the scaffolding
00:15:24.770 created for us you can see that in the
00:15:26.960 respond to block over here it says
00:15:29.240 render JSON zombies that's using the
00:15:32.900 Ruby 119 tags and it does the same thing
00:15:36.530 as the old syntax so we have our zombie
00:15:42.050 table but we want to make some changes
00:15:44.000 to the database how do we do that well
00:15:46.250 we do that by generating a migration
00:15:48.710 we're gonna call our migration add email
00:15:51.440 and rotting to zombies we're gonna
00:15:54.110 specify the columns we want to add in
00:15:55.730 this case the email column which is a
00:15:57.589 string and rotting which is a boolean
00:15:59.570 when we want to add a migration that
00:16:01.550 adds columns we can use this title
00:16:04.100 format and it'll write all the code for
00:16:05.870 us so we say add anything too and then
00:16:08.570 the table name we have our column names
00:16:11.270 and our types and that's going to
00:16:13.100 generate a migration for us which looks
00:16:15.680 a little bit like this as you can see
00:16:18.230 here it's adding two columns to our
00:16:19.520 zombie's table an email column and a
00:16:21.950 writing column but what happens when we
00:16:24.050 want to add some table options some
00:16:25.850 column options for a default we can just
00:16:28.370 write default false a couple other
00:16:30.950 migration options here besides default
00:16:32.870 we can also add a limit specify that it
00:16:35.720 can or can't be null we can specify
00:16:37.370 which position and the table to put the
00:16:39.470 column as well as add a unique
00:16:41.240 constraint to ensure that this column is
00:16:43.250 always unique at the database level now
00:16:47.270 that we have a migration we need to run
00:16:48.890 rake DB migrate to add those columns to
00:16:51.920 our database rick DB migrate is not only
00:16:54.470 going to run our new migration but if i
00:16:57.140 checked out somebody else's migrations
00:16:59.240 it's going to run those to some other
00:17:01.760 rate commands you need to be familiar
00:17:02.810 with start with rake DB rollback
00:17:05.959 what rake DB rollback is going to do is
00:17:07.820 look at our most recent migration and
00:17:10.060 undo it at the database level it's going
00:17:13.250 to roll it back this can be really
00:17:15.620 useful if let's say I haven't committed
00:17:17.600 my migration yet and I want to make some
00:17:19.850 changes and then migrate again it also
00:17:22.670 is really useful when you think about
00:17:23.990 deployment if I deploy my application I
00:17:26.570 run the migration and whoops I didn't
00:17:28.940 want to run that something went wrong I
00:17:30.710 can quickly type rake DB rollback that
00:17:33.560 will roll back the migration and I can
00:17:35.240 make any changes that I need to from
00:17:36.530 there another useful rate command is
00:17:39.050 rake DB schema dump and this gets run
00:17:41.810 automatically every time we run rake DB
00:17:43.760 migrate see after you have a rails app
00:17:46.970 that's lived for three or four years you
00:17:50.060 have a law end up with a lot of
00:17:51.230 migrations I mean like you know over a
00:17:52.970 hundred migrations and it's unrealistic
00:17:54.710 for somebody new who checks out your
00:17:57.110 rails app you know a new developer to
00:17:59.000 have to run all those migrations what
00:18:00.860 you find is that migrations start to get
00:18:02.510 brittle after a while this is why we
00:18:04.820 have a schema 2rb and it looks something
00:18:06.440 like this
00:18:09.150 as you can see here it has our entire
00:18:11.380 database structure so the next time you
00:18:13.750 check out somebody's rails app and you
00:18:15.340 need to get up and running and create
00:18:16.570 the database what you're gonna run is
00:18:18.610 rake DB setup that's going to create the
00:18:21.760 database if it doesn't exist yet it's
00:18:23.950 going to run the schema and create the
00:18:26.140 database using that schema file and then
00:18:28.870 it's gonna run any C data which you need
00:18:31.030 in there so we know how to add columns
00:18:35.500 to our database but how do we remove
00:18:37.300 them well let's go ahead and generate
00:18:39.190 another migration for that we'll call it
00:18:41.440 remove age from zombies the column we
00:18:44.710 want to remove is the age column which
00:18:46.630 is an integer and we are using another
00:18:48.970 pattern here with the migration name
00:18:51.250 remove something from table name that's
00:18:55.330 going to generate a migration for us
00:18:56.920 it's gonna obviously have the remove
00:18:59.320 column command but if you look at that
00:19:01.480 remove column command you'll notice it
00:19:03.370 doesn't have enough information in it to
00:19:05.500 roll it back sure we can remove the
00:19:07.570 column but when we want to add it back
00:19:09.280 what what type was it so in this case we
00:19:12.040 also need to have an add column command
00:19:14.770 in here now remember in the previous
00:19:17.500 migrations we had a change method
00:19:19.000 instead of a change method we're gonna
00:19:21.460 have an up method to migrate up and the
00:19:25.060 down method so that our application
00:19:26.710 knows what to do if we need to roll this
00:19:28.840 migration back a couple of the migration
00:19:31.270 commands include rename column rename
00:19:34.270 table drop table change column and
00:19:38.170 change column default so we know how to
00:19:42.940 add columns we know how to remove
00:19:44.590 columns what about everything else well
00:19:46.990 for everything else we're simply going
00:19:48.640 to create a migration and name it
00:19:50.410 anything that we want so in this case
00:19:52.360 let's drop the zombies table altogether
00:19:54.840 that's going to generate a up-and-down
00:19:57.460 method for us and we're gonna have to
00:20:00.070 write it you can see here I've written
00:20:01.270 it for us we have a drop table in the up
00:20:03.640 and we have create table in the down for
00:20:07.120 more information on database migrations
00:20:08.860 head over to guides Ruby on Rails org
00:20:12.070 over there there's a rails database
00:20:14.200 migrations guide which has tons of great
00:20:16.390 information about migrations so when we
00:20:19.240 created our rails app it ran bundle
00:20:20.950 install and installed
00:20:22.150 of external dependencies how to know
00:20:24.520 which dependencies to install well that
00:20:26.950 came from the gemfile which is at the
00:20:29.290 root of our directory so here you can
00:20:31.780 see a listing of all of our rails apps
00:20:33.190 external dependencies and whenever we
00:20:35.290 want to make sure we have these
00:20:36.640 installed or go out and install new ones
00:20:38.590 we can just run bundle install and
00:20:41.320 remember I got called by default when we
00:20:43.330 created our first rails app for more
00:20:48.220 information on bundler obviously I don't
00:20:49.960 have time to go into all the
00:20:51.220 nitty-gritty head over to Ruby on Rails
00:20:53.650 org in the screencast section there
00:20:55.540 they'll find a screencast in bundler I
00:20:57.130 created also you can go straight over to
00:20:59.230 the bundler website at gem bundler calm
00:21:03.979 by default our rails application uses a
00:21:06.599 sequel Lite database one way we can tell
00:21:08.969 this is on the previous slide where we
00:21:10.679 saw our gem dependencies it had listed
00:21:13.109 gem sequel Lite 3 so it's using a sequel
00:21:15.869 Lite database but how has our database
00:21:17.849 configured well that happens in our
00:21:20.249 config database yeah Moe let's take a
00:21:22.259 look inside here you can see we have a
00:21:25.229 configuration for our development test
00:21:27.359 and production environments how might we
00:21:29.729 change this out for my sequel well we
00:21:32.399 simply would have to change this
00:21:33.539 configuration we give it the my sequel
00:21:35.609 adapter the database name the user name
00:21:38.039 and password for our database and we
00:21:39.929 would replace the sequel Lite driver
00:21:41.459 with my sequel to inside of our gem file
00:21:43.649 run bundle install and then we'd be
00:21:46.319 using my sequel that's all we're
00:21:50.699 covering for level one now it's your
00:21:52.499 turn to take this information and learn
00:21:54.449 by doing in the challenges