Simple Ruby on Rails 5 REST API From Scratch

  Рет қаралды 153,954

Traversy Media

7 жыл бұрын

In this video I will show you how to create a very simple REST API from scratch using Ruby on Rails 5. We will be able to make requests to perform CRUD on articles stored in a MySQL database. We will install the mysql2 gem along with the faker gem to randomly generate content.
CODE: Code for this video
github.com/bradtraversy/simple-rails-rest
SUPPORT: We spend massive amounts of time creating these free videos, please donate to show your support:
www.paypal.me/traversymedia
www.patreon.com/traversymedia
FOLLOW TRAVERSY MEDIA:
traversymedia
traversymedia
traversymedia
MY EDUONIX COURSES: Please use affiliate links from website below
www.traversymedia.com/eduonix-courses

Пікірлер: 225
@jarredmacquoid7688
@jarredmacquoid7688 Жыл бұрын
It's a joy to see that people are still learning rails. Beautiful framework for beautiful language!
@333ANON
@333ANON Жыл бұрын
It's a relic of the past. A good one, but still a relic.
@udyatbhanubaliyarsingh1090
@udyatbhanubaliyarsingh1090 6 жыл бұрын
You are an absolute blessing, I was going thru your Laravel tutorial on Udemy and then I was thinking of a scenario and wanted to know how to expose a REST api thru rails, I googled and then heard a familiar voice and there you are again lol. Thank you for doing what you do, and I took your Bootstrap 4 course as well which significantly made me better at UI.
@websebdev
@websebdev 7 жыл бұрын
I'm so glad that you made this video! I thought that you gave up on Rails. Thanks for your great videos :)
@TraversyMedia
@TraversyMedia 7 жыл бұрын
Nope, I have not given up on anything :) Well may be Flash lol. I want to have resources for all languages/frameworks. Rails is just a little more time consuming in my experience. I still plan on doing a shopping cart at some point
@luissantiago7978
@luissantiago7978 6 жыл бұрын
Traversy Media with spree or from scratch?
@butterworks-io
@butterworks-io 6 жыл бұрын
I have been watching your videos for like a year and you inspired me to learn to program. I'm a rails developer now and I literally never know what the hell you looked like. Hahaha, thanks so much for being awesome. Keep up the good work. You have become my after work podcast on my way home. :)
@sirajussalekin9239
@sirajussalekin9239 7 жыл бұрын
Thank you so much. Rails 5 is amazing, I'm so grateful for your tutorial.
@chainer22
@chainer22 6 жыл бұрын
You managed to cover what took my instructor almost 4 hours to cover in 1 hour. and it is so clear and easy to follow. thank you so much for making this.
@BIERKOFF07
@BIERKOFF07 2 жыл бұрын
Exactly what I needed. Great video... 4 years later and is very useful yet.... thanks
@PetriikVx
@PetriikVx 10 ай бұрын
Wonderful, thank you Brad. Six years later works well. Just one change: update_attributes is already been deprecated, use update instead.
5 жыл бұрын
I followed tonight this tutorial without any problems. I have already used Postman before but with you explaining it looks like easier. Nowadays the Postman Extension is deprecated as Google Web Store shows in its page and they suggest us to use Postman Native Apps, but even this way it worked perfectly here. Thanks again for sharing your experience with us, Brad. :)
@Templars1005
@Templars1005 7 жыл бұрын
Fantastic video man! Thank you very much. Your channel has been and continues to be extremely helpful. Keep up the great work!
@danatassler8776
@danatassler8776 2 жыл бұрын
Been out of Rails development for a few years now. I've not looked back because I DETEST full-stack development. By that, I mean I really dislike having to figure out what "flavor of the week" technologies someone has implemented and research them. For this reason I've not accepted any LinkedIn offers. A college classmate suggested I revisit Rails and specifically specialize in APIs. Landed me here. Great tutorial! I especially liked the impromptu nature. (Complete with cussing.) Thanks so much!
@clementhung5576
@clementhung5576 3 жыл бұрын
For anyone using rails 6, the update_attributes function is deprecated. It is simply article.update(article_params). Great Video either way but wished there was some installation guide, as a beginner it took me a long time trying to gem install mysql2.
@zanaeira
@zanaeira 3 жыл бұрын
Thanks for this! I had the same issue on Mac. I had to install MySQL first using homebrew before it would work. In any case, this was a great tutorial so thanks for taking the time to make it :)
@andreivandrummer
@andreivandrummer 7 жыл бұрын
I bought your course by building 12 applications with Angular 2 and it's amazing, and all the videos you've done on youtube have been the same, I've learned too much! THANK YOU! I'll wait for the authentication token! (Part 2 of this video haha) thanks! : P
@luminarycrush
@luminarycrush 3 жыл бұрын
Great starting tutorial, it got me going in the right direction. I did hit a wall attempting to connect to a pre-existing database and not a newly created one. RoR has this funny opinion about lower case table names and pluralizing things by default so that took me a while to figure out. But now I'm off to the races. Thanks!
@israeluribe2010
@israeluribe2010 6 жыл бұрын
Great video, Brad! After this, now learning how to add authentication to the API using Devise and JWT. Wouldn't advance without this video! Thanks a lot!
@philschmidt2104
@philschmidt2104 4 жыл бұрын
Thanks so much for making this tutorial - I'm still a student now but I'll make sure to show my support once I have a full time job - many thanks again!
@ryanmontgomery6248
@ryanmontgomery6248 6 жыл бұрын
I like your style Brad. Thanks for this tutorial it was very well done and easy to understand. I really like the pace and explanation on your tutorials. Thanks
@maxarellano3425
@maxarellano3425 4 жыл бұрын
Great video man. Much better than all the other tutorials on rails APIs
@ahmetomer1759
@ahmetomer1759 7 жыл бұрын
You are an inspiration to me showing you don't have to be a nerd looking guy with glasses and mess hair to be a programmer I love it :)
@TraversyMedia
@TraversyMedia 7 жыл бұрын
Thanks. Yeah screw stereotypes. I can't stand them. I do have glasses by the way, my eyes are horrible but I wear contacts :)
@devilmanscott
@devilmanscott 7 жыл бұрын
Yeah, but it's the nerd looking people who normally put the most work & time into it, computing if you really want to be good you have to sacrifice many things. Also love books & documentation, people forget there's already been over 70 years of knowledge build up and that takes a long time to catch up to, I see too many trying to do shortcuts and rely too heavily on frameworks and libraries. Frameworks came to be because people who knew how to do from scratch wished to make development quicker, but now people only know how to use frameworks without understanding the core structure itself.
@TraversyMedia
@TraversyMedia 7 жыл бұрын
You can still care about what you look like, dress nice, go to the gym, etc and have huge passion for programming (or anything else). I have nothing against the people you are talking about, the nerdy types that basically do nothing else but I love diversity and I love to show people that anyone can do this if you have the passion for it, doesn't matter what you dress like, look like, music you like or anything else.
@devilmanscott
@devilmanscott 7 жыл бұрын
I wasn't saying you couldn't, I was just added the reason why a certain type of person seems to be so prevalent within the industry as I try to get really in-depth into computing knowing it from all angles from both low and high even I find it hard to allocate time for other things hence why I said sacrifice is quite often demanded, if you want to reach the zenith of your field, whether that be web, gaming, desktop, network and so on. Quite frankly the more I delve deeper into the rabbit hole it gets even more overwhelming, so I understand why people stop caring about the more normal day to day activities, luckily enough I enjoy computing immensely, but I do understand why many drop off, I now also tell people don't get into it, if you are just trying to make money, only if you truly interested. Anyway nice video.
@guilhermebertholuiz1560
@guilhermebertholuiz1560 4 жыл бұрын
I cant thank you enough, with this video I know exactly what I have to do for a test
@crazy_vulcan
@crazy_vulcan 7 жыл бұрын
Love starting up youtube and seeing new great content. Keep up the great work.
@ThePolaris87
@ThePolaris87 5 жыл бұрын
Great simple tutorial. Thanks! And it's so awesome to be running Rails on Windows now finally!!!
@eugenemusebe4963
@eugenemusebe4963 7 жыл бұрын
Damn you rock man.Am a laravel guy and just realized shifting to rails can take me a week or so to grab the concepts
@TraversyMedia
@TraversyMedia 7 жыл бұрын
Yes! That is what many people that a re just starting out do not understand. They ask how I know so many frameworks, but there is just so much that is similar. If you know migrations in Laravel you know them in Rails. Just minor syntax differences. There are so many things like that
@doloresdadd
@doloresdadd 7 жыл бұрын
Another great tutorial. You take the great factor of of learning a new language.
@MaHa63b
@MaHa63b 4 жыл бұрын
Very clear presentation about Ruby on Rails API functionality. Thank you about contribution.
@pneuma1387
@pneuma1387 5 жыл бұрын
that “shit” at 4:40 was awesome
@bil4103
@bil4103 5 жыл бұрын
Recommended Ruby on Rails REST-API tutorial 👍🏻
@luissantiago7978
@luissantiago7978 7 жыл бұрын
Definitely donating for great content! Thank you for uploading a ror project again!
@shuckle2134
@shuckle2134 5 жыл бұрын
I'm really digging ruby right now: just wish it was more popular these days.
@НикитаКальнов-л8ш
@НикитаКальнов-л8ш 5 жыл бұрын
oh yeah
@SteveM2
@SteveM2 7 жыл бұрын
Nice tutorial. CRUD API in 30 mins is pretty awesome.
@TraversyMedia
@TraversyMedia 7 жыл бұрын
Thanks
@AlexSmithCGI
@AlexSmithCGI 7 жыл бұрын
Thanks, Can you make Video on AngularJS 2 using this Rails API
@curlykink08
@curlykink08 5 жыл бұрын
Great tutorial, easy to follow and well explained. Thank you!!
@shubhashshivade6658
@shubhashshivade6658 2 жыл бұрын
Big fan sir of your teaching style
@jhonnymoreira2915
@jhonnymoreira2915 7 жыл бұрын
It is valid to notice that at 18:39, the @articles could be something like: Article.order(created_at: :desc).
@yiranli145
@yiranli145 6 жыл бұрын
Thank you so much! This video is really helpful and clear for a beginner like me!!
@GonzaloOviedoLambert
@GonzaloOviedoLambert 5 жыл бұрын
Thank you very much. All good, all functional and with spanish words where is applicable. Greet for Chile.
@ceznvr
@ceznvr 7 жыл бұрын
If you get "ActionController::InvalidAuthenticityToken" error you can add skip_before_filter :verify_authenticity_token to application_controller.rb to make it work
@makymadi242
@makymadi242 5 жыл бұрын
skip_before_action :verify_authenticity_token
@yli8888
@yli8888 6 жыл бұрын
Great article - thank you Traversy. One small bug in the controller destroy method. It should follow the same pattern to be safe: if article.save ... else ... end
@SuperRkkk
@SuperRkkk 5 жыл бұрын
Thanks good resource for beginers to understand REST Api
@matthewhanyu6158
@matthewhanyu6158 6 жыл бұрын
Awesome tutorial! I got a lot of things...thank you!
@MarkCorrea
@MarkCorrea 5 жыл бұрын
Awesome. Simple and easy to understand.
@juancamiloq1
@juancamiloq1 7 жыл бұрын
Brad my man, Im kinda new to programing and Im already learning Rails, a lot of people told me that its the best way to learn back end. What do you think? Awesome job man, please keep keep going :)
@TraversyMedia
@TraversyMedia 7 жыл бұрын
I think it is a good choice. It is very clean compared to something like PHP but all languages/frameworks have pros and cons. Node.js/Python/Ruby on Rails/PHP all good choices, it is all preference.
@juancamiloq1
@juancamiloq1 7 жыл бұрын
Thx a lot man! I´m going to keep learning Rails and later start with the JavaScript thing. I'm still very glad to see your React and other JS videos, to make me the best idea of everything that its going on.
@amani_art
@amani_art 7 жыл бұрын
Juan Camilo Quintero best decision ever.
@harjitsingh7308
@harjitsingh7308 6 жыл бұрын
Ruby is cool. It paves a way for other languages, after you know ruby it is easier to learn python, crystal and elixir
@d0m2288
@d0m2288 5 жыл бұрын
Your videos are always helpful, thank you.
@dave76920
@dave76920 6 жыл бұрын
So simple. So clear. So good. Thank you so much.
@ChronosLordTime
@ChronosLordTime 5 жыл бұрын
Awesome video, good edition, well explained, straight to the point.
@Sindoku
@Sindoku 5 жыл бұрын
Awesome thanks for posting this, Rails APIs are the easiest to make in the industry, even easier than Express IMO.
@emrahakgul8296
@emrahakgul8296 5 жыл бұрын
Great work requires great appreciation. Thanks for great video, man.
@emmanuelo.5594
@emmanuelo.5594 5 жыл бұрын
That was awesome you're the best it's even easier than rest Api in Flask 😎😎😎
@denisgaivoronskii6907
@denisgaivoronskii6907 6 жыл бұрын
Вы спасли мою курсовую работу! Thanx a lot!
@davidlafontant2973
@davidlafontant2973 2 жыл бұрын
You saved my day. Thank you very much 👏🏿👏🏿👏🏿👏🏿👏🏿👏🏿👏🏿
@bryansharpley4190
@bryansharpley4190 7 жыл бұрын
awesome thanks for all the great tutorials you make, if you do happen to expand on this and make one on connecting a js front end would be awesome with react or react-native
@saitej8018
@saitej8018 5 жыл бұрын
Thank you very much for the great video.This helped me a lot, please make the video on the authentication of API application
@AngelGarcia-pb5nf
@AngelGarcia-pb5nf 6 жыл бұрын
This is really great! One question, however: on top of this API, could you still build the rails application as normal? Like could I have a full web app with bootstrap, and user auth, and all the functionality I need AND the API on one website? or will I have to make this rails API, and in addition to it, make another rails project which only consists of the application itself?
@lexvieiralima
@lexvieiralima 5 жыл бұрын
Great video brad, very useful :)
@MatthewTrussell
@MatthewTrussell 5 жыл бұрын
You can also use Hyper Terminal with bash in Windows. I prefer it over the Git bash because Hyper is very customizable.
@kwesiacquah-dadzie1431
@kwesiacquah-dadzie1431 4 жыл бұрын
Brilliant tutorial! Well explained. Thank you
@groupemana6887
@groupemana6887 7 жыл бұрын
Thanks to your videos I learned lot of things. Can you make tutorials on JEE and Symfony ?
@n3xtgennexus
@n3xtgennexus 3 жыл бұрын
If you are using a recent version or RoR and get the error `undefined method update_attributes` for the update functionality, replace the `update_attributes` with just `update`
@viveknaik6798
@viveknaik6798 2 жыл бұрын
Very useful video! Thanks a lot!
@faraznisar3752
@faraznisar3752 3 жыл бұрын
What do you use for formatting the code, I noticed that your code gets auto formatted on save.
@joshcesana
@joshcesana 5 жыл бұрын
Great video! It helped me out a lot!
@StoriesByDrew
@StoriesByDrew 2 жыл бұрын
I have to learn Ruby and RoR for work so I can work on some of the microservices there. Since I don't want to invest a huge amount of time learning Ruby for my own personal reasons/opinions, this course is perfect. Wondering if we can get an updated 2022 version?
@TariqueMahmud313
@TariqueMahmud313 7 жыл бұрын
I thought you are a very skinny and geek looking guy :) I've been wrong for years! Thanks for another great tutorial.
@TraversyMedia
@TraversyMedia 7 жыл бұрын
I get that a lot :) Unfortunately that is how we think of programmers. I enjoy breaking stereotypes
@alfredosotoz
@alfredosotoz 7 жыл бұрын
Thanks for the video, I've learn a lot. Have on question, when doing a get request, how can you find by the title of the article and not by the ID? Sorry if my question is dumb, I'm newbie and learning. Thanks!
@tinomsakwa3757
@tinomsakwa3757 7 жыл бұрын
I have been waiting for this!!
@edgarcheverier
@edgarcheverier 6 жыл бұрын
Thank you! that was really good and simple!
@juroltv3119
@juroltv3119 2 жыл бұрын
Thank you so much, Sir! More power
@estah0
@estah0 6 жыл бұрын
Fantastic video man!
@cagrioz9798
@cagrioz9798 7 жыл бұрын
Hi Brad. I have question about learning. I am building wordpress websites and selling on market. Also i want to learn vue.js Python etc.. Do you should to learn some languages or frameworks when building something ?
@pe2062
@pe2062 6 жыл бұрын
Hey there! I didn't know where to post this request so here we go. I was wondering if you could do some tutorials on GraphQL and how to use it as a starting point for s ingle feature in RoR App...say a blog post, or an article. THANKS! I'm getting super into GraphQL and want to know how to kick off architecting Apps and API's with it in mind.
@bsqtechnology7775
@bsqtechnology7775 5 жыл бұрын
Thanks,Can you make video on user authentication API
@coffeeintocode
@coffeeintocode 7 жыл бұрын
Hey Brad, any chance of the same thing with PHP7? Keep up the great work, I'm doing your React course right now too
@SXCRD
@SXCRD 7 жыл бұрын
Anyone who gets an error at 29:00 put this line at the top of the controller (before the index,show and create but inside the class): skip_before_action :verify_authenticity_token
@KingaLMoody
@KingaLMoody 6 жыл бұрын
This one didn't help me, but adding :create into routes.rb after :index and :show works perfectly
@danhmanhnguyen4584
@danhmanhnguyen4584 6 жыл бұрын
it didnt work ;< so confusing
@bradchellingworth5973
@bradchellingworth5973 6 жыл бұрын
Actually if you want to be safe, you should include your authenticity token in you post requests. Just adds another layer of security. You solution is not checking the authenticity at all meaning anyone can post to it.
@Treedboxcom
@Treedboxcom 6 жыл бұрын
Very nice, thank you! Already subscribed :)
@yasminekordjazy3378
@yasminekordjazy3378 2 жыл бұрын
awesome! clear explanations
@JackAndAmandaGoode
@JackAndAmandaGoode 4 жыл бұрын
Kept it real. Love it!
@ewertonfrancoo
@ewertonfrancoo 6 жыл бұрын
Hey Dude! The video is awesome!! Thank you
@miguekos1233
@miguekos1233 5 жыл бұрын
Exelente explicacion, justo lo que necesitaba.. Saludos
@ahsanihsan8203
@ahsanihsan8203 6 жыл бұрын
Dude you are a life saver. Thank you.
@Thales1250
@Thales1250 6 жыл бұрын
Thank you so much! Really helpful!
@amarpatwa6752
@amarpatwa6752 7 жыл бұрын
hey Brad , your work is fantastic . please make a video on codeigniter restful API.
@lilSanchez100
@lilSanchez100 4 жыл бұрын
awesome as always!
@jassochivisuals5113
@jassochivisuals5113 7 жыл бұрын
Amazing video! Keep it up.
@mazarpradecki2983
@mazarpradecki2983 5 жыл бұрын
Great video! Thanks!
@jaepark75
@jaepark75 6 жыл бұрын
Traversy, I have a question about Rails 5. I'm currently using a virtual environment "vagrant", I have rails 4 installed on there. How do I build a rails 5 app without replacing my rails 4? Sorry if this is an easy question, still new to all this.
@Dams21
@Dams21 5 жыл бұрын
Great tutorial! Thank you :)
@loulamperouge2557
@loulamperouge2557 5 жыл бұрын
localhost/phpmyadmin is running on a different localhost port? or is it using the same port as the rails server does?
@cedrio1027
@cedrio1027 4 жыл бұрын
man you helped me so much thank you
@muhammadahmad7329
@muhammadahmad7329 6 жыл бұрын
Great Informative Video
@005JR8
@005JR8 6 жыл бұрын
hi thanks for video can you make a video on api consumption ... from one rails appilcations to another like you did here with postman
@Thaidakarium
@Thaidakarium 7 жыл бұрын
:0 this was unexpected for me x) thanks sensei
@TraversyMedia
@TraversyMedia 7 жыл бұрын
lol, It was unexpected to me too... I just decided to do it this morning :)
@johnbrown9181
@johnbrown9181 7 жыл бұрын
Nice tutorial, although I don't see any reason to use a database server during development. SQLite is more than fast enough for that, and using MySQL makes it a hassle to set up CI, and makes it harder for any new contributors to get set up as they have to set up a DB server and change the username/password.
@minelove789
@minelove789 7 жыл бұрын
Thank you so much sir! Salute to you!!!
@raphaelmro
@raphaelmro 6 жыл бұрын
Amazing tutorial!
@manutheitguy5225
@manutheitguy5225 7 жыл бұрын
Hi Brad, is it possible to download the videos after I buy the 10 projects course on eduonix? I don't have unlimited internet at home but I was planning on downloading the videos at work and do the projects at home.
@TraversyMedia
@TraversyMedia 7 жыл бұрын
Honestly I have no idea. The courses I make for them I have no control over and have no say in. I am paid a fixed price and they handle the rest. I would suggest emailing support
@manutheitguy5225
@manutheitguy5225 7 жыл бұрын
okay, thanks.
@ssj3broly105
@ssj3broly105 7 жыл бұрын
very easy to follow
@monishnjs
@monishnjs 6 жыл бұрын
nice explanation
@rotrose7531
@rotrose7531 7 жыл бұрын
thank you very much! It is too great!
@sushmithabhaskar3919
@sushmithabhaskar3919 4 жыл бұрын
You helped me a lot...
@giridharan4771
@giridharan4771 6 жыл бұрын
Nice tutorial
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 85 МЛН
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 25 МЛН
Evolution of the Samsung Galaxy
0:50
ios_aesthetics
Рет қаралды 9 МЛН
🤔Где сапфировое стекло в смартфоне? 📱
0:52
Nokia 33-10 ☠️ #shorts
0:33
Apollon 🗿
Рет қаралды 462 М.