SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Unknown column

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unknown column

    I am RoR newbie and am having a little trouble. I did a litle messing aroung (tutorials only) with the Thomas/Hansson book last week at work and am now trying to use Ruby at home.

    okay, I was pretty sure Ror was working and decided to go back and do that tutorial from the book again to make sure that everything was working. I got to chapter 7 (catalog display example) and when trying to view http://localhost:3001/admin/edit got stuck with this error:

    Mysql::Error: #42S22Unknown column 'date_available' in 'where clause': SELECT * FROM products WHERE (date_available <= now()) ORDER BY date_available desc

    The thing is, when I do http://localhost:3001/admin/list or http://localhost:3001/admin/edit/#/, the date_available appears.
    I tried rebuilding the Scaffold and Controller without writing over files that I had changed but that didn't work.

    Does anyone understand my problem or have ideas?

    h

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure it exists in your mySQL database? Fire up a mySQL client or dump the schema and post it here...

  3. #3
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    | products | CREATE TABLE `products` (
    `id` int(11) NOT NULL auto_increment,
    `title` varchar(100) NOT NULL,
    `description` text NOT NULL,
    `image_url` varchar(200) NOT NULL,
    `price` decimal(10,2) NOT NULL,
    `date_available` datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

    I got this by running a show create table products from the command line. I'm not sure why it says "|products|"... does that make a difference?

    It's strange, though, because, like I said, it works for new and edit.

    h

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is weird. I'm not sure, sorry! But I made this post to be with you on the fact that its very weird.

  5. #5
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, this is weird. I can add, view and edit items (from my ruby demo ap), but when I go to check the table from the command prompt or mysql query browser nothing comes up! I checked the config file and it's set to the same thing that I use to login to the db the othe two ways.
    Any ideas?

    Thanks

  6. #6
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you're in the correct environment? (debug, production)

  7. #7
    SitePoint Zealot Xavius's Avatar
    Join Date
    Sep 2005
    Location
    Toronto, Canada
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe check out the RoR website, perhaps others have had this problem?

  8. #8
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry if this is missing the point (it is certainly side-stepping your question) but why would you want to go to an edit page without a record in mind?

    Has the scaffold been updated to include a response to edit without an id?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  9. #9
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I put edit/# with the pound in itallics (hard to tell) meaning any number. I suppose I could have put a real number. Sorry for any confusion.

  10. #10
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess I'm confused.

    So are you saying:
    admin/edit/# doesn't work
    admin/edit/#/ does
    ?
    Quote Originally Posted by bimo
    when trying to view http://localhost:3001/admin/edit got stuck with this error:

    ...

    when I do http://localhost:3001/admin/list or http://localhost:3001/admin/edit/#/, the date_available appears.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  11. #11
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If that is what he really is saying that wouldn't it be making sense that hes getting some sort of error? I'm not too familiar with scaffolding because I don't use it much but what does edit do when there is no ID passed to it?

  12. #12
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    samsm, the url has nothing to do with my problem. When I said

    I put edit/# with the pound in itallics (hard to tell) meaning any number
    I meant 'admin/edit/1', 'admin/edit/2', 'admin/edit/3', 'admin/edit/4', etc, etc.

    I was using the pound character (#), in the discussion only, not in real life, as a variable. Sorry for any confusion

    Anyway, I figured out my problem. It turns out that I updated a column name in the production db but not the development db, thinking that changes to the production db would cascade to test and development.

    Dumb of me but I'm new at this

  13. #13
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Migrations might interest you: http://wiki.rubyonrails.com/rails/pa...dingMigrations

    If anything, changes would propagate from development to production: it is rare that you have a web appin production, then develop it!

    Douglas
    Hello World


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
  •