I will make simpler than it is to get the answer I need without make you read a lot of code.
MySQL stored procedure:
CREATE PROCEDURE add_player
(IN name varchar(100),
IN isTrue boolean)
BEGIN
START TRANSACTION;
insert into tags (name,is_player) values (name,isTrue);
COMMIT;
END //
player_controller.rb
ActiveRecord::Base.connection.execute("call add_player('#{name}', #{is_player})")
Two problems I see(if you see more - say):
- if
name
contains'
it breaks the call - sql injection - I don't use
?
as parameters when I call the stored procedure. The reason is that it's just not working when I'm try with?
. I tried also change it toPlayer.where("add_player(?,?)",name,is_player)