Displaying 20 results from an estimated 800 matches similar to: "has_one without inverse belongs_to"
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_id''s of
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
When I''m executing cucumber tests, I noticed that sometimes rails app
(in test env.) getting several the same requests (GET or POST) usually
around 3, and it doesn''t render anything with empty HTTP status code.
Have anyone met something similar to that issue?
here is some example of log file:
Started POST "/account" for 127.0.0.1 at 2010-11-30 22:34:17 +0200
2009 Feb 15
3
conditions on association include, hacky but more or less solved
Hi all,
I just finally figured out how to get 2.2.2 to do this, and thought
I''d share in case others run into the same thing.
The situation is a find with associations, but the tricky part is that
the association shouldn''t always be loaded. This is similar to putting
a condition on a has_many association in a model, but the condition is
dynamic rather than predefined.
The
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
2006 Feb 18
4
verifying best practice
i have a Project model, which belongs_to :user
when i add a project, the users_id is based on the session[:users_id].
to get the users_id into the projects table, i''m doing this:
@project = Project.new(params[:project])
@project.users_id = session[:users_id]
this is working, i''m just verifying this is the best way to do it.
2005 Dec 15
3
How to delete a record
hey,
i my database i have users and groups, each user can get in different groups
my db structure:
table groups: id, name, basegroup, firm_id
table users: id, firstname, lastname, email
table groups_users: group_id, user_id
my relation is a many to many:
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
end
class User < ActiveRecord::Base
has_and_belongs_to_many
2006 Feb 18
44
I forgot. Why do we hate* Java?
Hi,
I''ve started reading some Java books. Gasp! What makes website
development with Java so bad? I haven''t looked at Struts but I''m
reading about Hibernate. Compared to ActiveRecord, Hibernate seems
like some extra typing to explicitly define the model fields, getters
and setters. I know that these are things that you can do in
ActiveRecord when things get complicated
2010 Dec 18
1
Can I make my colnames bold?
Hello forum! As the subject indicates, I am trying to make a barplot and
would like my column names to be in bold. Is this possible in R without
having to make my column names in mtext? Any help would be much
appreciated. The code I am using is as follows.
par(mar=c(3,8,2,2))
par(adj=.5)
par(font=2)
par(oma=c(3,3,3,3))
par(xpd=TRUE)
Blot<-matrix(c(25.2995, 0.7625, 25.6135, 36.5770,
2008 Sep 16
3
has_one :through eager-loading problem
I have a problem with the :include option in find for my
has_one :through association.
I have Users, Profiles and Customers, all connected to each other with
a has_one :through => :membership association like this:
class Profile < ActiveRecord::Base #could also be user or customer
has_one :membership # i saw an acrticle of Ryan about
has_one :through, there this would be has_many, is
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 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
2014 Apr 19
0
How to has_one/belongs_to association only return the objects unassociated in combobox?
I have two models (Car and Driver) and a combobox to select which driver
belongs to which car. I want the combobox just show the objects that have
not yet been associated.
# vehicle belongs_to: driver
# driver has_one: vehicle
# simple_form # vehicle/_form.html.haml
= f.association: driver, label_method: :name, value_method: :id
How to ensure validation before saving, to avoid problems of
2006 Dec 01
0
How to save has_one belongs_to models?
How can I save two models that have has_one and belongs_to
relationship to each other? I want to save both the models by using
script/console. TIA.
--~--~---------~--~----~------------~-------~--~----~
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
2011 Jul 07
0
has_one through belongs_to
Hi.
My model data is the following:
- Place
- User
- Checkin
Instead of having a Checkin that belongs to both User and Place, I chose to
add another model, Program, that allows to list all the places a user can
checkin into, and also hide the checkins he''s no longer involved in (= the
user sign out of a specific program).
That give me crazy relationships:
Program has_many Checkin
2011 Oct 20
2
Access other model attributes directly with has_one, belongs_to ?
So, I have 2 models A and B that share 5 common attributes and all other
attributes are different. So I wanted to extract these 5 out into one
common table and use has_one, belongs_to to knit it back together. So
now there are 3 tables with 1 having the shared properties, we''ll call
this table C.
Table A
id
dollar_amount
Table B
id
quantity_on_hand
Table C
id
version
My question is,
2006 Feb 20
1
belongs_to, has_one, has_many question (again?)
Hi All,
Probably this has been asked numerous times, I apologize already!
Can somebody point me to a good tutorial on how Rails works with
relations?
I know about database design and normalization, I also know about
programming in general (and OOP for that matter).
Only thing I can say is that I''m following the "Four days on Rails"
tutorial by John McCreesh.
He writes
2006 Jul 06
4
has_one, belongs_to - I am just not getting it
Let me preface by saying i''m a total noob at ruby/rails. :-)
For some reason, I am just not grasping the concept of has_one &
belongs_to...
I''m working on a project that includes user authentication, and 3
different types of user profiles.
User profiles are either "fan", "band", or "venue" objects, and user
logins are "user"
2006 Oct 13
3
Validation errors in has_one/belongs_to relationships.
I have two objects, QuoteInput and Insured.
QuoteInput has one Insured and Insured belongs to QuoteInput.
I don''t understand what I''m seeing.
I assign an Insured to a QuoteInput. The Insured object has invalid
data.
I call save! on the quote input. QuoteInput has no validations.
I expect two things to happen - 1) an exception should be thrown,
indicating that there was a
2010 May 11
1
has_one/belongs_to -- accessing the subordinate
With a has_one/belongs_to relationship, what''s the best way to guarantee
that the belongs_to object gets created and is accessible alongside the
has_one object? I *think* the after_create callback is a good choice,
but I discovered an oddity while trying it.
F''rinstance, if every horse has a carriage:
============
ActiveRecord::Schema.define do
create_table(:horses) {|t|
2008 Apr 29
4
Default values for belongs_to and has_one
There really doesn''t seem to be a *declarative* way to define a default
value for belongs_to and has_one associations
class Person < ActiveRecord::Base
belongs_to :address
end
p = Person.new
p.address.city = ''Atlantis'' # Bummer!
Of course, there''s an easy way to avoid this
class Person < ActiveRecord::Base
belongs_to :address