Displaying 20 results from an estimated 10000 matches similar to: "NULLs and model relationships"
2006 May 28
3
Working with topics and categories
Hello guys,
I''m a newbie in RoR and I have a problem. My DB structure is
======================================
topics table : id(int,11)
name(varchar,255)
categories : id (int,11)
topic_id(varchar,255)
name(varchar,255)
======================================
--Models:--
class Topic < ActiveRecord::Base
has_many :categories
end
class
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
2005 Dec 17
3
Can scaffold generate listboxes in views? I''ve been unsuccessful.
I''ve created several different Rails applications but I''m running
into the same trouble with each one. Lets say I create an app called
Test. I type ''rails test'' and it generates the directory for me.
Now I edit my database.yml file. Then I create a database with
Postgresql by typing createdb test. Now I go into Postgresql by
typing ''psql
2009 Oct 15
2
Model.Save causing nil object error
Hello all.
Newbie to rails here and I am having a bit of an issue. I have the
following models:
class Topic < ActiveRecord::Base
validates_presence_of :name
validates_length_of :name, :minimum => 3
has_many :relationship_topics
has_many :relationships, :through => :relationship_topics
end
class Relationship < ActiveRecord::Base
has_many :relationship_topics
has_many
2005 Jul 25
2
acts_as_tree and traversing parent/child relationships
I am working on an Rails application that uses a pretty complex
category structure through out the site. I have defined a table to
house all the info and a FK to reference parents within the table
CREATE TABLE categories (
id int(11) NOT NULL auto_increment,
name varchar(50) NOT NULL,
parent_id int(11) default NULL,
constraint fk_category_id foreign key (category_id) references
2007 Oct 24
7
NoMethodError when creating new ActiveRecord model object
the strangest thing is happening...i''m not getting this every time,
maybe 1/3 of the time, identical requests...
i''m a rails newbie, but i think i''m trying pretty standard stuff, this
is an excerpt from the log:
----------------------
Processing EmailConfigsController#edit_xml (for 127.0.0.1 at 2007-10-24
15:52:09) [GET]
Session ID: 6630219819a2da423d8c48a259dd28d6
2009 Feb 26
0
[cdr_odbc] error: Cannot insert the value NULL into column 'calldate'
Hi,
I am trying to get * log to mssql server. I have odbc and freetds
configured, but my insert query is missing calldate which is a NOT
NULL field in database schema.
cdr_adaptive_odbc: Insert failed on 'sqlserver:cdr'. CDR failed:
INSERT INTO cdr
(clid,src,dst,dcontext,channel,lastapp,lastdata,duration,billsec,disposition,amaflags,uniqueid)
VALUES
2006 Aug 02
2
many-to-one relationship, do I need a second table?
Ok, to keep things short. Im wondering if I need a secondary
relationship table to handle my many-to-one relationships. Here is an
example of what I''ve written down. For instance say I want to find all
of the people in a given location.
class Location < AR:Base
has_many :people
end
class Person < AR:Base
belongs_to :location
end
My SQL tables look like:
CREATE TABLE
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'',
2006 May 30
2
acts_as_tree, acts_as_list and is invincible (help!)
So I have the following model
class Topic < ActiveRecord::Base
belongs_to :topic
has_many :topics, :order => :position
acts_as_tree :order => :position
acts_as_list :scope => :topic_id
end
that I use for a site''s navigation. Everything (list, create, edit, even
the drag&drop sort) works fine, except the destroy function, which the
vanilla version
def destroy
2007 Jan 31
2
has_many :conditions
Is it possible to put conditions relative to the current instance in
has_many''s :conditions?
For example, in a forum app:
class Post < ActiveRecord::Base
belongs_to :topic
has_many :self_and_descendants, :class_name => "Post", :order =>
"lft",
:conditions => "topic_id = #{topic_id} AND (lft BETWEEN #{lft} AND
#{rgt})"
end
With the
2007 Apr 14
0
has_one with reference to the one stored in this object's table?
I''m trying to build a system for generically storing an object graph,
on top of AR itself. The idea is to define one base class, and use
AR''s automatic single table inheritance to have it create the right
class.
Here''s what I have so far:
table generic_objects:
id int(11) not null auto_increment primary key
type varchar(255)
table generic_fields:
id
2009 Mar 08
2
RESTful nested resources and polymorphism?
With ref to my previous post: http://www.ruby-forum.com/topic/180356
I am now able to access items from topics controller. However, now I
need to add sub-item e.g.: An item itself could have many sub-items. So
my items model is like:
class Item < ActiveRecord::Base
validates_uniqueness_of :title, :scope => [:topic_id]
validates_presence_of :topic_id, :title, :owner, :position
2007 Aug 05
0
Newbie - Question on Parent child updating
All,
I''ve just started Rails and Ruby a week or so ago. Please forgive me
for my ignorance. I started writing a small test application to test
some of my new knowledge and have hit a wall. Would like some best
practices.
I have 3 tables, as below...
CREATE TABLE `carts` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`quantity` int(11) NOT NULL,
PRIMARY
2006 Jun 27
1
Help me, I stuck ..
I have three tables and is not allowed to change data scheme:
CREATE TABLE `applicants` (
`id` int(10) unsigned NOT NULL auto_increment,
`fullname` varchar(60) NOT NULL default '''',
`address` varchar(60) NOT NULL default '''',
PRIMARY KEY (`id`)
) ;
CREATE TABLE `positions` (
`id` int(10) unsigned NOT NULL auto_increment,
`position_name` varchar(30)
2006 Apr 20
1
Rails is losing key information
I am using ruby 1.8.4 with rails 1.0 under fedora core 3 on a WIntel
platform.
Rails appears to be losing key information under some circumstances.
Specifically, in the Questions class that follows, the presentation_id
property is apparently being lost.
The STDOUT dump from the create method indicates that the
presentation_id should be 42, but the dump from the database shows that
it is 43,
2006 Jun 23
0
Newbie: where to put input validation and model aggregations
I''m feeling a bit dense and am having a hard time grasping the best way
to implement simple search in Rails. Basically, I just want an input
textbox where a user can type a query which then checks records in the
database ... extremely simple. I already wrote a little ''search''
action in my controller, however I''m trying to stick with the whole
Rails
2005 Dec 31
0
Polymorphic many to many linking
Hi,
I''m trying to create a model where a few objects can all be linked to
each other through a central linking table. Table structure is like
this:
-- model class Computer
create table computers (
id serial,
description varchar
);
-- model Class user
create table users (
id serial,
name varchar
);
-- model class Desk
create table desks (
id serial,
location varchar
);
--
2006 Jan 25
1
Rails day 2: where is my association?
I?m following along a few tutorials on the web and trying to implement
my own example, but I must be missing something because I can?t get
has_many or belongs_to to work like I expected. now I have watched all
the videos and made a cookbook several times with different interfaces.
what I''m looking for is *not* a code snippet to solve something (because
I already have that),
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