SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 33 of 33
  1. #26
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The database code is the smoking gun, everyone who uses Rails has used migrations for years now. Just like you don't directly write select, and update queries, you don't write create queries either. In addition to being easier, this approach insulates you from minor changes and allows you to easily switch to MySQL or whatever. If this book isn't advocating that approach, I'd get rid of it.

    If you have the stack set up, and want to burn 5 minutes, do this:
    mkdir temporary_folder
    cd temporary_folder
    rails quickapp
    cd quickapp
    ruby script/generate scaffold story name:string link:string
    rake db:migrate
    ruby script/server -p 3003
    (in browser: http://localhost:3003/stories )

    I just ran that one, so no typos.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  2. #27
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When i got to page 102 of Simply Rails 2, I had the same problem creating the 'stories' table from the code in the code archive, since I always got an auto_increment error. After playing around with the statements, I found if I changed int(11) to INTEGER for the 'id' field, it worked. But after looking at posts in this forum, I noticed that the code in the book, besides using INTEGER for the 'id', also had two other fields, so I dropped the stories table I had created and used the code from the book, which is:

    CREATE TABLE `stories` (
    `id` integer primary key autoincrement NOT NULL,
    `name` varchar(255) default NULL,
    `link` varchar(255) default NULL,
    'created_at' datetime DEFAULT NULL,
    'updated_at' datetime DEFAULT NULL
    );


    That worked without giving me an auto_increment error, so now I'm proceeding with the rest of the book. Hope that helps someone else.

  3. #28
    SitePoint Zealot daveporter's Avatar
    Join Date
    Mar 2002
    Location
    Perth, Western Australia
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to clarify this issue - if people look back at my earlier posts in this thread I think I answer the issue & solve and fix it - but people keep going over the problem time and time again....

    also to Sam - the sql on page 102 is not used permanently - further on the better way to do it using migrations is used.
    So in fact the 102 sql can be ignored and use the ruby script/generate line on the bottom of page 121 instead !

    Dave

  4. #29
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've got to be honest with you, I think this was a really bad idea to put into the book and only causes confusion - even if you do get the code to work!

    The paragraph beneath the code example expresses that you'll be learning migrations later and that there is no need to know what the sql means.

    Then why didn't he just use migrations in the first place and say he'll explain them later??

  5. #30
    SitePoint Zealot daveporter's Avatar
    Join Date
    Mar 2002
    Location
    Perth, Western Australia
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Dalemeko,

    I agree 100% - so as I said earlier, just use migrations and move on.

    Some folk seem to have problems getting sqlite installed, so once you get that issue solved then you can move on.

    cheers, Dave Porter

  6. #31
    SitePoint Member
    Join Date
    May 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried changing to the db directory and then running sqlite3 (without the now unnecessary 'db/' part) and that seemed to work. Here's the commands I used:

    $cd db (from the shovell directory)
    $sqlite3 development.sqlite3
    sqlite> create table stories (
    ...> "id" integer primary key autoincrement not null,
    ...> "name" varchar(255) default null,
    ...> "link" varchar(255) default null,
    ...> "created_at" datetime default null,
    ...> "updated_at" datetime default null);

    (I did run a rake db:migrate command from the root directory earlier, but I'm not sure it affected anything.)

  7. #32
    SitePoint Member
    Join Date
    May 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok.

  8. #33
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samsm View Post

    If you have the stack set up, and want to burn 5 minutes, do this:
    mkdir temporary_folder
    cd temporary_folder
    rails quickapp
    cd quickapp
    ruby script/generate scaffold story name:string link:string
    rake db:migrate
    ruby script/server -p 3003
    The only answer that's worked for me, thanks samsm


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •