Ruby on Rails 7 Alpha Quick Start Guide including Tailwind CSS and new At Work Encryption

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi welcome to a rail 7 quick start guide l7 is now available in alpha and by the time you're watching this it may be later than that but we can get started with it straight away and showcase a new application all the things that have changed and some other new features that you may want to use in your application so let's get started with that uh in my case uh you can just go ahead and go to your console and you can do gem update rails double dash pre and it will come with a whole list of spam for you if you've not done this already in my case it'll say nothing to do in my case i had to update my redis gem before doing this but it your your experience may vary it'll tell you what you actually need to update in that case however we have this available so let's create a new rails app now i'll rather look at quickly the help system for it because a couple new options here major big changes in this release we have a replacement for webpacker entirely to a system that um feels a lot more like the the sprocket system that used to exist before that i think in the um the webpacker system which wrapped up web package gm which wrapped around webpack you dealt with yarn you dealt with md npm and that was a bit complicated and a bit non-obvious really to people who are used to users using the gem file and just using that kind of stuff to deal with things previously however it worked very well for years however now with rail seven there's a big c change in how that's being done because of http 2.0 dealing with lots of files uh being sent over the wire quite well and um import maps being well supported so we'll go into that briefly in a moment the other thing is that now we can choose a css processor and also framework if you like when we create our new apps in this case tailwind is an option post css sas is dart sas and then there is an option for bootstrap as well it's not shown here it's not quite working just yet in the alpha release but um just to create a new project with bootstrap straight away or tailwind straight away is a very nice thing to do so let's just do exactly that so rail's new and then i'm going to create the to-do app that would just be great for beginners in the other videos and let's just add this to my database so postgresql in my case yours may differ there but then i'm going to specify css tailwind one of it will go and create a few bits and pieces install various bits of gubbins and then you know we can take a look at the big changes to uh rails seven um particularly we're going to start with the gem file i think or in fact before i forget let's just create a database so don't forget this and make sure that everything is working whoops uh ldb create oh i'm not in the folder that's why whoops there we go well db create and you're up and let's open a new tab and then just go and make sure the server is running so localhost 3000 yes it's all working so we're okay there so from here yes let's look at that that gem file so let's open it up and take a look at the gem file so here things have changed i'm just going to rearrange this a little bit um so that everything is in the order i kind of want to discuss it in so we have uh going from the top down we have input map which i just talked about so that's sort of the replacement for webpacker and everything else to do with that kind of stuff there's obviously links to the various guides for that or the various repos tailwind css we know that we've specified that we'll just verify it's working in just a second and then we've got turbo and stimulus rails now these were available for rail 6 and maybe even before that but certainly for rail six are something you could add into your project and turbo rails is the replacement for what used to be well yeah um it's all part of the hot wired framework basically uh so turbo and stimulus are the two but previously we did have turbo links it's now just called turbo and stimulus is if you haven't heard of it before it's a sort of a js framework that lets us do a lot with a very small amount of javascript so we can add little bits of javascript to get quite a lot working in our apps but those are sort of independent of rails 7 themselves they're just provided by default now so you can turn them off if you want to of course further down nothing particularly too um surprising in here and just moving down to here so by booger's now gone that's been replaced by this debug gem i need to look at that myself i haven't really looked into it too much for this but we'll i'll come back to that later and then a couple of things have been uh turned off so we've got gem spring is been turned off um spring was very good at speeding things up on slower computers but because computers are very fast by comparison to when spring first came along along the scene it's not on by default but of course you can just uncomment this to turn it back on if you wish spring was always a bit of an overhead and you had to remember that it was running in a certain cases so having it not be something you have to think about is good in that particular case and then rack mini profiler is kind of handy to actually turn on and then see information at the top left of your browser however if you do turn on that on and bundle of course make sure it's included then you'll just want to make sure you restart your server before that will actually appear in the web browser and then the test group is exactly the same so those are the changes to the gem file and that brings us on to looking at the application itself in rails seven and let's see how this affects so let's see how easy true tailwind is or let's see first of all how hard it was previously so if i go into code and i just go to my tailwind guide rather someone else's tailwind guide i use um this is the guide i use works very well with rail six and you by all means you can follow through with this guide and see how easy or hard it is to add it to rails to make sure everything's working so you you can get down to this point there's like about 12 steps and bits and pieces um yeah um all these things you need to do to make sure all works and everything now that's gone away so how does it go away well let's create a couple of resources and you'll see why so first of all i'm going to create the d to do task resource if you like that we did in the previous episode for the beginner series and i'll just show you how that actually uh looks and works with tailwinder or an easy version of tailwind so let's create that so rails um generate a scaffold and uh because this this is just an easy way to do things for a task and let's just give it a title a description in texts a due at column from date time a deleted column and if you're interested in soft deletion that's in the previous episode you're more than welcome to take a look and then finally this state which is an integer okay i'm not going to cover any of what those are there in the previous episode if you're really interested we're going to create that scaffold and i'm going to create a second scaffold where's generated scaffold for a user and then i'll just put a name and an email we're not doing password authentication or anything at this stage just really showing you a couple of things so we've got both of those built in we can go back into our code go to the uh roots file and then just get the root of the the entire site the home page to the tasks index page and then if we just refresh uh let's just see where have i got my localhost anywhere uh oh i need to just migrate yes i always forget to do that when i'm doing these these videos there we go so we can just refresh and we should get the page okay now it looks pretty unstyled but it's not it's that it's actually working with j with tailwind already how do we know that well if i open up a uh examples file that i have trivial example here is just to open up application html erb and apply some classes to the body tag anti-aliased font sans and then bg gray let's increase that to like 700 okay that's an actual class provided in tailwind it's nothing to do with anything i've done and if i refresh the page yes so we obviously have tailwind working now we can go a little bit further than that we can just decide to go down here and let's just say if i want to copy and paste all of you and i'm just going to paste it into the tasks index for now but this is more like a user page more than anything else but if i refresh you'll see we have this table and it's all nicely styled as provided by tailwind stuff and if you want to get more components like this that people have put together have a look at tailwindcomponents.com uh tailwindcss.com is the of course the framework url but this has lots of copy and paste code you can use to be inspired by and you know make lots of changes to and play around with it so nice and easy so we know tailwind's working and there's no configuration it's all done for you which is quite nice when starting a new project now one thing i wanted to just do and do is look at the users page this is going to be unstyled don't worry i'm just going to leave unstyled in this case i'm not going to worry with too much styling because i want to demonstrate the last thing on the show with the rail 7 release that is encryption or at work encryption now you may be familiar with in transit and at rest encryption in transit is over the wire so https ssl that kind of stuff at rest is the stuff that you will do for your database itself on its server so for example aws amazon web services will provide encryption at rest for your database to make it safe from outside attackers but if you have access legitimate access to that database like say for example a database remote connection you can still see all the data inside of it and you can still download that so this is what work encryption does this is not the same thing whatsoever as password you know salting and hashing it's not anything to do with that this is just for storing information in encrypted form of the database that your application only your application can actually decrypt so obviously there is going to be a little bit of a penalty there but for things like personally identifiable information like for example maybe names email addresses social security numbers national insurance numbers addresses you could have all this kind of stuff in there that was encrypted now we need to do a few things first of all to get this to work first thing we need to do is go this is the guide for it and there is a specific thing you need to do which is this bin rails db encryption init so if i just go into here and just um type that in bin rails db encryption init that will actually give you a set of credentials okay in my case i'm not i'm showing i'm showing these on camera but it doesn't matter it's just a test project so we'll just copy and paste that and then i need to do basically uh editor let me see if i've got this remembered yes i do so in my case i'm going to load this up with text mate just in a different editor there we go this is my credentials file for this particular project i just paste that into the bottom and then close that up and it says file encrypted and saved so that's how you deal with encrypting encrypted credentials in rails but this is just adding some more credentials into there now we've done that we need to restart the server okay so let's not let's not try and keep the server running and i'm also going to load up a new tab and then go into the rails console then i'm going to go to this users model um in fact i may need to restart again because i've got to do something else first let's go to the user model that we created and i'm going to do encrypt name uh whoops no no just encrypt name thank you very much and i'm also going to do encrypts email now these are the examples given on the rails website but um we're also going to use deterministic true so what are the differences they both encrypt things so if we just go just and restart everything again just to be completely uh paranoid and more than anything else in these videos and if we just reload that re users resource and create a new user let's create a user called alice and uh email of alice at example.com create the user in this case we're also going to create a back to users and create a second user called bob and bob at example.com great user great so back to users so we have these two users and they're in there and they're in the database they're visible and if i for example go across to my rails console and say use it all we see we have two users great you say well what does this encrypted thing do is what is it done so if we go across the pg admin that's looking at this server if i just refresh and we go to development schemas tables and then the users table and if i right click i can do view edit data or rows see the bottom here now in name and email they're not the plain text values in the database even if you have a legitimate connection to the database and pull this data out there are encrypted values but not in here now what's the difference you may ask between name and email deterministic you may think well everything should be deterministic if you're if you're decrypting it surely well not exactly so the difference here is if i ask for user.where name is alice i get nothing okay an empty array that happens just because i can't query things that are just set as encrypt crypt's name so if ever want to find anyone by their name i can't use that option but if i just want to output that for example let's say the first line of their address if i never need to search for it um so i don't know maybe this is more difficult than i imagined about thinking about something that i will never need to search for but let's go on to the deterministic one so if i do the same thing but i do email is alice at example.com it comes up just fine so yes if you want to query on something use deterministic true otherwise use just encrypts and that will work fine again it's kind of up to you your particular example your particular application as to which one is more appropriate for you but very handy tools to have for perhaps confidential information perhaps just sensitive information or indeed personal identifiable information you could do something with imp address if you were storing ip address for example because you wanted a higher degree of security on that particular field uh pretty good so i like the fact that that's available by default with rail7 i think it may have been even independently produced i think it may just be packaged with rails 7 but those are the main things that i wanted to just show you oh and also i just wanted to talk about yes input maps and how that's actually dealt with so if we just go back onto our application here and go on to more tools developer tools and if i go into the network tab and then refresh the page you see all the files come in now they're all separate files and there is the hello world so in this case if i want to for example make a change in this hello world example uh it before when we compiled everything to a single file this would all produce a single file so that would mean it would have to regenerate that entire file because i made one change in here now in this case this will still be dealing with cache busting but like hash bus when i make a small change to that one small file and because all the files are dealt with a little bit better with http 2.0 then uh everything is much nicer as far as dealing with cache busting is concerned with rails 7. uh in real six there will be like two files here the application.js and application.css and i can't remember exactly because i don't have it in front of me but yeah there'll be two or three files uh in here i think vendor.js it includes.js are the ones and then the application so yeah so that's that i'm pretty much happy with rail 7 release so far if you've got any questions about it if you've if you haven't looked through the notes and reading through some of the other longer term guides then um do put them down below and i'll do my best to answer them there otherwise we'll be covering in upcoming weeks with and new updates the beginner series and of course i may well do some highlights on on various parts of these new gems and we'll show about that kind of stuff and there's obviously full guides linked in the rails dev post for the encryption guide if you want more information about what that allows you to do and other bits and pieces and all kinds of stuff like that i may all do the separate episode on that but uh for now i think that's a good quick start guide otherwise you should be good to go with very similar kind of stuff that you do with l6 and head off and create new projects if you enjoyed the video do give a thumbs up down below feel free to subscribe if you aren't already and click on the bell for notifications for more episodes and yeah we'll hopefully see you next time thanks for watching
Info
Channel: Code Build Repeat
Views: 2,485
Rating: undefined out of 5
Keywords: ruby on rails 7, rails 7, rails 7 tutorial, ruby on rails 7 tutorial, ruby on rails 7 guide, rails 7 guide, ruby on rails tailwind guide, tailwind css, ruby on rails encryption guide, at work encryption, ruby on rails, web development, tailwind css project, tailwind css rails, install tailwind css
Id: VOUi7Kbt_Vk
Channel Id: undefined
Length: 17min 17sec (1037 seconds)
Published: Mon Sep 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.