Displaying 20 results from an estimated 20000 matches similar to: "comments for joel about rails in software discussion"
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 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 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 Jun 07
1
has_many, through, want to store email in mysql
Hi,
I''m still a new with ROR, but it''s really cool :) I just have this
problem with a project of mine.
I want to store email in a database. I already wrote a simple import
script, that works, so that''s not a problem. Showing the email
(efficiently) in a ROR site is.
These tables are in the database:
emails
id
email_id (foreign key -> emails.id)
seq
2010 Jan 25
0
has_many, :finder_sql, setting attributes
Hi all,
My question is somewhat complicated, but bear with me. My project has a
number of models: User, Program, and Team. Users belong to multiple
Programs. Programs have multiple teams, but Teams belong to one
program. For each Program a User belongs to, he can belong to multiple
Teams. (Think of this in an athletic context where users are athletes,
programs are universities). So my
2006 Jun 17
2
how to delete a parent record and child records?
Wow, got myself lost as *soon* as I left the hand-holding exercises in
the books.
I''m trying to set it up so when I click the (scaffold-generated)
''destroy'' link on one (of a list) of parent MySQL records, the children
records in a different table get deleted also.
Very simple setup: my tables are ''customers'' and ''accounts''
class
2006 Jul 13
1
How to create a child from a parent
Hi i am trying to figure out what is the best way to do this very basic
thing:
lets say i have two tables: one with parents and one with children.
there is a one to many relation between them.
I scaffolded the parents tabel and i can open each parent. Now i want to
add a link to the ''show'' view which will create a new child record.
In the model i defined the has_many and
2012 Jun 07
2
load_missing_constant: Expected to define class in module
Hi I''m having some weird issues with Rails 3 and classes defined in
modules.
To be more precise I''ve created several files that define classes in the
AppBase module like:
module AppBase
class BackendMenu
[content omitted]
end
end
When a page tries to use the BackendMenu class like AppBase::BackendMenu
I get an error saying "Expected backend_menu.rb to define
2006 Apr 09
1
Join using :THROUGH - SQL is wrong even when using :SOURCE
Here''s a join table for an educational institution:
create_table "student_appointments", :force => true do |t|
t.column "supervisor_id", :integer, :default => 0, :null => false
t.column "student_id", :integer, :default => 0, :null => false
t.column "course_id", :integer, :default => 0, :null => false
[other columns
2006 May 28
7
Self-referential has_many :through relationship
Hi,
I have a self-referential has_many :through relationship setup to
track relationships between users. Basically relationships are
modeled as a join table with an extra column ''relation''.
create table relationships (
user_id integer unsigned not null,
friend_id integer unsigned not null,
relation char(1) not null,
)
--- relations ---
f = friend
r = request to
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 Jan 11
0
Easy Question, I Think
I am just getting started with Rails, don''t know any Ruby, and don''t
quite even get object oriented programming yet. I have tweaked my
schema to The Rails Way and have generated a bit of scaffolding.
I am trying to create a new Part, which references a PartName and a
PartNumber. I can create a PartNumber on the fly, but the PartName
has to exist. I have an inelegant solution
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 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
I am just getting started with Rails, don''t know any Ruby, and don''t
quite even get object oriented programming yet. I have tweaked my
schema to The Rails Way and have generated a bit of scaffolding.
I am trying to create a new Part, which references a PartName and a
PartNumber. I can create a PartNumber on the fly, but the PartName
has to exist. I have an inelegant solution
2006 Dec 27
0
HABTM Checkboxes - Adding/Updating Users to a Project
Hello all,
I''m trying to create a HABTM checkbox action that adds/updates ''users''
to a ''project''.
I have the following laid out.
---------------------
TABLES
---------------------
create_table "assignments", :id => false, :force => true do |t|
t.column "project_id", :integer, :default => 0, :null => false
2006 Mar 22
0
Another Problem with params
I am trying to do a similar thing for some spares that I am trying to manage...
My spare.rb file is as under
class Spare < ActiveRecord::Base
belongs_to :department, :class_name => ''department'', :foreign_key
=> ''department_id''
belongs_to :subequipment, class_name => ''subequipment'',
:foreign_key =>
2006 Feb 02
1
circular table refs in activerecord
I cannot find this anywhere, and it is holding up a project. I have a
*very* simple rails app with three tables, one of which is the users
table:
users:
Column | Type | Modifiers
---------------+-----------------------------+-----------------
id | integer | not null default nextval(''public.users_id_seq''::text)
login
2010 Dec 30
3
rake db:seed with has_many through (m:n with seperate table)
My model consists of users and tasks (m:n), the relation is stored in a
seperate table sharedtabs (that contains some extra fields).
Between tabs and tasks there is a 1:n relation.
I have trouble writing my seed.rb:
works: (1)
tab = Tab.create(:name => ''Admin'', :category => 0)
tab.tasks.create(:name => ''Admin_Tab1_Private Task 1'')
works: (2)
2006 Jan 30
1
Multiple associations between tables - do they ever work?
This is really bugging me. How can I get a second association to work
between 2 tables.
I have two models, User and Article. A user has many articles, and an
article belongs to one user. Then I have the "current article", which
is a the article that the user is currently viewing/editing. I want to
track/save this value, so they can come back to the same article if they
log out
2006 Aug 16
0
Creating a comments system for multiple types of
It sounds like you want a polymorphic association -
class Party < ActiveRecord::Base
has_many :comments, :as => :commentable
end
class BlogEntry < ActiveRecord::Base
has_many :comments, :as => :commentable
end
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
then include columns ''commentable_id'' and