Displaying 20 results from an estimated 600 matches similar to: "building and saving has_many and has_one relations"
2006 Jan 18
5
Inserting the parent Id to the child table
Hi All,
I need your suggestions for the following. I am still learning RoR and
pardon my ignorance.
I have say two tables.
Table A : students
Table B : addresses
Table B has student_id as the foreign key to Table A
If I am displaying the list of students and wanted to get individual
students addresses based on their id, is the only option is to get the
id from students controller method list
2010 Dec 24
1
Running scripts in hadoop
R-help group,
I'm looking for some assistance on using an R-script to read STDIN from
hadoop.
Example, say I have two tables. One is a student table, the other is a class
roster table (tables join on student_id). Student SAT score is in the
student table, whether the student passed or not is in the roster table.
So to determine if a student passed or failed based on their SAT score, I'd
2011 Jan 15
3
has_many :through with Single Table inheritance
I have the following model structure setup.
class User < ActiveRecord::Base
end
class Parent < User
has_many :relationships
has_many :children,
:class_name => "Student",
:through => :relationships,
:conditions => "related_as = ''parent''"
end
class Student < User
has_many :relationships
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
2005 Oct 05
0
has_and_belongs_to_many on legacy DB
I am working with mapping ActiveRecord onto a legacy database. All is going
well (using set_table_name, set_primary_key, etc), but I can''t get my
many<=>many relationships to work.
My contrived example of the situation:
Student has_and_belongs_to_many Teachers. This is mapped via table
student2teacher where the foreign keys are studentId and teacherId. The
primary key in Student
2006 Jan 04
4
HOWTO: Render partial in div
Hey-
I''m using ROR 1.0 and script.aculo.us 1.5.1. I''ve been trying
unsuccessfully to render a partial in a DIV, but can''t seem to get the
right combination of stuff to make it work. There seems to be a few
different ways of going about it. Right now I can render a partial.
What do I need to to render the partial in a div? Here is what it
looks like so far:
#
2006 Jan 06
0
Rails ActionWebService and gSOAP interoperability problem
Hi!
I''ve successfully created a Rails web service. I can connect to it
with an XML-RPC client, without any problems at all. However, when I
try to use a gSOAP application to connect to the web service, it
doesn''t work. The back trace that I get is at the end of this
message. From the back trace, it appears that the SOAP request is not
being recognized as a SOAP
2006 Jan 07
0
gSOAP and ActionWebService interop problems
Hi!
I''ve successfully created a Rails web service. I can connect to it with
an XML-RPC client, without any problems at all. However, when I try to
use a gSOAP application to connect to the web service, it doesn''t work.
The back trace that I get is at the end of this message. From the back
trace, it appears that the SOAP request is not being recognized as a
SOAP request, and
2006 Apr 16
1
Design question: Years/Teams/Students
People,
I want to design a historical sports db for my old school. I think at
the moment it should be like:
A year has many teams
A team has many students
A student has one lastname, firstname and middlename
but a student can also have many teams (eg summer/winter abd over a
number of years) . .
Is there a problem with this? Doesn''t it just mean that there will be a
student table
2013 Jun 22
4
ActiveRecord::Base.transaction - SystemStackError - stack level too deep:
Im having an issue that seems to only happen when trying to use a
transaction. Ive used transactions many times in the past and Im at a loss
as to why im getting the stack level too deep problem.
SystemStackError - stack level too deep:
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:70:in `''
I have a StackOveflow with more detail -
2005 Dec 29
0
Problem destroying some record with relations has_many has_one
Hi guys!
I''m developoning a small web-app, everything goes quickly and well!!
I need some help, im trying to destroy at the same time some records of
varius of my models. My model are relathionate with has_many, has_one.
What could be the best way to do it? Could i use act_as_a_tree or there
are other cool way?
Thanks
P.D: Sorry by my bad english
2008 Apr 11
2
Validating an ActiveRecord object and its has_many :through associations
Considering an object with several has_many :through => associations,
what is the ''best'' way to handle validations?
As an example:
class Student < ActiveRecord::Base
# some attrbutes like
# :name
# :grade
# relationships
has_many :students_assignment, :dependent => :destroy
has_many :assignments, :through => :students_assignment
has_many
2006 Nov 04
0
one to many relationship; has_one
I''m new to ruby and rails and as a result am a bit lost on implementing
a one to many relationship. In my DB I have 2 tables contents and
locations, contents contains the foreign key location_id. I generated a
content and a location model using rails scripts and then edited the
models as follows
class Content < ActiveRecord::Base
has_one :location
end
class Location <
2006 Jun 19
0
has_one frustrations, please help!
Hi everyone. I''ve been bending my head around a has_one association for
about 3 hours now and I can''t get it to work. I''m pretty sure it''s not
something I''m overlooking anymore. Here''s the essential part of the
schema I''m working with:
-----
t :topics
c :id
c :last_post_id
t :posts
c :id
c :topic_id
-----
Topics are simply named
2006 Jun 21
1
ActiveRecord has_one default value
My apologies if this is a dumb question, but I''ve searched around and
haven''t been able to come up with a solution.
Is there a way when specifying a has_one association to specify a
default value for an object if data is missing in the child table. For
instance:
class Student
has_one :university
end
if no university is associated to the student in the database, I would
2006 May 16
1
saving a has_one association question
Hiall,
Say I have
class User
has_one :community
end
class Community
belongs_to :user
end
Will the following work and both save user and community if validation
doesn''t fail?
user = params[:user]
user.community = params[:community]
user.save
Or do I have to do something like the following
user = params[:user]
if user.save
user.community = params[:community]
end
to be on the
2006 May 24
5
where can i find a good tutorial for has_one and belongs_to?
thanks for helps!
--
Posted via http://www.ruby-forum.com/.
2006 Apr 07
2
has_one not using the pk?
Hello,
im trying to wrap a fairly ugly legacy schema using AR. How to handle
normalized informations which aren''t connected via the pk?
create table what (
myid int,
myclass int, ;; references blahclass.blahid
mygender int
)
create table blahclass (
blahid int,
mdesc1 text,
fdesc1 text)
)
I would like to wrap this as
class What < AR::Base
has_one :blahclass
class
2006 Apr 12
0
Sorting with SQL for has_one, belongs_to relationship
I''ve been using this sort helper to have sortable tables.
http://wiki.rubyonrails.com/rails/pages/Sort+Helper
I''ve encountered a situation where I need to sort a column that is not
part of a table, but it''s related table.
For example, say I have db tables called foos and bars. Foos have
fields called name and title. And bars have fields called note and
foo_id. Foos
2006 Apr 15
1
Is this a HAS_ONE bug?
Let''s say I have:
A BELONGS_TO B
B HAS_ONE A (with :dependent=>:nullify)
But this association does not need to exist. In other words, I could
have many A''s and B''s that are not associated in this manner.
Presently, if I try to delete "B":
1. If B is associated to an "A", this works fine and A.my_B is
nullified.
2. If B is NOT associated, I