Displaying 20 results from an estimated 10000 matches similar to: "select-multiple for has_many association"
2009 May 12
4
has_many :through and scopes: how to mutate the set of associated objects?
I have a model layer containing Movie, Person, Role, and RoleType,
making it possible to express facts such as "Clint Easterbunny is
director of the movie Gran Milano".
The relevant model and associations look like this
class Movie < ActiveRecord::Base
has_many :roles, :include => :role_type, :dependent => :destroy
has_many :participants, :through => :roles, :source
2005 Apr 23
0
collection_select: generated select tag not marked on error
When a select tag generated by collection_select has a validation error
the tag isn''t marked in the page. That is, the generated tag looks like
this, say,
<select id="obj_attrib_id" name="obj[attrib_id]">
<option value="1">Option 1</option>
<option value="2">Option 1</option>
</select>
Whereas is should,
2008 Nov 19
0
has_many through select box in form
Gentlemen,
I have searched the group and have not found any post that clarifies
thsi s=issue to me. Please forgive me in advance if I missed
something.
I have 3 models:
Ticket
has_many :citations, :dependent => :nullify
has_many :violations, :through => :citations
Violation
has_many :citations, :dependent => :nullify
has_many :tickets, :through => :citations
Citation
2010 Mar 16
3
collection_select has_many
hi
i have two models:
GeoRegion & GeoRegionSub
which have a has_many relation to each other.
how can include the has_many relation in the collection_select helper? i
want to have that dropdown where the parent is in black and the children
indented.
<%= collection_select :dl,:parent_id, GeoRegion.all.????, :id, :title %>
thx
--
You received this message because you are subscribed
2008 Apr 23
0
self referential (n-n relationship) belongs many controller
Hi all,
I ve some troubles in my small acpplication (only 2 tables).
I want to follow up tasks but these tasks are linked to others tasks.
So I ve tried to do store the nn relationship in other table called
links
1st table : tasks
columns : id | infos neutral... (as title, description etc ...)
-----------------------------------------------------------------------------------
model :
class
2006 Jul 20
2
using association properties in form helpers
sorry for the noob question:
how do i reference an association''s properties in a form helper?
e.g. if i wanted to build a select list to choose a user''s address''s
state (user.address.state), how would i hook that to the "method" of
collection_select
collection_select :user, ???, States.find(:all)
2006 Jul 27
0
CRUD, REST and associations
Let''s say I have the model class Reader and Magazine, connected by join
model Subscription. It looks something like this
class Reader < ActiveRecord::Base
has_many :subscriptions, :dependent => :delete_all
has_many :magazines, :through => :subscriptions
validates_presence_of :name
end
class Magazine < ActiveRecord::Base
has_many :subscriptions, :dependent =>
2012 Sep 13
3
Creating a link_to from a collection_select
I want to be able to change one attribute of a link_to to be what is the
current selection of the collection_select. And needless to say I can''t
quite figure it out.
app/views/tasks/show.html.erb
Who would you like to assign this task to?<br />
<%= link_to ''Myself'', :controller => ''task_queues'', :task_id => @task.id,
:action =>
2006 May 05
0
Missing documentation for find_in_collection? Trying to drill down in a 4 level has_many association fails
I''ve been reading up in ActiveRecord::Associations and playing around
with my app via the console and found some interesting methods via
the code completion of IRB, but I have no idea how to use them and
can only find one hint in the API
http://api.rubyonrails.com/classes/ActiveRecord/Associations/
ClassMethods.html
It mentions here in the has many associations that if you use the
2006 Jun 19
2
const_missing error of has_many through association
Hi,
I am new to ruby on rails. I am building an association join model
and encountered the following error. Does anyone know what am I
missing?
> NameError in StartController#home
>
>d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:100:in `const_missing'': uninitialized constant Membership
I have the following tables relationships
Users
2006 May 04
0
Complement set association to has_many/through?
I have two models, A and B, with a straightforward many-to-many
has_many/through association between them. So, in A I have the
association processed_bs and in B I have processedby_as. This works
fine.
Now, I would like to also have an association unprocessed_bs in A,
which holds all Bs that _aren''t_ in processed_bs. I can write a method
in A that returns all those objects as a list
2006 Sep 26
0
ActiveRecord, has_many association and object graphs
I am still using Rails 1.0...
I have a simple has_many association:
class Round < ActiveRecord::Base
has_many :scores
end
class Score < ActiveRecord::Base
belongs_to: round
end
When I do something like this (contrived for the sake of clarity):
rr = Round.find(params[:id])
rr.scores.each { |s|
logger.debug("object_id=#{s.round.object_id}")
}
I see a database query on
2006 Jul 31
0
Polymorphic has_many association through a belongs_to
Hi,
Let''s say I''ve the following Models and their relative associations:
Seat
----
belongs_to :booking
Booking
-------
has_many :seats
has_many :debits, :as => :chargeable
Debits
------
belongs_to :chargeable, :polymorphic => true
Why
>> seat.booking.debits
nil
while
>> Booking.find(seat.booking_id).debits
[]
?
Thanks.
Cheers,
Marco
2006 Jun 22
0
how to save objects in a has_many :through association?
(I posted this yesterday but it never showed up on the mailing
list... weird.)
I recently converted a habtm relationship into one using
has_many :through. Some of my old logic relied on the ability to use
the #<< operator to add items to the relationship and get them auto-
saved. I''m curious to know the best way to do the same operation with
the has_many :through
2014 Apr 06
0
collection_check_boxes with has_many through: association Rails 4
I am trying to list all the categories a user can be interested in with
check boxes so that a user can submit these interests through my join table.
collection_radio_buttons works with a simple has_many, belongs_to
association:
<%= collection_radio_buttons(:listing, :category_id, Category.all, :id,
:name do |b| %>
<%= b.label { b.radio_button} %>
<%= b.text %>
2006 May 10
3
has_many association.
I''m creating a address book.
A user can have many contacts.
In the user model, I put:
has_many :contacts
And in the contact model, I put:
belongs_to :user
To list all contacts, I search as following:
@user = User.find(session[:user_id])
And rendering:
<%= render(:partial => "contact", :collection => @user.contacts)%>
To persist I am using the following
2010 Jun 17
0
Edge Rails Nested has_many :through Association
So this functionality isn''t supported natively in Rails 3 (or any
versions before that for that matter) But I had found a work around
via this blog post: http://geoff.evason.name/2010/04/23/nested-has_many-through-in-rails-or-how-to-do-a-3-table-join/
This didn''t work on Rails 3 because it wasn''t able to properly build
the query from the join with symbols. I was
2012 Jul 10
1
has_many association with autosave issues
I''d like to use autosave => true for an association for its added benefits:
the parent doesn''t save unless the children saves. However, it seems to
skip validations when saving the children. And this seems to be the case
since the beginning of time...
Anyone know why?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 May 08
2
Creating a "Foo has_many bars" association where bar isn''t a model.
Hi
Let''s say we have model Foo. Each Foo instance can have several bars.
Those bars are primitive, so they shouldn''t be models. For example,
Foo might be a type of convention, and the bars might be years the
convention was held in. Naively, we would have a conventions_years
date, and put:
has_many :years
inside class Convention. But then we''d get an error, since for
2007 May 22
3
can I use acts_as_list with a has_many :through association
I''d like to be able to use a has_many :through association and treat
the associations as a list but I''m getting this error when I try an
use an acts_as_list method:
NoMethodError: undefined method `move_to_bottom''
I''m using edge rails r6786.
Here are my domain rules:
Activities are things students can do.
Units consists of a sequenced list of