Displaying 20 results from an estimated 20000 matches similar to: "update_attributes for nested form"
2009 Apr 12
0
rails 2.3 nested forms with has_many through checkboxes
I was wondering if anyone knew of a way to combine the new nested
forms in rails 2.3 with a has_many through relationship via
checkboxes. Basically I have a page model, a page_category model and
a category_items join table. Pages have many page categories through
category items. The category_items table is polymorphic so i can use
it for other models who need categories (maybe this is
2005 Nov 30
8
nested attributes with update_attributes()
Hi,
I am trying to use the update_attributes on object with nested
attributes and I am getting the following error:
ProductPrice expected, got HashWithIndifferentAccess
Here''s the situation (simplified):
class Product < ActiveRecord::Base
belongs_to :productPrice
end
class ProductPrice < ActiveRecord::Base
has_one :product,
:dependent => true
2006 Dec 29
2
update_attributes fails: ReadOnlyRecord
I''m trying to update a record, but it just stops with
"ActiveRecord::ReadOnlyRecord". I don''t understand why, because I never
wanted my model to be read only. Relevant code:
Controller:
def edit
@project = find_project
if request.post?
@project.update_attributes(params[:project])
if @project.save
flash[:message] = _(''Project was
2009 Feb 23
2
geokit - using :through to connect models
hello..
i am currently trying to use :through to attach two of my models
together using geokit. for some reason, i am running into a problem:
ArgumentError: Unknown key(s): as
i have two models, one that is geocoded, and one that belongs to that
model. the models look like:
,----[ employer.rb ]
| class Employer < ActiveRecord::Base
| acts_as_mappable
| before_validation_on_create
2011 May 19
1
update_attributes updates data from second instance of nested form but not the first
Got a weird situation with an update put to a controller with a form with
nested attributes.
On the data below, I am updating data for both items (''0'' and ''1'') in
rosters_attributes (in the example below I am updating the ''name'' attribute
to a new value in both cases. What I am stuck on is that ''1'' gets its data
updated,
2009 Feb 03
1
update_attributes! does not update nested model
Hi!
I have updated my app to rails 2.3. I have form that has few nested
models and I am happy that I can just write
accepts_nested_attributes_for :tasks, :allow_destroy => true, but
update_attributes! does not update my nested model. I have tried
update_attributes, and it works. Any ideas?
Few lines from log:
update_attributes:
SQL (0.1ms) BEGIN
Education Update (0.3ms) UPDATE
2013 Mar 25
1
validates presence of foreign key fails in nested form
I''m using accepts_nested_attributes as follows:
class Timesheet < ActiveRecord::Base
attr_accessible :status, :user_id, :start_date, :end_date,
:activities_attributes
has_many :activities, dependent: :destroy
has_many :time_entries, through: :activities
accepts_nested_attributes_for :activities, allow_destroy: true
end
class Activity < ActiveRecord::Base
attr_accessible
2010 Jan 25
0
has_many, :finder_sql, setting attributes
Hi all,
My question is somewhat complicated, but bear with me. My project has a
number of models: User, Program, and Team. Users belong to multiple
Programs. Programs have multiple teams, but Teams belong to one
program. For each Program a User belongs to, he can belong to multiple
Teams. (Think of this in an athletic context where users are athletes,
programs are universities). So my
2009 Oct 06
1
Problems Processing multiple form elements generated by javascript actions
Hi all,
After many days of struggling, I have a multi-model form with ajax
elements more or less working, but I''m hitting a wall with a few bugs
that I can''t figure out. Guidance would be very much appreciated.
I''m using the Ryan Bates technique from Advanced Rails recipes to
dynamically add and remove elements on a multi-model form.
2012 Jun 29
0
Can I make Rails update_attributes with nested form find existing records and add to collections instead of creating new ones?
Hi there,
I''ve asked this question at stackoverflow.com
http://stackoverflow.com/questions/11257662/can-i-make-rails-update-attributes-with-nested-form-find-existing-records-and-ad
I haven''t seen a better answer than one I propose myself but I''d like to
know if it''s possible to enhance accepts_nested_attribute_for to allow a
find_or_create_by behavior for
2012 Nov 06
0
How to get which check boxes has beed unchecked and remove Subscription for them?
I have following subscription creating system, right now when I`m selection
available subscription groups(Marketing, Sales) action Save Subscription
create this two subscriptions:
@subscriptions = current_user.subscriptions
> @apps = App.all
> if request.post?
> if params[:subscription] and params[:subscription][:app_id]
> params[:subscription][:app_id].each do |app_id|
>
2007 Oct 15
0
converting from HABTM to has_many :through
Hello,
I have a has_and_belongs_to_many relationship that I''ve realized I need
to add additional attributes to. So I''m converting it to a has_many
:through (HMT) relationship. This is the first time I''ve used an HMT,
and it seems like I''m using too much code. I couldn''t figure out how to
get the join model objects to update automatically as a result of
2013 Feb 10
0
Nested attributes doesnt get updated
Hi
Am building a nested form and my code works fine with sqlite3 but throws
errors when using Oracle during update action.
Am getting the following error:
ActiveRecord::RecordNotFound in AWRequestsController#update
Couldn''t find WADetail with ID=5000000015 for AWRequest with ID=5000000022.0
Request
*Parameters*:
{"utf8"=>"✓",
2006 Mar 16
2
please help: "undefined method ''updated?''"
Hi,
after updating to rails1.0 (using the debian package) and following the
instructions at http://manuals.rubyonrails.com/read/chapter/120
I always get in my rails application the following error:
"undefined method `updated?'' for #<Device:0xb6c95564>"
when I want to save (create or update) an interface or device-object
(as explanation: devices are servers, which have
2006 Jul 02
5
Question about setting field values for a belongs_to model
I have two tables, applicants, and skills where each applicant
"has_many" skills, and each skill "belongs_to" an applicant.
When I have a reference to an applicant and a (skill) id for one of
their skills, I thought to update their skills by using
@applicant.skills.find(id_of_skill).description = ''new description''
# even adding
2006 Jun 12
0
validates_associated -- explicitly setting collection?
Hi, I have a class (say Parent) that has many of two other classes, say
FirstChild and SecondChild. These could look like this:
class Parent < ActiveRecord::Base
has_many :first_children, :dependent => true
has_many :first_children, :dependent => true
validates_associated :first_children
validates_associated :second_children
end
class FirstChild < ActiveRecord::Base
2006 Jan 11
0
Easy Question, I Think
I am just getting started with Rails, don''t know any Ruby, and don''t
quite even get object oriented programming yet. I have tweaked my
schema to The Rails Way and have generated a bit of scaffolding.
I am trying to create a new Part, which references a PartName and a
PartNumber. I can create a PartNumber on the fly, but the PartName
has to exist. I have an inelegant solution
2006 Feb 17
1
validate() with has_many association
I''m creating a simple portfolio site for a painter. I have a painting
and an image model with following relationship:
Painting
has_many :images
Image
belongs_to :painting
On the edit screen the user can edit the Painting data as well as upload
pictures for a thumbnails and full size image. The Image model extracts
filename, width, and height from the uploaded file, saves those
2006 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
I am just getting started with Rails, don''t know any Ruby, and don''t
quite even get object oriented programming yet. I have tweaked my
schema to The Rails Way and have generated a bit of scaffolding.
I am trying to create a new Part, which references a PartName and a
PartNumber. I can create a PartNumber on the fly, but the PartName
has to exist. I have an inelegant solution
2010 Jan 27
2
has_many, through with nested models?
First the data model:
class Forum < ActiveRecord::Base
has_many :topics, :dependent => :destroy, :order => ''created_at
desc''
end
class User < ActiveRecord::Base
has_many :topics, :dependent => :destroy
has_many :comments, :dependent => :destroy
has_many :replies, :dependent => :destroy
end
class Topic < ActiveRecord::Base
belongs_to