Displaying 3 results from an estimated 3 matches for "my_table_nam".
Did you mean:
my_table_name
2007 Aug 30
1
belongs_to with foreign keys that reference non primary key columns
Hello,
I have a situation where the foreign key into a table doesn''t
correspond to that table''s primary key:
my_table
-------------
id (pk)
name
...
other_table
--------------
id (pk)
my_table_name (fk references my_table(name))
...
I want to be able to say something like:
class OtherTable < ActiveRecord::Base
belongs_to :my_table, :foreign_key => { :my_table_name => :name }
end
OtherTable.find(:first).my_table
Is this possible? If not, what is the reasoning behind the decisio...
2014 Jun 30
1
Getting data from Table in RStudio
...d use to do so. However, i had proceeded to add a dataset to RStudio using the following code:
library(RODBC)
dsn.name <- "MySQLlocal"
user.name <- "orange"
pwd <- ""
ch <- odbcConnect(dsn=dsn.name,uid=user.name,pwd = pwd)
res <- sqlFetch(ch, "<my_table_name>")
odbcQuery(ch, "Select * from <my_table_name>")
odbcClose(ch)
When the code is run all that is returned is
> library (RODBC)
> dsn.name <- "MySQLlocal"
> user.name <- "orange"
> pwd <- ""
> ch <- odbcConnect(d...
2007 Aug 30
3
has/belongs to many sql error
I have a model Asset which has_and_belongs_to_many :tags. Tag has only
one field, name. There is a table assets_tags which only has an
asset_id and a tag_id.
I can add a tag to one asset. If I try to add the same tag to another
asset though (asset.tags << tag) I get this error:
Mysql::Error: #23000Duplicate entry ''4'' for key 1: INSERT INTO
assets_tags (`tag_id`, `id`,