DISQUS

ruby on rails blog: Ruby on Rails Tutorial, now with more 2.0.2! | ruby on rails blog

  • chris · 1 year ago
    Hi,

    finally a tutorial which uses rails 2 AND is suitable for beginners like me. I tried to start with rails, but there are no tutorials that take advantage of the newest version.
    Can't wait until you post the next entry!!

    Bye
  • sergey · 1 year ago
    please more tutorials! love it!!
  • sergey · 1 year ago
    please more tutorials! love it!!
  • pritish · 1 year ago
    Good metaphors / writing style. However, since I installed RoR with mysql, I had to add a couple commands to make this example work:
    [1.] rails bookstore -d mysql
    script/generate scaffold Book title:string description:text
    [2.] rake db:create:all
    rake db:migrate

    thanks for the posting & good luck with your new ventures.
  • Jonathan · 1 year ago
    pritish:

    I have the command to generate a Rails app for use with a MySQL database, maybe I will make it bold so it's clearer.

    As for, rake db:create:all, I've never used it...EVER :P Thanks for posting, perhaps somebody else will have that problem.
  • steve · 1 year ago
    When I ran the generate scaffold command I got an error:
    wrong constant name Title:stringController

    What I ran was:

    script/generate scaffold Book title:string description:text

    from within the bookstore directory. Removing all and repeating the above still gave the same result. This is the ruby environment:

    Ruby version 1.8.6 (x86_64-linux)
    RubyGems version 0.9.4
    Rails version 1.2.4
    Active Record version 1.15.4
    Action Pack version 1.13.4
    Action Web Service version 1.2.4
    Action Mailer version 1.3.4
    Active Support version 1.4.3
    Edge Rails revision unknown
    Application root /home/steve/projects/ruby/bookstore
    Environment development
    Database adapter mysql
  • Jonathan · 1 year ago
    Steve, you are getting an error because you aren't running Rails 2.0

    Try visiting the link to the ONLAMP article I have posted, or updating to Rails 2.0.
  • Mike · 1 year ago
    Jonathan really this is the best tutorial I've seen yet
  • Sam · 1 year ago
    Thank you so much!
    I was pulling my hair out trying to do all the Internet tutorials written for earlier versions.
    .... I hope the books I ordered are up to date.
    Keep up the good work!
  • Mitch · 1 year ago
    More, more, more stuff like this
  • zulfi · 1 year ago
    Great post... i have downloaded and installed RoR with aptana IDE. Couldn't understand head or tails of the new framework... this post helped me really to get started...
  • joey · 1 year ago
    Finally I found something that I could do! Thanks!

    I had to do a

    "rake db:create"

    to get the mysql to work (should have set up before).
  • Nik Kantar · 1 year ago
    Nice to see Rails2 tutorials are slowly starting to spring up. :)

    Oh, and the last image link is missing "wp-content" in the target url.
  • Anderson · 1 year ago
    Hi, nice very nice page..!





















    Good luck !
  • nick · 1 year ago
    what steps need to be re-run if you add a field to the bookstore? if you wanted to add something like publishing_date, would you re-run the scaffold command? or manually edit the db\migrate01.db file then rake db:migrate again? i have tried what makes sense to me, but couldnt get it working.
  • dx111ge · 1 year ago
    great stuff, started with RoR but wasn´t aware of the differences between 1.x und 2.x . Now I saw , it works :-) if you use the right tutorial ....
  • Geoff Wright · 1 year ago
    All,

    Great tutorial. Definitely one of the more understandable ones I have read.

    However, one thing I would like to see is the "what next" part. Its great that we can see how to get started, but I'm sooo keen to see how you would move it forwards (adding additional functionality), e.g. letting people register and add books.

    If anybody happens to know of a tutorial that sounds like what I'm after - please, please, please point me in the right direction : )
  • st · 1 year ago
    Jonathan,
    Thanks for a good tutorial which is relevant for 2.0. I was using the Rails book but had to stop at page 77. because the examples need 1.2.x.
    guess i can go back to the book to complete the depot app.

    st
  • Cheri · 1 year ago
    Hi,

    I just checked out meeta.com. Nice site! How did you do the routing? The routes look very clean.

    Thanks,

    Cheri
  • Terry · 1 year ago
    Absolute newbie, just installed the latest and greatest rails (read: 2.0.2). After two unsuccessful tries with other tutorials, this was up and running in ten minutes. Well done.
  • Ling · 1 year ago
    I'm a newbie and trying to get my hands dirty with ruby on rails. So far so good. Question though, if you have multiple models...would you need to run the scaffold one model at a time? Also in the end, do db:migrate for each model or does db:migrate collect all the models at once?


    Thanks.
  • Jonathan · 1 year ago
    Yes, you would need to run a scaffold for each model, seperately.

    db:migrate will migrate through all of your migrations, so no, you don't need to run it each time, unless of course you need those fields generated in the database immediately.
  • Saloni · 1 year ago
    Hey tutorial to get started with RoR !!
    Thanks
  • Saloni · 1 year ago
    oops was too happy to get started with RoR and so skipped the word " nice " in my previous comment...

    newayz here it comes again..

    Nice tutorial Jonathan..Thank you very much for you efforts..
  • Andrew · 1 year ago
    Useful tutorial, thanks. I'm still not convinced by RoR though, I turned off javascript and clicked the destroy link next to the new book I made, and nothing happened.

    With javascript on, there is a popup that asks you if you want to delete the book, and that does work. Although the code is inline and quite horrendous.

    I guess this can all be changed behind the scenes, but it stuff like that is so important - why didn't they do it right?
  • Jonathan · 1 year ago
    Andrew:

    The destroy link has a JS confirmation prompt, which you can disable in the view.

    It's nothing to fault the framework for, the destroy link you see was the result of a scaffold generation, which allows you get get your application up and running.

    If for some reason, you need to run an application that supports non-JS users, of course you will need to make those changes.

    Like I've stated before, scaffolding is meant to assist with development...not replace it. How many skyscrapers or houses do you see, post-production, with scaffolding?
  • Dieter · 1 year ago
    Thanks for this tutorial. You've really got me started!
  • Mostanser Billah · 1 year ago
    Really wonderful and helpful as well for beginners like me. I was really afraid of starting ruby on rails, this helps me a lot exactly what I want.

    Thanks
  • Sal B · 1 year ago
    Thank you! I've been wanting to learn Rails for sometime and I've been on Lynda.com for the last week and of course the tutorial for building the web app is using old version of Rails. I stumbled your post - so maybe more people can find this and not have to pull their hair out. I look forward to more tuts!

    Thanks again!
  • evan · 1 year ago
    Create little tutorial. Helped me get riding the rails quickly!
  • cliff · 1 year ago
    Just want to put this out here in case anyone was using postgresql like myself instead of mysql or mysqlite

    I had to make a couple of changes because I was using postgresql. I had to go into the config/database.yml and change the adapter to postgresql and the database to bookstore_dev. These were in the development section. Then I had to rake db:create and then I was able to do the 'script/generate scaffold Book...'
  • CarniBird · 1 year ago
    very nice tutorial
    thanks!
  • sivaji · 1 year ago
    super :D
  • SteveJ · 1 year ago
    Not really sure why the version of mysql that I'm running doesn't install with innodb turned on by default. Other than that little stumbling block (which was not your issue, but mine) the tutorial was what I was looking for. The other posts which mention tutorials for earlier versions of Ruby/Rails are interesting: usually I can fight my way through version differences . . . not with this stuff.

    Thanks
  • iTOtto · 1 year ago
    Hi!

    I get the error mentioned by steve, although I did update everything I could imagine:

    macbook-air:bookstore totto$ script/generate scaffold Book title:string description:text
    wrong constant name Title:stringController
    macbook-air:bookstore totto$ rails -v
    Rails 2.0.2

    Any hints would be appreciated...

    Thank you for the great tutorial!
  • software_developer · 1 year ago
    thank you it is good article.
    very important point is using of upstream version of rails.
    keep it up-to-date.. people need it ..
  • Neverwolf · 1 year ago
    Thank you very much. Finally I can make something with RoR. I feel like a kid with a new toy! Sorry, I'm excited.
  • Michael · 1 year ago
    Thanks for the tutorial. Love it!

    I wish I'd knows about RoR earlier. You can create database interfaces in two minutes with RoR while I'd spent hours creating similar things with PHP. Amazing!

    I'm running OSX leopard and was trying to use MySQL.
    Some trouble I hand with the tutorial and I had to figure out myself:

    Socket file in config/database.yml needed to be changed (for Leopard). Had to change add line of code:

    socket: /var/mysql/mysql.sock

    under "development", "test" and "production"

    I also had to insert password in the given fields.

    Database 'bookstore_development' had to be manually created in mysql
  • Matt · 1 year ago
    Seriously, the one and only rails tutorial I have found that lays the framework for beginners. I really appreciate and enjoyed this tutorial. Thank you so much.
  • Wizzor · 1 year ago
    rails -d mysql bookstore seems wrong to me, I don't know if the syntax has been changed since the writing of this article, but I found the correct order to be

    rails bookstore -d mysql

    With the original script I got a Rails project named -r :)
  • xenfreak · 1 year ago
    "Hi,

    finally a tutorial which uses rails 2 AND is suitable for beginners like me. I tried to start with rails, but there are no tutorials that take advantage of the newest version.
    Can’t wait until you post the next entry!!

    Bye"

    i cannot emphasize with this anymore than has already been said. you explain everything clearly, you know exactly what you are talking about, and explain all the minute details.

    you're a great instructor and i look forward to reading more of your tutorials.
  • Froschi · 1 year ago
    Great tutorial! Thank you very much.
  • Nimit · 1 year ago
    pretty good and easy tutorial
  • my name is hannah · 1 year ago
    you are, like, my hero and stuff.

    I've been trying to get somewhere with ruby on rails tutorials form various sources and have been pulling my hair out. and feeling very stupid. yours is the first i got to work.

    so far anyways...

    woop woop.

    h
  • digitaln00b · 1 year ago
    Can anyone please explain to me why am I getting this error:

    rake aborted!
    #42000Unknown database ‘bookstore_development’

    I've been stuck at this step for hours. :(

    I'm totally new to this.
  • datakix · 1 year ago
    digitaln00b,

    ROR 2.0.2 creates a default database reference name for you called 'bookstore_development' in you config/database.yml file.

    If no db exits, then the migration will fail.

    Just open MySQL (via Query Browser) and create a database called 'bookstore_development' and rerun the rake db:migrate command.
  • Mike I · 1 year ago
    thanks for the tutorial - it was very helpful - i wondered how the scaffold model was implemented in the newest version of ruby ... anyways, i've managed to implement RoR in an XAMPP enviornment on windows, let me know if any one needs help with this implementation.
  • CJ · 1 year ago
    I downloaded the query browser, and connected to the localhost server on port 3000. I executed 'create database bookstore_database' but I got a 'Access denied for user ''@'localhost' to database 'bookstore_database''. I assume I need to use a username and password, but what should they be? Is there a default set for a hobo app?
  • Christopher · 1 year ago
    I downloaded the query browser, and connected to the localhost server on port 3000. I executed 'create database bookstore_database' but I got a 'Access denied for user ''@'localhost' to database 'bookstore_database''. I assume I need to use a username and password, but what should they be? Is there a default set for a hobo app?
  • Christopher · 1 year ago
    oops, i meant i tried to create 'bookstore_development'. I had the right name, it just didn't work out for the reason given above.
  • Primate · 1 year ago
    This tutorial is simply incredible. You're right, there really aren't many beginners guides, and I was struggling with the concepts of rail (after spending so many years with PHP)!

    Thank you so much :D!
  • jefe · 1 year ago
    Those with MySql probs:

    MySQL runs on port 3306 by default, so you connection thru the Query browser should be something like hostname: localhost, port: 3306.

    The only account created after installing MySQL is "root" and with no password, I believe.

    "root" is the admin account, so you will have all access

    hope this helps
  • Gavin · 1 year ago
    Tanfastic!

    Great pace!

    Keep 'em coming
  • Gabe Odess · 1 year ago
    I am new on rails, I am trying to find a way to change my table columns and scaffolding fields from within rails. At this point, the only way I know how to accomplish this is to make the changes through MySQL, and then delete the rails helper file before I run a 'generate scaffold' again.

    There must be a more efficient way of doing this. Any suggestions?
  • Tom Johnson · 1 year ago
    *Big Thumbs Up*
  • Ben · 10 months ago
    Love it, quick and to the point. Great way to start learning Rails.
  • Rowena · 7 months ago
    I got an error in db:migrate, I'm using mysql, is that code ok for mysql?
  • Rowena · 7 months ago
    I solve the problem just add space before the password