Displaying 20 results from an estimated 33 matches for "location_id".
2006 Aug 02
2
many-to-one relationship, do I need a second table?
...id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(255),
created_at DATETIME,
updated_at DATETIME,
PRIMARY KEY (id)
) TYPE=''InnoDB'';
CREATE TABLE `people` (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(255),
created_at DATETIME,
updated_at DATETIME,
location_id INT UNSIGNED,
FOREIGN KEY (location_id) REFERENCES locations(id),
PRIMARY KEY (id)
) TYPE=''InnoDB'';
And so, to describe my question, Im wondering if I need the secondary
relationship table (like a has_and_belong_to_many relationship) in order
to search for people by locati...
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'', [["Select a Location", ""],["",
""]] + Location.find_all.collect { |l| [ l.name, l.id ] } %>
</div>
This starts the drop-down menu with a nu...
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 can access a system valid time like this :
@systemMessage.syste...
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 < ApplicationController
def login
# load user info and set location
@session[:user] = User.find_by_username_and_password(...)
@session[:user].location_id = @params[:location_id]
end
end
Chris
_______________...
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.
This is in the view:
<% Location.find(:all).each do |locat...
2010 Dec 14
5
Build associated model confusion
...g (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 dives. Currently the
foreign key is on dive as location_id.
How do I properly, in my dives_controller, generate the location, get
the ID, and pass it on to my new dive? It would be nice to have the
constructor of Location called, but if it doesn''t work that way, then
that''s okay too.
My code is below:
Thanks.
--
Melih O.
http://www.onv...
2008 Apr 23
1
Validation dependent on unsaved parent
...dered for a location
end
class Order < ActiveRecord::Base
has_many :line_items, :dependent => :destroy
belongs_to :location
end
class LineItem < ActiveRecord::Base
belongs_to :order
belongs_to :item
def parlevel
if self.order
Parlevel.find(:first, :conditions => {:location_id =>
self.order.location_id, :item_id => self.item_id})
else
nil
end
end
def validate
if self.quantity_requested
if self.parlevel
limit = self.parlevel.quantity
else
limit = 0
end
errors.add(:quantity_requested,"above maximum...
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` LIMIT 1
[2011-09-27 10:05:11|main|debug] Unit Load (3.0ms) SELECT * FROM
`uni...
2006 Jun 07
10
habtm "AND" find conditions
I have two tables and a join table for them
e.g. books, authors in a many to many relationship (habtm) and a join
table books_authors.
I can successfully search for a book that has
"author.id = 2 OR author.id = 4"
but I am unable to search for
"author.id = 2 AND author.id = 4"
This is because the result of all the joins only has one author.id
column so no single row has
2006 Dec 29
3
Functional test a "create" action when a validation fails
I''m trying to write a functional test of a "create" action in one of my
controllers. In the corresponding model I have a
"validates_uniqueness_of :location". In the test case I am
constructing I have the create fail with the error "Location has
already been taken". Is there a way I can write an assertion like:
assert_equal "Location has already been
2006 Jul 07
4
How to add Asia token analyzer to ferret simply?
Hi,David
Can you give me an example of how to add analyzer to ferret to Asian
languages?
My web application will have to support multi language search,which
means,for example,both Chinese and English will be searched through the
form.
Currently,I have decided to use the simple token principles,which means
that every Chinese character will be a token,although this is not so
well in some
2010 Dec 23
0
has_many :through full stack help
...en I save. I have included below what I think is relevant, I
am beyond just hints at this point, I need help with the code itself -
just cant get it to work. THANK YOU THANK YOU if you can help
-------PRACTICE MODEL-------
class Practice < ActiveRecord::Base
attr_accessible :name, :tax_id, :location_ids, :employee_ids, :system_ids
has_and_belongs_to_many :employees
has_and_belongs_to_many :locations
has_many :implementations
has_many :systems, :through => :implementations
validates_presence_of :name, :tax_id
end
-----SYSTEM MODEL-------
class System < ActiveRecord::Base
at...
2006 Nov 04
0
Problems with ActiveRecord, Oracle adapter, find_by_sql, multi-table join - ORA-04043 error
...schema.cust_loc cl, schema.location loc
WHERE e2.equipment_id = e1.equipment_id
AND e2.some_column like ''SOME_VAL%''
AND e1.equipment_id = ne.net_element_id
AND ne.class_name = ''FooBar''
AND e1.building_id = b.building_id
AND b.main_address = cl.cust_loc_id
AND cl.location_id = loc.location_id
So, I setup a class for the ''Location'' table like this:
class OracleLocation < ActiveRecord::Base
establish_connection(
:adapter => "oracle",
:database => "our_db",
:username => "user",
:pass...
2007 Jun 08
0
Advanced search
I like the simple search of ferret; I would like to take this one step
further and do an advanced search; the user will type in key words and
use a drop down box to select the location; now how to pass this
location_id to the ferret search so it searches key words only on
matching records with same location_id?
thanks
--
Posted via http://www.ruby-forum.com/.
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 < ActiveRecord::Base
belongs_to :content
end
When I attempt to access content.location I get this error
|R...
2007 Jul 25
17
DRb not starting
...:product_description=>{},
:product_label_description=>{},
:product_label_free=>{},
:product_product_id_supplier=>{},
:product_description_supplier=>{},
:supplier_description=>{},
:pub_date_sort => {:index => :untokenized_omit_norms, :term_vector =>
:no},
:location_id => {:index => :untokenized},
:tab => {:index => :untokenized}},:remote => false})
THis will do the ferret locally without the DRB server. Works ok.
If I change this to:
class Mutation < ActiveRecord::Base
acts_as_ferret ({:fields => {:description=>{},
:product_id=&g...
2008 Jun 12
1
unidirectional belongs_to polymorphic
...them. Or, more
specifically, the headache involved with the many-to-many and the
caching and everything isn''t worth the cost. I just want to be able
to store a location for a Person (and for various other models that
are unrelated to Person).
Some questions:
Why does Person need both a location_id and a location_type? In order
to instantiate the location, it needs to look up the whole row in the
locations table, which includes a "type" column (as required by single
table inheritance).
Why won''t the new sexy fixtures work on this (regardless of whether
Person has a locati...
2005 Dec 12
2
count sql failing with unknown table....
...text NOT NULL,
`start_sallary` float NOT NULL default ''0'',
`end_sallery` float NOT NULL default ''0'',
`created_at` datetime NOT NULL default ''0000-00-00 00:00:00'',
`valid_on` datetime default NULL,
`invalid_on` datetime default NULL,
`location_id` mediumint(9) NOT NULL default ''0'',
`user_id` mediumint(9) NOT NULL default ''0'',
`type_id` mediumint(9) NOT NULL default ''0'',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `sectors` (
`id` int(10) unsigned NOT...
2006 May 24
4
AR foreign key problem.
Hello Railslist,
(I''m using RadRails 0.6.3 on Windows XP with Ruby 1.8.4, Rails 1.1 and SQLite3)
I have two tables in the database: "locations" and "customers":
customers.sql
---
id INT PRIMARY KEY
name VARCHAR 255
address VARCHAR 255
postal_code VARCHAR 255
city VARCHAR 255
---
locations.sql
---
id INT PRIMARY KEY
postal_code TEXT
longitude FLOAT
latitude FLOAT
2006 Mar 11
0
Using :joins - How to help Rails populate a list of records from a complex join
...39; +
''c.id = col.county_id AND '' +
''s.id = l.state_id AND l.state_id = ? AND '' +
''g.id = l.group_id AND '' +
''sc.location_id = l.id'',
state, state, state],
:joins => ''s, counties c, colonies col, locations l,
groups g, schools sc'',
:select => ''c.*, col.*, l.*, g.*, sc.*''
end
Basically, it searches for school...