Ruby on Rails Tutorial Part 2 - CRUD Basics with the Rails Console

  Рет қаралды 74,929

andrewperk

andrewperk

Күн бұрын

Пікірлер: 70
@DennyMueller
@DennyMueller 12 жыл бұрын
Thanks for this tutorials. Watched so many videos as ror greenhorn, but no tutorial explained the essentials as good as yours.
@victorls
@victorls 10 жыл бұрын
For those running on rails 4! The line of code that is written on 4:35 "attr_accessible :title, :content" does not work on rails 4. Instead, you have to move on to the controller and write the following: class PostsController < ApplicationController def new @p= Post.new(post_params) end private def post_params params.require(:post).permit(:title,:content) end end Solution found here: stackoverflow.com/questions/18409783/cant-mass-assign-protected-attributes-in-rails-4 Hope it helps!
@rgbm21
@rgbm21 10 жыл бұрын
You are right.I was stuck in it for a while..Thanks
@MrBrianHare
@MrBrianHare 10 жыл бұрын
Thank you
@eklektisk2231
@eklektisk2231 9 жыл бұрын
Thank you! :D
@keithchong6960
@keithchong6960 9 жыл бұрын
+Víctor Lopez THANK YOU SO MUCH DUDE I LOVE U
@alsouno
@alsouno 13 жыл бұрын
best RoR tutorial series on youtube i've come across. thanks :)
@andrewperk
@andrewperk 12 жыл бұрын
Hi Matt, we just use the name of the Model and in Rails the models class name has the first letter capitalized. Yes, you reference all models the same way by calling the model's name and using dot (.) notation to access its methods and properties.
@annabortsova
@annabortsova 13 жыл бұрын
Great videos! so much better than reading through documentation on my own !!! thank you!
@andrewperk
@andrewperk 12 жыл бұрын
Hi Scott, I never expected my videos to be as popular as they are and I just wanted to make some videos as I enjoy teaching. At the time I only had a cheap microphone and this is the quality that it gave me. Hopefully you'll still be able to learn even with the bad audio. Thanks for watching.
@imrankhanvu
@imrankhanvu 11 жыл бұрын
hello andrew perk, u know i was intrested in ror, and i was looking for a start, because from last two or months i was looking for tutorials and trainings, i was listing to some screen costs, but i was confused that whats going on, i wasn't clear that what is rails and what r they doing, and now at the end i found u on youtube, great lecture, i m pleased to found ur lectures, thanks a lot,
@andrewperk
@andrewperk 13 жыл бұрын
@gamers542 Hello, yes it will work on windows. I used to do Rails on windows before moving to Linux. You should still be able to use almost the exact same commands. In your command line navigate into your rails app and run rails console or rails c as instructed. The reason I switched from Windows to Linux is because windows is terribly slow with Rails and testing. In Linux it's very fast. Things for rails just work in Linux where as in Windows it was always a struggle and Googlefu was needed.
@msnazi
@msnazi 12 жыл бұрын
I'm coming from JavaScript to Ruby. This language is beautiful
@hellohello223
@hellohello223 10 жыл бұрын
For people who are using Rail 4, you need to install gem install protected_attributes or save gem 'protected_attributes' in the GEMFILE
@wilprim5383
@wilprim5383 11 жыл бұрын
I love these tuts! They have helped me a ton.
@rixterman07
@rixterman07 11 жыл бұрын
I had to use the syntax: post = Posts.new(.... i.e. plural Posts otherwise an error results... Like the videos! Starts out nice & simple...
@minkury
@minkury 13 жыл бұрын
You have no idea, how helpfull you are to me!!!
@SUNILRAHEJA
@SUNILRAHEJA 10 жыл бұрын
Thanks ....this was helpful too!! I had a issue with the attr_accessible since i was running Ruby 4. However i could figure it out through googling. :)
@HVRain
@HVRain 13 жыл бұрын
The best RoR tutorial, thank you
@inhibited44
@inhibited44 9 жыл бұрын
I programmed rails a few years ago. Never knew you could update or delete by command line. That's good to know. Rails 4 changed so much that I have to rewrite my programs to use them :(
@andrewperk
@andrewperk 13 жыл бұрын
@TheBrogrammer You're welcome.
@leandro842
@leandro842 9 жыл бұрын
you are amazing man! this will help me very mutch, tank you!
@aaaabbbbccc123
@aaaabbbbccc123 11 жыл бұрын
Note these videos are working in Rails 3.1 hence why post.new are throwing exceptions. See stack flow link for fix: stackoverflow.com/questions/17371334/how-is-attr-accessible-used-in-rails-4
@sjalal0228
@sjalal0228 11 жыл бұрын
Great video...very easy to understand.
@sthardman
@sthardman 12 жыл бұрын
No worries. It's just so hard to focus. I skipped this one. The others are better. Thanks for posting. It's really helpful.
@orujgadimov4420
@orujgadimov4420 8 жыл бұрын
@andrewperk Thanks for your great help! It is very easy to follow and understand your tutorials. I have a question and I was wondering if you could help me with that. When i try -create Post table, it always says "nil" never goes to comment "Our first post" etc What am I doing wrong? Thanks beforehand for your help!
@BlazeX344
@BlazeX344 9 жыл бұрын
Very helpful tutorial, thanks! :)
@stcheeve
@stcheeve 10 жыл бұрын
Great tutorial vids, straight to the point. The poping and audio skipping is extremely annoying though.
@gamers542
@gamers542 13 жыл бұрын
But why do the post commands from the terminal instead of running a single file that has the commands stored? Is it easier that way or just for demonstration purposes?
@NjeriChelimo
@NjeriChelimo 12 жыл бұрын
I did find it useful. Very clear. Thanks! :D
@isnerdy
@isnerdy 11 жыл бұрын
Workaround for the runtime error: If you look at the error messages, it says that attr_accessible is depricated (AKA no longer used), and that there's a new security model for mass assignment. While probably not the best idea, one way around that is just to remove the attr_accessible line from the posts.rb file. I deleted the line and then didn't get any errors when setting up the hash.
@fxStar
@fxStar 12 жыл бұрын
Hello, I'm getting NameError: undefined local variable or method `post' for main:Object when I try to do post.save ? Any ideas ? Thank your for these tutorials.
@gamers542
@gamers542 13 жыл бұрын
I'm learning RoR some more and your vids make it easy to follow. Question though. Can you do all that in a file and do Ruby (file name).rb on the command line (I'm using Windows) and it would still work? Thanks.
@monarkbhagat848
@monarkbhagat848 10 жыл бұрын
Hey Andrew.. I am very new to Ruby and ROR too, I just went as per ur video, I am using Rails 4; I added Post.new() to Post Controller and also did the post = Post.New[] in console when I tried to save it as per the video in console I wrote post.save its showing NoMethodError am stuck to this and hope to have a Quick reply on it..
@imrankhanvu
@imrankhanvu 11 жыл бұрын
and some suggestions if u don't mind, when u write and command, its hard to read, because the font is too small, so is it possible that u edit all these lectures and u show all the commands in a subtitle in big size. that way it will be easy for use to read them. thanks a lot.
@ianjamiesonmusic
@ianjamiesonmusic 11 жыл бұрын
Will definitely be switching from PHP.
@vytaslll2
@vytaslll2 10 жыл бұрын
Try Laravel first :)
@under_score2268
@under_score2268 11 жыл бұрын
Great video, thank you very much.
@illtriniboy
@illtriniboy 11 жыл бұрын
I just did this too, I guess we will see how this pans out
@oldno7uk
@oldno7uk 11 жыл бұрын
patience of a saint!
@allenlee9111
@allenlee9111 12 жыл бұрын
Appreciate for your job!
@bjornsteneram6540
@bjornsteneram6540 11 жыл бұрын
So.. can't seem to find the source code for this video on your site Andrew! Good video tho!
@deltaupsilonfraternity3982
@deltaupsilonfraternity3982 11 жыл бұрын
Hello, I am learning RoR and I am having issues with this tutorial, and the blog in general. 1st after I activate the server for the localhost I cannot use the command prompt. (I am using windows) Also I get a runtime error when I try to set up the post = Post.new variable. Help?
@shrenikdoshi2690
@shrenikdoshi2690 9 жыл бұрын
Hey your tutorials are very helpful to me But i have encountered one error please solve it asap NoMethodError: undefined method `attr_accessible` for Posts (call 'Post.connection' to establish a connection): Class
@imrankhanvu
@imrankhanvu 11 жыл бұрын
ok now about the problem, when i run this command post = Post.new(:title => "our first post", :content => "our post content") the console throws a bunch of errors, but the main error is like this, attr_accessible is extracted out of rails a gem. please use new recomonded protction model for params(strong_parameters) or add protected_attributes; to your gemfile to use old one. help me please.
@ShivaprakashYaragal
@ShivaprakashYaragal 8 жыл бұрын
@4.40: its attr_accessor
@biNuTheFirst
@biNuTheFirst 12 жыл бұрын
thanks bro! veryyyy useful
@rtrnzero
@rtrnzero 11 жыл бұрын
Looks like adding attr_accessible to post.rb caused a run time error when trying to create post = Post.new
@AverageGottn
@AverageGottn 11 жыл бұрын
How do I add a column to table with that console?
@drewh22
@drewh22 12 жыл бұрын
Thank you!
@SouravKen
@SouravKen 11 жыл бұрын
Any luck with the fix. I am trying to learn RoR. While following this tutorial I got stuck on this line. For sure this is because I am using latest version on and clearly unlike Java it does not seem to have backward compatibility. I am googling but not no success yet :(
@sampathchetelli8803
@sampathchetelli8803 11 жыл бұрын
while storing values to post it only storing default values...............please resolve my problem...................
@gadamson12
@gadamson12 12 жыл бұрын
When i do post = Post.new[:title => "Our First Post", :content => "Content for our first post"] it returns nil. Help?
@curatedbasics
@curatedbasics 11 жыл бұрын
1.9.3p194 :005 > post = Post.new|:title => "first post", :content => "content") SyntaxError: (irb):5: syntax error, unexpected tASSOC, expecting $end post = Post.new|:title => "first post", :content => "content") hi!! any ideas how to fix this syntax error?
@BharathRajendran-SRM
@BharathRajendran-SRM 11 жыл бұрын
wow.. i love this tutorial ..how to upload file ...can u explain file concept in 12 video
@rameshswe
@rameshswe 13 жыл бұрын
It is super . i am running ROR in Wampserver + ROR installer
@ranesh237
@ranesh237 10 жыл бұрын
what is mass assignment?
@millennia
@millennia 12 жыл бұрын
i think its fine.
@SANVELXRP
@SANVELXRP 12 жыл бұрын
like it
@mayankrajput2102
@mayankrajput2102 9 жыл бұрын
1. irb(main):001:0> on running rails c 2. NoMethodError: undefined method `save' for nil:NilClass on running the post = Post.new.......
@TheRoger005
@TheRoger005 9 жыл бұрын
I was enjoying your tutorials until your link to "source code" goes directly to a ridiculous blank insurance advert.
@Soraskull
@Soraskull 12 жыл бұрын
I can testify to how slow it is cause it drives me crazy.
@IAMPROJECT45RI
@IAMPROJECT45RI 9 жыл бұрын
2.2.0 :016 > Post.title NoMethodError: undefined method `title' for # Somebody can halp me?
@4sky
@4sky 11 жыл бұрын
migrate=> where migrations will be stored config=> where you store configurations for ruby stop using the word to describe the word! it doesnt clear up anything...
@JeffRAX
@JeffRAX 6 жыл бұрын
it appears he is not describing the word, but explaining what is in those folders...
@nikhilfadnis8009
@nikhilfadnis8009 9 жыл бұрын
audio quality kinda sucks
@sthardman
@sthardman 12 жыл бұрын
What's up with the audio? Extremely annoying!
Ruby on Rails Tutorial Part 3 - Routing
7:19
andrewperk
Рет қаралды 53 М.
Ruby on Rails Tutorial Part 6 - CRUD - Create - Save Method
10:49
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
x86 Assembly: Hello World!
14:33
John Hammond
Рет қаралды 1,4 МЛН
Ruby on Rails Tutorial Part 1 - Getting Started
11:10
andrewperk
Рет қаралды 257 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 289 М.
10 Signs Your Software Project Is Heading For FAILURE
17:59
Continuous Delivery
Рет қаралды 44 М.
Кем был убитый в Москве Армен Саркисян
16:59
BBC News - Русская служба
Рет қаралды 59 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 581 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 856 М.
Trump's Plan for "Greater America" Explained
8:42
TLDR News Global
Рет қаралды 759 М.
Fullstack LMS: Ruby on Rails 7, Hotwire, Tailwind, Stripe, PostgreSQL
8:02:47
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН