I run a insert statement on ruby on rails. But failed. This is the code:
class BookmarkController < ApplicationController
def index
if request.post?
@user_new = Bookmark.new(params[:user_new])
tags = @user_new.tags.split(",")
@user_new = Bookmark.new(params[:user_new])
query = "INSERT INTO bookmark (title , url, tags) VALUES (#{@user_new.title}, #{@user_new.url}, #{tags[0]}) "
Bookmark.connection.execute(query);
end
end
But the output is :
ActiveRecord::StatementInvalid in BookmarkController#index
SQLite3::SQLException: near ".": syntax error: INSERT INTO bookmark (title , url, tags) VALUES (abhir, www.mrabhiram.tumblr.com, tumblr)
Can anyone suggest me the proper way to insert records using SQL insert statement?