Displaying 11 results from an estimated 11 matches for "b_id".
Did you mean:
cb_id
2006 Nov 04
2
sql query in active record
hi all,
if i want to write a query select * from a,b where a.b_id=b.id in active
record
using joins,condition how can i write that
in docs i found for conditions you do by giving "?" and then the parameter
eg. a.b_id=?
but it takes b.id as string i.e a.b_id=''b.id''
i dont want that
any suggestions
thanks in advance
regar...
2011 Apr 11
4
Printing field attributes outside the model.find_by_sql
Hi All,
I have Model called pays..and it has fields like(id, topic, subject,
created_at, b_id) and i also have a Model called suggests with
fields(id, income, price, b_id)
In my ruby on rails action or method Controller:
def print_two_table
@p = Pay.find_by_sql("SELECT p.id, p.topic, s.id, s.income, s.price FROM
pays as P LEFT OUTER JOIN suggests AS s ON s.b_id = p.b_id WHERE
p.cre...
2006 Feb 28
4
multiple keys table
probablly a newbie question:
Rails does not support a table with multiple keys ???
it seems that the ActiveRecord set_primary_key method can only set the
column name... (hope i''m wrong there)
example:
table A - P.K id, string name
table B - P.K id, string name
table C - P.K a_id and b_id, both are also foreign keys.
Thanks,
Amir.
--
Posted via http://www.ruby-forum.com/.
2006 Dec 30
2
search on multiple table
Hello,
I am trying to make a search, using acts_as_ferret on a
has_and_belongs_to_many relation :
class a < ActiveRecord::Base
belongs_to :b
has_and_belongs_to_many :c
Joboffer.find_by_contents( query +b_id:1 ) is working fine
but
Joboffer.find_by_contents( query +c:1 ) is not working
Here are the tables descriptions:
Table a have field : id, b_id
Table b have field : id, name
Table c have field : id, name
Table c_a have field :a_id, c_id
Any idea on how to include c on my search ?
--...
2006 Jan 27
1
"Conditional" match?
I have two datasets, big and small.
s_date<-c(?2005-12-02?, ?2005-12-01?,
?2004-11-02?,?2002-10-05?,?2000-12-15?)
s_id<-c(?a?,?a?,?b?,?c?,?d?)
b_date<- c(?2005-12-31?, ?2005-12-31?,
?2004-12-31?,?2002-10-05?,?2001-10-31?,?1999-12-31?)
b_id<-c(?a?,?b?,?c?,?d?,?e?,?c?)
small<-data.frame(date_=as.Date(s_date),id=s_id)
big<-data.frame(date_=as.Date(b_date),id=b_id)
For each row in ?big?, I want to look for a match in
small where two conditions are met:
a. big$id=small$id
b. big$date_>=small$date
If match is found, I wish...
2006 May 17
2
Association data clobbering (foreign keys too?)
Can someone please confirm or correct the following statements?
If I have the following tables
create table as (id int, [...], b_id int);
create table bs (id int, [...], a_id int);
create table as_bs (a_id int, b_id int);
and the associations woould be defined like this
class A << ...
habtm :bs
belongs_to :b
end
so my Model A has a habtm collection of Bs *plus* a direct belongs_to
link to one B (and vice vers...
2008 Jul 04
2
How to make WHERE foo_id IN () query?
Hi,
There are 3 models:
A has_many :Cs
B has_many :Cs
C belongs_to A and B
I got a single object of A and an array of B objects. How can I get
all Cs that have a_id equal to object A.id *and* b_id that belongs to
an object in Bs array?
Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public....
2013 Jul 19
12
Rails 4 "belongs_to: record" association doesn't work
Hi,
I discovered a weird behavior when using a "belongs_to: record" association
in Rails 4.
Given two models A and B:
class A < ActiveRecord::Base
belongs_to :record, class_name: ''B'', foreign_key: ''b_id''
end
class B < ActiveRecord::Base
end
When creating A, it inserts a record in B and returns A with id of nil:
irb(main):001:0> A.create!
(0.1ms) begin transaction
SQL (0.4ms) INSERT INTO "bs" DEFAULT VALUES
(2.4ms) commit transaction
=> #<A id: nil, b_id...
2006 Mar 15
1
push_with_attributes not inserting default values
I have a join table A_B with columns[a_id, b_id, c_data default 1,
d_data default 1].
If I do:
@aobj.bobjs.push_with_attributes(@bobj,{:c_data => 0})
I find that the row inserted, has d_data set to 0 and not the default
value specified in the database, which is 1. So I am having to
explicitly set it using :
@aobj.bobjs.push_with_attributes...
2007 Sep 23
3
Connecting a row of an unknown table to another row of an unknown table
...------------------------------''
My first idea was to create three extra join tables, "genre_genres",
"element_elements", and "genre_elements". I realized, however, that I
could collapse that into one "connections" table:
id :integer
a_id :integer
b_id :integer
a_class_name :string
b_class_name :string
The _id''s can hold either/both the id of a genre or an element; likewise
the _class_name''s can hold either/both "genre" or "element".
However, that would require hacking together a custom ActiveRecord class...
2007 Jul 22
18
db:fixtures:load order
I was trying to deal with foreign key issues related to order of
fixture loading when I came across this:
http://techpolesen.blogspot.com/2007/04/rails-fixture-tips.html
This got me looking deeper into rails and I noticed that
db:fixtures:load calls Fixtures.create_fixtures once for each fixture
file. However, Fixtures.create_fixtures is capable of taking multiple
files and also handle the