Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql2 error #54

Closed
vnguyen13 opened this issue Sep 26, 2012 · 8 comments
Closed

Mysql2 error #54

vnguyen13 opened this issue Sep 26, 2012 · 8 comments

Comments

@vnguyen13
Copy link

Hi again, I'm getting a errors when I go to create a new item or when updating an item.

I have 8 items, their order starts with 0 and goes to 7. When I go to create a new item and hit create, I actually get a routing error:

No route matches {:controller=>"admin/featured_items", :id=>nil, :action=>"edit"}

When I go to update an item, this comes up when I hit Update:

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = 8)' at line 1: SELECT COUNT(*) FROM `featured_items`  WHERE (1 = 1 AND order = 8)

I'm running rails 3.2.8. Have you seen this before?

The item does get does get created. It just gives an error.

@vnguyen13
Copy link
Author

This actually might be related to the fact that I named the column "order".

@swanandp
Copy link
Contributor

You can escape it by using the table name prefix order by table_name.order

On Wed, Sep 26, 2012 at 10:05 PM, vnguyen13 notifications@github.comwrote:

This actually might be related to the fact that I named the column
"order".


Reply to this email directly or view it on GitHubhttps://github.com//issues/54#issuecomment-8896256.

@vnguyen13
Copy link
Author

Thanks for being so quick and responsive. I tried it out and got:

undefined method `order' for "":String

This is what my line looks like:

acts_as_list :column => `featured_items`.order

@swanandp
Copy link
Contributor

Sorry, I should have been clearer. I meant :column => "featured_items.order"

@vnguyen13
Copy link
Author

Getting closer.. now it's saying:

undefined method ``featured_items`.order_was' for #<FeaturedItem:0x110561e48>

@swanandp
Copy link
Contributor

Can you paste your acts_as_list line here?

@swanandp
Copy link
Contributor

It should look like this:

     acts_as_list :column => "`featured_items`.order"

Alernatively, you can also use:

    acts_as_list :column => "`order`"

@vnguyen13
Copy link
Author

Well, fixed by doing two things. Changed the column name to position, and then fixed a routing error I must've had for a long time.

Thanks again for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants