Rails 3 – Build a Blog – Part 3: Edit and Delete CRUD

by woody2shoes on August 10, 2010



This is the continuation of the Rails 3 Build a Blog series. This episode includes implementation of the Edit and Destroy methods on the Posts Controller. There are a lot of things left to cover on Rails 3, but this gets you the basics of the MVC framework and how to use Cucumber to build your application using BDD.

Download 361.3 MB
Download (iPhone/iPod) 79.9 MB

  • http://twitter.com/jeremyhamel jeremyhamel

    Yes – I’ve been waiting for this!!

  • http://twitter.com/jeremyhamel jeremyhamel

    Yes – I’ve been waiting for this!!

    • http://teachmetocode.com Charles Max Wood

      Glad you’re enjoying these screencasts. I’d love to connect and find out what your background is and what you’re interested in learning.

  • Allan Cochrane

    Very brave to leave the errors in. I could almost taste your frustration at times and believe me, I know how that feels having to jump out of the flow to do research ..

  • Allan Cochrane

    Very brave to leave the errors in. I could almost taste your frustration at times and believe me, I know how that feels having to jump out of the flow to do research ..

    • http://teachmetocode.com Charles Max Wood

      I appreciate that. I leave them in for two reasons.

      First, if I’m going to see the error, someone else probably will as well.

      Second, I’ve read articles or followed tutorials that show you the happy path. I’ve run into problems implementing what apparently worked for someone else. This highlights the pitfalls and helps folks avoid them.

      This episode did have more of those mess ups than normal.

  • Nipingaunflay

    I wonder if your fancy cucumber tests really test anything, remove the logic from your destroy action and replace it with render :text => “I won’t destroy it”, all your steps will pass or just require the user to confirm, or login, your tests will still pass and the post will remain in the database.

    On the other hand it’s not really a good deal to destroy with a get, imagine what happen if a search spider hits those urls.

    This video will be a guide for users without much knowledge on how rails works, so teaching wrong, bad practices won’t help them much.

    Apart from the rant, thanks for sharing and taking your time on trying to help.

  • Nipingaunflay

    I wonder if your fancy cucumber tests really test anything, remove the logic from your destroy action and replace it with render :text => “I won’t destroy it”, all your steps will pass or just require the user to confirm, or login, your tests will still pass and the post will remain in the database.

    On the other hand it’s not really a good deal to destroy with a get, imagine what happen if a search spider hits those urls.

    This video will be a guide for users without much knowledge on how rails works, so teaching wrong, bad practices won’t help them much.

    Apart from the rant, thanks for sharing and taking your time on trying to help.

    • http://teachmetocode.com Charles Max Wood

      I can appreciate your concern over the tests’ efficacy. I probably should have a test that verify’s that I’m on the root/home page. Then I could state with certainty that I’m on a page that would show the information if it were there. (And wouldn’t show it if destroyed.)

      Destroy with a get, I believe, is fine. You simply have to make sure that it’s protected behind a login and secured so spiders and malicious users can’t hit it unless they have permission. I intend to add an authorization system to take care of this.

      This video will be a guide. I agree that I should disclaim that the destroy URL should be protected. But beyond that, I want to make sure that people see what Rails is capable of. If I can make it as clear as possible, then people can come to understand the basics. We can revisit the finer points in future videos.

      I really do appreciate the feedback. Please let me know what you think if other and future screencasts.

      • Johan

        i don’t think rails protects you from cross site request forgery, csrf, (at least the old one did not do it) when you are dealing with get-requests.

  • http://railorz.ru DEkart

    It seems that your RSS feed doesn’t work. I want to subscribe, but see some strange message instead of posts. Could you check this?

  • http://railorz.ru DEkart

    It seems that your RSS feed doesn’t work. I want to subscribe, but see some strange message instead of posts. Could you check this?

    • http://teachmetocode.com Charles Max Wood

      Thanks for the heads up. I’m looking into it right now.

      • http://teachmetocode.com Charles Max Wood

        Thanks a TON for the heads up. It should be working now. If it isn’t, please email me at chuck@teachmetcode.com

  • Anonymous

    I appreciate that. I leave them in for two reasons.

    First, if I’m going to see the error, someone else probably will as well.

    Second, I’ve read articles or followed tutorials that show you the happy path. I’ve run into problems implementing what apparently worked for someone else. This highlights the pitfalls and helps folks avoid them.

    This episode did have more of those mess ups than normal.

  • Anonymous

    Thanks for the heads up. I’m looking into it right now.

  • Anonymous

    I can appreciate your concern over the tests’ efficacy. I probably should have a test that verify’s that I’m on the root/home page. Then I could state with certainty that I’m on a page that would show the information if it were there. (And wouldn’t show it if destroyed.)

    Destroy with a get, I believe, is fine. You simply have to make sure that it’s protected behind a login and secured so spiders and malicious users can’t hit it unless they have permission. I intend to add an authorization system to take care of this.

    This video will be a guide. I agree that I should disclaim that the destroy URL should be protected. But beyond that, I want to make sure that people see what Rails is capable of. If I can make it as clear as possible, then people can come to understand the basics. We can revisit the finer points in future videos.

    I really do appreciate the feedback. Please let me know what you think if other and future screencasts.

  • Anonymous

    Thanks a TON for the heads up. It should be working now. If it isn’t, please email me at chuck@teachmetcode.com

  • Anonymous

    Glad you’re enjoying these screencasts. I’d love to connect and find out what your background is and what you’re interested in learning.

  • Johan

    i don’t think rails protects you from cross site request forgery, csrf, (at least the old one did not do it) when you are dealing with get-requests.

  • http://twitter.com/ronniemiller Ronnie Miller

    Hey Charles, Thanks for the tutorials, they’re really helpful. Regarding setting up each scenario, I did some investigating.. looks like Cucumber lets you use a “Background” statement, so you can setup stuff that will be used for the scenarios that follow:http://github.com/aslakhellesoy/cucumber/wiki/Background

  • http://twitter.com/ronniemiller Ronnie Miller

    Hey Charles, Thanks for the tutorials, they’re really helpful. Regarding setting up each scenario, I did some investigating.. looks like Cucumber lets you use a “Background” statement, so you can setup stuff that will be used for the scenarios that follow:http://github.com/aslakhellesoy/cucumber/wiki/Background

Previous post:

Next post: