Displaying 20 results from an estimated 30000 matches similar to: "Some strange questions about SQL"
2006 Mar 19
1
some strange behavior for has_many with STI
Hi all,
I''m having some trouble with a has_many association on a table using
the single table inheritance model that I''m hoping someone can help me
with. The schema for the table is:
CREATE TABLE `comments` (
`id` int(11) NOT NULL auto_increment,
`user_id` int(11) default NULL,
`type` varchar(20) NOT NULL default '''',
`type_id` int(11) NOT NULL default
2006 Mar 21
3
Newbie - ActiveRecord relationships
So I''ve worked through Agile Web Development with Rails and I''m now
trying my first little app to get into the swing of things. Its a task
tracking app where people can create tasks and assign them to others,
and also log time against the tasks.
I''m having trouble working out the model relationships. This is what
I''ve got so far, but its not right as
2006 Apr 06
4
using two foreign keys to the same table
i am working on a task manager with ruby on rails. it is my first major
project, so i''m still gettng my feet wet as i learn.
i''ve been trying to use the built in relationships to link my tables
together, but i''m not able to use the same naming conventions. for each
task, it has a field for the creator, and another field for the
assignee. both of these fields
2006 Apr 02
1
One to Many Relationship Issues
Hi,
I am having issues with a one to many relationship(it never works :-)).
Jokes aside, I am getting an error:
Mysql::Error: #23000Cannot add or update a child row: a foreign key
constraint fails: INSERT INTO adverts (`image_url`, `price`, `title`,
`website_url`, `description`, `user_id`) VALUES(''bb'', 22.0, ''aa'',
2005 Dec 12
2
count sql failing with unknown table....
Hey Rails People,
I''m doing my first Rails app and I''m having a newbie problem with the
count method....
Mysql::Error: #42S02Unknown table ''jobs_sectors'' in where clause: SELECT
COUNT(*) FROM jobs WHERE (jobs_sectors.sector_id = 1 )
Extracted source (around line #4):
1: <div class="sectors">
2: <ul>
3: <% for sector in @sectors
2005 Oct 17
0
acts_as_taggable and per-user tags
I''m trying to add per-user tags to a simple app built atop the
tiny_file example code, as follows:
-------------------------------------------------------------------------------------------------
sqlite> .schema
CREATE TABLE resources (
id INTEGER PRIMARY KEY,
filename VARCHAR(255),
user_id integer
);
CREATE TABLE ''tags'' (
''id'' INTEGER
2005 Dec 23
4
OO model style: inheritance
Hi everybody
I am totally new to rails and I am trying to start a
tiny project to get familiar with rails. But I already
got my first problem and I would be happy if somebody
could point me in the best and cleanest direction.
I am trying to develop a small gallery app. Since I
would like to add more features in future I am trying
to design a clean OO architecture of my models:
The base object
2006 Jun 12
0
struggling with relatively simple out of model updating
I''m trying to do a In/Out thing...
In my in_outs_controller.rb
def edit_in_out
@in_out = InOut.new
@in_out.user_id = params[:id]
@user = User.find_by_id(@in_out.user_id)
if @in_out.save
@user.update_attribute(:in_out, params[:user][:in_out])
flash[:notice] = ''In/Out was successfully updated.''
redirect_to :action =>
2006 Jan 13
4
missing foreign key fields in scaffold views
Is there any reason that foreign key fields do not show in any of the
scaffold views ?
project table:
id serial primary key,
category_id integer,
user_id integer,
name varchar,
morestuff varchar
foreign key (category_id) references categories(id),
foreign key (user_id) references users(id)
scaffold generated views only show name, morestuff fields
2006 Jun 23
2
Foreign key - relations
Hello,
I''ve got DB like this:
(roughly)
create table projects (
id int auto blabla,
name varchar(200),
user_id int,
sales_id int);
create table users (
id int auto..,
name varchar(50));
So project.user_id has a foreign key to user.id - all is good.
Everything works fine.
Now my question..
How can set a relationship from two different fields to the users table
??
Fx.
2006 Mar 15
10
Scaffold with Foreign Key
I have two tables:
------------------------------
drop table if exists users;
create table users (
id int not null auto_increment,
username varchar(100) not null,
password varchar(20) not null,
firstname varchar(20) not null,
lastname varchar(20) not null,
primary key (id)
) TYPE = InnoDB;
------------------------------
drop table
2006 Mar 22
3
Parent-Child Tables Help
can someone help me with this
i have a table
cars
(
id int
model_id int
make_id int
color_id int
description text
constraint fk_cars_carmake foreign key(make_id) references
carmakes(id),
constraint fk_cars_carmodel foreign key(model_id) references
carmodels(id),
constraint fk_cars_color foreign key(color_id) references colors(id)
)
carmakes
(
id int
carmake varchar
)
carmodels
(
id
2006 Jan 22
2
acts_as_taggable: weird SQL problem with untagging
Setup as follows:
class Resource < ActiveRecord::Base
belongs_to :user
validates_presence_of :filename
validates_uniqueness_of :filename, :scope => "user_id",
:message => "already exists, try uploading another file or deleting first."
acts_as_taggable :join_class_name => ''TagResource''
2008 Nov 28
1
Rails Beginner.. NoMethodError
Dear all
I encounter error when I login my Web application
NoMethodError in AdminController#login
undefined method `get_title'' for #<Class:0x63ac78>
Here is part of my code
controller/admin_controller.rb
def login
session[:user_id] = nil
if request.post?
if User.authenticate(params[:name], params[:password])
user = User.find_by_name(params[:name])
2006 Mar 20
1
FileColumn question
Can someone please help me with this.
I have an Images table :-
create table images (
id integer unsigned not null auto_increment primary key,
image varchar(200) not null default ''''
)ENGINE=InnoDB default CHARSET=latin1;
And a car table :-
create table cars (
id integer unsigned not null auto_increment primary key,
user_id integer unsigned not null,
title varchar(100) not
2006 Aug 17
6
NameError in AdminController#index building scaffold
I''m a pretty big newbie with ROR, but when following a tutorial I
encounter an ugly error when building a scaffold. Here is my
environment
Dev system:
- Windows XP
- java version "1.5.0_06"
- MySQL java version "1.5.0_06"
- Ruby 1.8.4
- Ruby Gems 0.9.0
- Gem install mysql
Successfully installed mysql-2.7.1-mswin32
Installing ri documentation for
2004 Dec 21
3
What is sip-friends.sql??????
maybe a dumb question but what do we have here???
sip-friends.sql
#
# Table structure for table `sipfriends`
#
CREATE TABLE `sipfriends` (
`name` varchar(40) NOT NULL default '',
`secret` varchar(40) NOT NULL default '',
`context` varchar(40) NOT NULL default '',
`username` varchar(40) default '',
`ipaddr` varchar(20) NOT NULL default '',
2006 Feb 22
0
Realtime queues with Firebird SQL through unixodbc
Hello,
I have a partially working Realtime Queue using unixODBC and Firebird. I
followed the steps on asterisk-guru and the voip-info asterisk message
boards but have been having no success.
I say that my queue is partially working because callers can join the
queue. However the calls do not go to the agents even if the agent is
not tied up and is available for calls. So the caller is stuck
2006 Nov 27
3
ActiveRecord: Reference same table twice
Hi,
I have 2 tables, "users", and "user_comments". I am trying to allow
users to leave comments on each other''s profiles (eg, think youtube like
this: http://www.youtube.com/profile_comment_all?user=google).
Here is a simplified view of my database schema:
mysql> describe users;
+-----------------+--------------+------+-----+---------+----------------+
| Field
2006 Jul 04
1
LoginGenerator Problem
I am trying to make a barebones login system based on this example
(which in turn is just standard RoR login) but when I enter a user name
and password, it says the login is unsuccessful every time. I am not
sure where I am going wrong. Here is all relevent information
CREATE TABLE `users` (
`id` int(6) unsigned NOT NULL auto_increment,
`login` varchar(20) NOT NULL default