ewanmcdougall-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-Mar-10 21:07 UTC
SQL - int not inserted into database correctly
Hello
I''m using writertopia authentication plugin. Looking at the Rails
server output I see the following insert when I call
current_user.has_role ''moderator'' @group
SQL (0.000154) BEGIN
Role Create (0.000424) INSERT INTO `roles` (`name`, `updated_at`,
`authorizable_type`, `authorizable_id`, `created_at`)
VALUES(''moderator'', ''2008-03-10 20:36:37'',
''Group'', 23, ''2008-03-10
20:36:37'')
SQL (0.000497) COMMIT
so far so good. I then check the database and instead of having
roles.authorizable_id = 23 it = NULL.
+----+-----------+-------------------+-----------------
+---------------------+---------------------+
| id | name | authorizable_type | authorizable_id |
created_at | updated_at |
+----+-----------+-------------------+-----------------
+---------------------+---------------------+
| 21 | moderator | Group | NULL | 2008-03-10
20:36:37 | 2008-03-10 20:36:37 |
+----+-----------+-------------------+-----------------
+---------------------+---------------------+
If I execute the SQL for the mysql commandline prompt I get the
expected result and a non null authorizable_id.
Any suggestions about how to go about fixing / debugging would be very
appreciated.
Cheers,
Ewan
P.S I have the same problem using Ruby-based MySQL library that ships
with Rails, as I have using the C-based MySQL library.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
ewanmcdougall-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-Mar-11 10:48 UTC
Re: SQL - int not inserted into database correctly
A new day and I''ve found the problem. Looking further down the Rails server output I discover I''m updating the roles table and inserting the null value, inadvertently. I was temporally changing the association on a model object not realising the changes were save automatically. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---