Displaying 20 results from an estimated 6000 matches similar to: "collection_select has_and_belongs_to_many update_attributes"
2006 May 11
1
ActiveRecord collection_select and has_and_belongs_to_many
Hello everyone, first post to the list and a relative newbie to Rails
development. Done quite a bit of JSP, PHP, HTML, XML etc and thought I would
kick the tires on Rails to see if it can speed up development for internal
applications. Anyway, I am running into a problem that is just driving me
crazy and everything I read on the net doesn''t seem to help. I was hoping
someone here might
2006 Aug 17
0
HABTM and collection_select
Hi,
I''m trying to use collection_select with a habtm relationship. Let''s say
you have two tables: books and authors with a many-to-many relationship.
Is there any way in rails to render something like selection boxes for
each author, so that the user can change them?
I tried this (and several more variations) but it doesn''t work:
<% for @author in @book.authors
2006 Jan 06
6
HABTM problem not saving all associations
Hello all,
I have an Order object that has and belongs to many Products and has
and belongs to many Loan Types. This is so I can select multiples of
each in my order entry screen via checkbox groups.
I''m having some trouble with saving multiple HABTM associations for a
single model object; only the first HABTM association declared in the
model will save during the initial @order.save
2009 May 31
0
[HELP] pagination w habtm association and authorization plugin...
I am using the proven authorization plugin to defines roles for users,
so I can get all groups where a user is ''member''
@groups = current_user.group_memberships
I have an habtm association between groups and events
class Group < ActiveRecord::Base
has_and_belongs_to_many :events
..
class Event < ActiveRecord::Base
has_and_belongs_to_many :groups
I am trying to list
2005 Mar 01
0
has_and_belongs_to_many problem
I''m having a problem with a has_and_belongs_to_many (habtm)
association between two models with extra attributes. I''m writing a
comic book database, and each issue has many creators on it. Thing
is, some creators perform multiple duties. They may write one issue,
draw another, etc.
However, if I add a creator twice to an issue and try to delete it, it
removes both creators:
2012 Jan 30
4
Reaching into a has_and_belongs_to_many - will :through work?
Hi. I''m hoping somebody can tell me that I''ve just gotten my syntax
wrong and I can in fact do what I want to do.
I''ve got a Group, and a Group has_many Campaigns.
Campaign has_and_belongs_to_many Users (and, naturally, vice versa).
So I''ve got a groups table, a campaigns table (that has a group_id), a
campaigns_users join table (with campaign_id and
2006 Aug 18
1
join update seperation?
I have a legacy DB without access to change the user or group table
(must use StoredProcedures to edit those). But I do have access to the
usergroup join so I thought the joins would be pretty much like my other
rails apps where I do HABTM checkboxes. I''ve created a page that just
shows habtm checkboxes for the join and the updates are occuring for the
join but I''m
2006 Mar 22
1
HABTM / Dropdown Help Needed
I''m terribly new to Rails, so bear with me.
I have an application I am working on which deals with projects and
subcontractors. There can be several subs on each project and each sub
can work on several projects. I have my join table set up and
has_and_belongs_to_many in both models. If I manually put data in the
join table, this works in my show view:
<% for subcontractor in
2010 Sep 01
0
Error on update_attributes with HABTM relationship
Hope someone can tell me what''s up, because this has me baffled.
I have an Image model, and a Provider model. Both are defined as
"has_and_belongs_to_many" relating to each other. In my image form
partial, I have a bit of AJAX generating the provider_ids array
dynamically from a provider AJAX search on the same page.
So for example, each time I click on a provider name that
2006 Jul 16
6
using collection_select
hello,
supposing i have a User class that contains a Wibble
class User < ActiveRecord::Base
has_one :wibble
end
in my view i have
<%= collection_select :user, :wibble, Wibble.find(:all), :id, :name %>
when i post, i get an error like
"Wibble expected, got String"
how/where am I supposed to convert this posted wibble_id into a
Wibble, or am I using collection_select
2006 Jan 25
2
Update join_table attributes
I have two ActiveRecord classes that point at each other with a
"has_and_belongs_to_many" (habtm) relationship using a join table. The
join
table has an a few additional columns besides the _id columns.
For those of you with the Agile Web Dev w/ Rails book, it''s exactly the
same
setup as the articles<->articles_users<->users example on p240.
The habtm
2006 Jul 05
1
created_on in HABTM table getting parent dates
All of my HABTM tables receive the parent created_on/last_update_on
dates whenever a record is inserted into these join tables. I don''t
have any defaults in the database or anything else populating these
tables. I assumed rails would populate these automagically. Is there
something that needs to be done to get this to populate with the correct
current timestamp instead of
2006 Nov 22
1
has_and_belongs_to_many find with multiple predicates?
Hi,
I have a habtm relationship between ''Posts'' and ''Tags'' and am trying to
get a list of Posts that have multiple tags. Something like:
@posts = Posts.find_posts_with_tag_ids[1, 3, 5]
Is this catered for in ActiveRecord or should I write my own SQL
statement?
Thanks,
GiantCranes
--
Posted via http://www.ruby-forum.com/.
2006 Mar 22
3
Parent-Child Tables Help
can someone help me with this
i have a table
cars
(
id int
model_id int
make_id int
color_id int
description text
constraint fk_cars_carmake foreign key(make_id) references
carmakes(id),
constraint fk_cars_carmodel foreign key(model_id) references
carmodels(id),
constraint fk_cars_color foreign key(color_id) references colors(id)
)
carmakes
(
id int
carmake varchar
)
carmodels
(
id
2006 Apr 27
3
collection_select to display 2 fields
I''m trying to get a collection_select generated Drop-down box to display
two fields from a table (first name & last name); however, I am having
trouble concatenating the symbols. It appears as though any code I put
in the 5th argument for collection_select is processed prior to
executing the collection_select method. The code executes successfully
with 1 symbol in the 5th
2005 Dec 31
6
habtm recursion via destroy_without_callbacks
I am having a problem with two models that each have a HABTM
relationship to the other. For example:
CREATE TABLE people (id INT, name TEXT);
CREATE TABLE teams (id INT, name TEXT);
CREATE TABLE people_teams (person_id INT, team_id INT);
The person model has:
has_and_belongs_to_many :teams
And the team model has:
has_and_belongs_to_many :people
The trouble comes when trying to destroy
2008 Dec 09
4
HABTM checkboxes insert but don't delete
I have a problem related with the HABTM relationships with checkboxes.
I''ve got a profile and a service model, both related with
has_and_belongs_to_many.
The problem is that i can insert new data in the profiles_services
table, however, i cant delete already existing data.
What could be the problem?
--~--~---------~--~----~------------~-------~--~----~
You received this message
2006 May 24
0
Problems validating form with collection_select
I have the following models:
class Comandancia < ActiveRecord::Base
has_many :elementos
end
class Elemento < ActiveRecord::Base
belongs_to :comandancia
validates_presence_of :nombre, :apellido_paterno, :apellido_materno,
:comandancia
end
In the view for New Elemento I''m using
<%= start_form_tag :action => ''create'' %>
<%= render :partial =>
2006 Nov 26
0
concatenate fields in collection_select
Hi,
I am filling a collection_select with a list of models references based
on a column named "model_ref".
<%= collection_select(:assets, :model_id, @models, :id,
:model_ref,:prompt => ''- Select a model -'') %></p>
I have two issues :
1) I would like to concatenate another column next to the model
reference inside the option value with the description
2007 Apr 30
1
collection_select - prepending a "any" option
Say I have a normal <SELECT> tag being generated thusly:
<%= collection_select :task, :id, Task.find(:all), :id, :name %>
what is the easiest way to add a "ANY" option to the top of the option
list? I know Task.find(:all) returns a collection object, so is there
a unshift() for that?
well OK I tried:
Task.find(:all).unshift([:id=>0,