Displaying 14 results from an estimated 14 matches for "entity_id".
2006 Jan 18
6
Using conditions in ActiveRecord
This bit of code finds several groups; all those which have
entity_id''s of ''1'' OR ''2'' OR ''3'', as you would expect:
ee = [ 1, 2, 3 ]
groups = Group.find(:all, :conditions => "entity_id in (" + ee.join
(",") + ")")
But this bit of code only finds groups which have entity_...
2006 Jan 31
4
has_one without inverse belongs_to
...alled users_id that contains the user
id of the user that created the entity.
In entity I have...
has_one :user
... as I want to be able to show the user who created the entity from
the entity object.
But this produces the following error...
Mysql::Error: #42S22Unknown column ''users.entity_id'' in ''where clause'':
SELECT * FROM users WHERE (users.entity_id = 1) LIMIT 1
...Where I want it to select users by users.id.
What do I do? I bet it is easy.
Martin
--
Posted via http://www.ruby-forum.com/.
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
...messages"
WHERE ("private_messages".user_id = 1061 AND (message_type = ''draft''))
SQL (0.6ms) BEGIN
Person Load (0.9ms) SELECT "people"."id", "people"."first",
"people"."last", "people"."entity_id", "people"."user_id" FROM
"people" WHERE ("people".user_id = 1061) LIMIT 1
UserRole Load (6.1ms) SELECT DISTINCT "user_roles".role_name FROM
"user_roles" WHERE ("user_roles".user_id = 1061)
SQL (1.5ms) UPDATE "use...
2007 Feb 12
2
Objects in Arrays? Allowed, right?
Hi:
I''m trying to manually append objects to an instance variable that is
just an array of objects. Here''s my controller code:
@tasks = Task.find(:all, :conditions => "entity_id =
#{session[:user].id}")
for t in @tasks
if Subtasks.find(:first, :conditions => "child_id = #{t.id}") != nil
@mtasks << t
end
end
However, when I execute, I get an error:
You have a nil object when you didn''t expect it!
You might have expected an instance...
2009 Feb 15
3
conditions on association include, hacky but more or less solved
...s would be represented by a condition in the join clause:
...
FROM `traits`
LEFT OUTER JOIN `trait_values` ON trait_values.trait_id = traits.id
LEFT OUTER JOIN `key_factors` ON key_factors.trait_value_id =
trait_values.id
AND
key_factors.entity_id=@entity.id
There are two steps to getting this effect. First, you have to get the
associations to load in a single query. Second, you have to get the
condition into the join clause.
By default in 2.2.2 associations are loaded in follow up queries.
That is, for
@traits = Trait.find :all,...
2006 Jul 20
2
a rails model question
Hi all,
I am a newbie in ruby/rails.
I have a question about my database model:
table1: entities (name, description, author_id ...)
table2: relations (source_id, target_id, relation_type) (it describes
the relations between 2 entities and the relation type)
How can I define models using rails, or do I need to redefine my
database schema?
thank you
--
Posted via http://www.ruby-forum.com/.
2006 Mar 04
2
Using Migrations to Build a MySQL FULLTEXT index?
Can anyone point me to the proper syntax to build a FULLTEXT MySQL
index via migrations?
I''m really liking these things, and don''t want to step back into the
world of manual intervention.
2009 Dec 15
0
Problems reloading plugin extending AR model
...cations/blob/master/lib/madb_notifications_lib.rb#L8
Entity.class_eval do
def user_subscribed_to_creation?(user_id)
NotificationSubscription.find(:first, :conditions => [
"source_filter = ? AND event = ? and source_type = ? and
destination_type = ? and destination = ?", {:entity_id =>
self.id}.to_yaml , "after_create", "Instance", "user", user_id.to_s
])
end
end
and this is then used in a view of the plugin, where @entity is an
instance of the model Entity:
http://github.com/dedomenon/madb_notifications/blob/master/app/views/madb_notifi...
2006 Aug 03
0
How to create/save unary (pk-only) models
...o |t|
end
class Entity < ActiveRecord::Base
has_many :entity_members
end
create_table "entity_membership", :force => true do |t|
t.column "person_id", :integer, :null => false
t.column "role", :string, :null => false
t.column "entity_id", :integer, :null => false
end
class EntityMembershp < ActiveRecord::Base
belongs_to :entity_member
belongs_to :person
end
The entity id is needed to link the aggregation to various other
models, but there''s no other information that can or should be
associated wi...
2008 Apr 08
1
Help with primary_key_prefix_type
...ot;entity_name" varchar(40) NOT NULL, "entity_legal_name" varchar(120) NOT
NULL, "entity_legal_form" varchar(4) NOT NULL, "created_at" datetime
DEFAULT NULL, "updated_at" datetime DEFAULT NULL);
But I expected to see this:
CREATE TABLE entities ("entity_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT
NULL,...
It makes no difference if I pass the value to
config.active_record.primary_key_prefix_type as a string or a symbol as
neither works.
So, what am I doing wrong?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~---...
2006 Jun 11
4
[Question} how best to use attribute driven db with Rails
I designed out a mostly attribute driven database. Originally i was
going to use PHP, but have now decided to use RoR. Being able to use the
built in OR functionality would be nice, but I am not sure how well it
melds with attribute dbs.
If anyone can give me some pointers, I would really appreciate it
(especially since this is my first endeavor and on an important project
as well).
2008 Mar 08
9
Validation error handling on related models
I have 2 models, entity and client. Entity has_one client and client
belongs_to entity.
Entity has attributes name and legal_name. Entity also has an unique
index on (lower(name)). The pKey for both is the conventional Rails id.
Client has a fKey constraint on entity_id and is indexed in entity_id.
In controllers/clients_controller.rb I have:
# GET /clients/new
# GET /clients/new.xml
def new
@client = Client.new
@entity = Entity.new
respond_to do |format|
# new.html.erb
format.html { render :template => ''clients/edit.ht...
2006 Jul 04
8
inherits_from: Multiple table inheritance
Hey guys,
I just implemented very simple and primitive class table inheritance in
ActiveRecord. The goal is for this to become mature enough to become a
true feature in Rails. Check it out here:
http://guest@blog.raylucke.com/svn/inherits_from
Here?s how it looks in action:
create_table "books", :force => true do |t|
t.column "product_id", :integer
t.column
2006 Apr 22
9
one to many question
...s
acts_as_tree :order => "name"
#...
end
class Product < ActiveRecord:Base
#...
has_and_belongs_to_many categories
#...
end
class Image < ActiveRecord:Base
#...
# ??
#...
end
Lets say the image table sql looks like this:
create table images (
image_id int not null,
entity_id int not null,
entity_type varchar(20) not null,
image_path varchar(255) not null,
image_type varchar(20) not null,
primary key(image_id)
);
For example if i were to store the "BIG", "SMALL" images for a category
in the above table, I would do:
insert into images values(1...