Displaying 20 results from an estimated 500 matches similar to: "one to many relationship; has_one"
2006 Feb 06
3
linked table confusion
placement.rb
has_one :client
has_one :case_manager
client.rb
belongs_to :case_manager
has_many :placements
case_manager.rb
has_many :clients
has_many :placements
I am trying to create a view file for placements.
I can pull columns from clients table in this view by using...
<%= @placement.client.wholename %>
but if I use
<% @placement.case_manager.wholename %>
2011 Sep 27
0
has_many with :finder_sql returns [nil]?
Is it supposed to do that? I find it very confusing.
AR 3.0.10
class Unit
has_many :units, :finder_sql => proc {
"SELECT * FROM `#{table_name}` WHERE `location_id`=#{id} AND
`location_type`=#{Location::UNIT}" }
end
Both should return []. However...
>> Unit.first.units.find([1000000])
[2011-09-27 10:05:11|main|debug] Unit Load (4.0ms) SELECT `units`.*
FROM `units`
2006 Feb 03
9
Because I''m very slow - trying to use console
I can''t see how to use variables so I am using console to test things
out...
clients table - a column named first_name
My very brief console session...
>> clients = Client.find_by_sql("select * from clients where first_name
= FN")
ActiveRecord::StatementInvalid: RuntimeError: ERROR C42703 Mcolumn
"fn" does not exist Fparse_expr.c L1034
2006 Apr 14
1
Script.aculo.us Effects with callbacks not working as it should.
Hello all!
I''m having a problem which is driving me insane.
It''s probably related to the fact that I''m new to javascript.... :)
Here''s the thing, I have a couple of effects which are all being put
in the queue.
Some of these effects have callbacks; e.g. "afterFinish".
But the calback is being made directly instead of after the effect is done.
The
2006 Mar 14
4
has_one
I''ve got an order model that stores order data.
One piece of data is a credit card type, which is a digit 1,2 or 3.
I have a cardType model that has an id, shortName and LongName for the
credit card merchant (visa, mastercard, amex).
I want to be able to say: order.cardType.shortName, but can''t seem to
get has_one working. It works with has_many and a finder_sql statement
on
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
2005 Nov 03
0
AR model and virtual attributes
i have a need to create a ''virtual'' attribute. Is the following possible?
class User < ActiveRecord::Base
# user things are owned by user at his selected location
has_many :owned_things, :class_name => "Thing", :conditions => ''user_id =
#{id} and location_id = #{location_id}''
attr_accessor :location_id
end
class AccountController <
2008 Jan 09
0
problem with checkboxes updating table
I''m having issues getting checkboxes to update a cross-reference table
correctly. I keep seeing entries in the locations_users table, for
location_id and user_id, "11" and "2", respectively. The user id is
fine, but there is no such location with id 11. There are only 5
locations and their ids go from 1-5! I can''t seem to find where the 11
is coming from.
2005 Nov 23
0
Another CTI question
I''ve asked some CTI questions before and I have another one based on
my migration progress.
These are two condensed tables (the actuals being bigger):
Content
+-------------+
| id |
| title |
| description |
| etc..... |
+-------------+
ContentJob
+--------------+
| content_id |
| location |
| date_expired |
| etc..... |
+--------------+
The above is
2006 Mar 17
2
Security issue dealing with comment posting - anyone?
This is how I''m posting comments currently. This works, but I read
somewhere that I shouldn''t inject params right into my sql query,
because it makes it easy for people to hack in and ruin the db. I''m not
sure if this even makes sense, but I''ve tried other things, and can''t
get anything else to work.
#currently
def comments
content =
2006 Mar 13
5
Displaying related entries by tags - HELP!
Ok, my site is setup like pretty much every other blog out there. A
list of the most recent 5 posts, then by clicking one, you go to an
individual post page, displaying the full context of that post.
Now, what I would like to do is to display the related entries in the
side column, which is part of the layout, based on the tags belonging to
that specific entry.
Here''s my coding so
2006 Jun 26
2
How can I sort options in a select box?
Pretty much a newbie here, looking for help on select boxes in forms....
Is there any way in the view to sort the options of a drop-down select
box?
My current code (within a larger _form.rhtml file) is:
<div class="form-element">
<label for="asset_location_id">Location</label>
<%= select ''asset'', ''location_id'',
2008 Jul 09
2
build matrix with the content of one column of a data frame in function of two factors
Hello,
First, thanks for your help (and sorry for my english !)
I have a data frame in which each row represents a vote (in percent, only
20,40, 60,80,100) of one person on one content, with three columns : name
(the name of the voters), content_id, vote :
str(votesredac)
'data.frame': 1000 obs. of 3 variables:
$ name : chr "Guillemette Faure" "Guillemette
2006 Mar 16
4
Table Relationships Problems.
I have the following tables setup:
locations
:id
:name
systemmessages
:id
:name
systemmessage_validtimes
:id
:name
:systemmessage_id
:location_id
:start
:end
The systemmessage_validtimes has a ''has_many'' relationship with
systemmessages, meaning that there could be many valid times for each
system message.
@systemMessage = Systemmessage.find(1)
E.g. I
2006 Nov 04
0
Problems with ActiveRecord, Oracle adapter, find_by_sql, multi-table join - ORA-04043 error
Hi all,
Windows XP
Oracle 10g client
OCI8 0.1.16
Ruby 1.8.5
Rails 1.1.6
I''m hitting weird behavior with the Oracle adapter and a find_by_sql
call on a multi-table join.
The SQL looks like this:
SELECT DISTINCT e1.ip_address, loc.street, loc.city, loc.state
FROM schema.net_element ne, schema.equipment e1, schema.equipment e2,
schema.building b, schema.cust_loc cl, schema.location
2010 Dec 14
5
Build associated model confusion
I''m new to Rails3, and I''m just trying to get one last thing to work
before I call it a night. The situation is the following (please if
the code is horrible, just let me know, still learning):
I want to log a dive. I might have a new location on that dive at
which point I have to create a new Location, and then create the dive.
A dive has_one location. A location has_many
2006 Mar 01
2
active_record postgresql adapter problem
Instead of using numeric I created the field "unit_price" as PostgreSQL
type money. Now when I try and add a row I get the following. How do I
override AR default behaviour to cast numeric post data to money, or am
I forced to only support database types that active_record knows about?
RuntimeError: ERROR C42804 Mcolumn "unit_price" is of type money but
expression is of
2006 May 28
1
ActiveRecord: FK constraints problem
Hi all.
I have has_and_belongs_to_many association between models: Section and
Content.
class Section < ActiveRecord::Base
acts_as_tree
has_and_belongs_to_many :contents
belongs_to :default_content, :class_name => ''Content'', :foreign_key =>
''default_content_id'', :dependent => :nullify
end
class Content < ActiveRecord::Base
belongs_to
2006 Apr 18
0
custom content widget design
Hello all,
I am trying to design a reusable widget content system, where I can easily lay
out a bundle of widgets on a page and allow a user with proper administrative
rights to click and change them.
For the database storage, I don''t want to have to create a new table for every
different classification of widget (ie, list, text body, image, etc). I
would like to create a central
2008 Apr 23
1
Validation dependent on unsaved parent
I''m having trouble with a validation that depends on an attribute of a
belongs_to parent. If the child is added to an unsaved parent
(parent.children << new child), the has_many collection
parent.children includes the unsaved child. However the belongs_to
attribute child.parent appears to be nil until the parent has been
saved. Without access to the parent attributes, the validation