similar to: @model.update_attributes(params[:model]) without saving?

Displaying 20 results from an estimated 70000 matches similar to: "@model.update_attributes(params[:model]) without saving?"

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 Jun 13
4
When saving parent fails, children will still be updated
Hi all, When submitting a master/detail form I first want to handle the children before saving the parent. There are has_many and belongs_to relations between the parent and the children, so I can edit the children using (psuedo-)code like: child.destroy for deleting, child.update_attributes for updating and @parent.children.push(child) for adding child-records. I update the parent by using:
2005 Dec 19
2
update_attrbutes without saving?
Hello all, Is there a method for updating all the attributes from a hash without saving to the database? (the counterpart of update_attributes but without saving). What I want to do is: person = Person.find(params[:id]) person.update_without_saving(params[:person]) #update the in-memory object. # Process person object ....... person.save I know that when you are creating a new object, you can
2006 Jan 03
5
update command not updating DB
I really need your help guys... I spent 6 hours on this simple update command today that should work. It works fine in my other controller, but doesn''t work in this one for some reason. Here is my controller code for the list view, and then the update command: ====== def edit @user = User.find(params[:id]) end def update @user = User.find(params[:id]) if
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
2008 Aug 26
1
transaction not working with update_attributes!
I am trying to wrap the updating of two models in a transaction and when the transaction fails it is not rolling back. My method is : def update_attributes(user,params) @user = user @company = user.company begin User.transaction do @user.update_attributes!(params[:user]) @company.update_attributes!(params[:company]) end true rescue false
2006 Mar 02
6
Newb question about facade columns
Hello, I am trying to deal with a database table that contains a date in the form of the number of seconds since epoch. Data is inserted in this format by an existing script that I can''t change, so a schema change isn''t realistic. I would like to allow humans to view and edit this data in the form of an actual human-readable date. I figured a facade column would be the
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
2007 May 21
7
How do I stop a column being updated by model.save?
One of my models has a column that is updated very frequently from a separate process, so it is important that when a record is saved in rails, this column should be left alone. In the update method of the controller I have: @record = MyModel.find(params[:id]) @record.update_attributes(params[:my_model]) params[:my_model] doesn''t have a reference to the column I''m talking
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
2008 Feb 11
3
can't update my data base using "update_attributes"
Hello, I have this problem that my rails application works fine in development environment on my local Linux and windows system but when I uploaded it to work on the server in production environment I have this problem as listed in the pasted log file at the end of this entry: NoMethodError (undefined method `[]'' for nil:NilClass): /app/controllers/admin_controller.rb:201:in
2007 Jun 30
3
transactions with two models
Hi, In Agile Web Development with Rails section on Transactions (p 381) there are two main examples. 1) making changes in two records in the same database table 2) making changes in two records each in a different *database* I want to do what is in between: changes in two records each in a different table of the same database. Suppose they are apples and oranges tables. How do I write this?
2006 Jul 11
3
update_attributes and save!
I notice that ActiveRecord::Base.update_attributes() calls save(). What if I want to get an exception if the save fails? Is there a way to get the update_attributes() function plus the save! function? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Jul 19
3
How do I change :type attribute in a view?
I''m using single table inheritance and want to change the :type attribute from an admin view. How do I do this given that :type has to be handled with special care? -- Posted via http://www.ruby-forum.com/.
2006 Jan 14
14
Javascript/AJAX Debugging
Hello ! I''m trying to implement something similar to the "multiple updates" section of the Web2.0 chapter of the Agile book. I implemented my version, and nothing is happening. No javascript errors, my logs look fine, page is rendered fine... just no Effect.Highlight. Here is the code: views/causes/cause_home/index.rhtml =============== <%= form_remote_tag(:complete =>
2006 May 11
1
RoR completely ignoring a column when saving changes
I have an action that needs to update two models/two tables in one shot, and it works great, but ignores one column. Here is the action code: (verify_id is irrelevant in this case) [CODE] def edit @page_title = "Edit User" @page_active_3 = "active" if request.post? @user = User.find(params[:id]) @profile = @user.profile verify_id(@user.id,
2006 Oct 16
3
Saving many_to_many
Ahoy, i''m trying to save a many to many between "talent" and "vital stat" talent_controller.rb def edit @talent = Talent.find(params[:id], :include => [:talent_type, :vital_stats]) @talent_types = TalentType.find_all @vital_stats = VitalStat.find_all if request.post? @talent.attributes = params[:talent] @talent.attributes =
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,
2006 Apr 24
4
Does Rails need more useful form helpers?
I have been using rails professionally for only a month and a half now, but I am continually running into problems with form helpers and accessing multiple objects on a single page. To whit: 1. While text_field and text_area and such all support the :index option, the select helper does not. 2. When appending the text ''[]'' to a helper''s object name, the id is
2007 Dec 06
2
Implementation of rest in ROR
Hi all, I am new to ROR world. I know the REST conceptually but find the difficulties in implementation can anybody guide me that which is the best book which i have to read. also some good links of implementation of rest in ROR. If anybody made a small application to restful in rails please forward me that application. i found some demo but i didn''t understand for what purpose they