similar to: Question re: Computing a field in a DB record

Displaying 20 results from an estimated 10000 matches similar to: "Question re: Computing a field in a DB record"

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
2008 Mar 23
0
Committing a record update to the DB from a test
Hi all, I hope someone can help me with this. I''m trying to write a test to see if my versioning (acts_as_versioned) works. In order to do that, I have a class which inherits from ActiveRecord: class Order < ActiveRecord::Base However, when I try to update or to create a new order within the test, my changes do not affect the DB: o = Order.create(:name =>
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 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 May 23
2
additional fields in session DB table
I am using active record sessions and everything works fine. I am integrating it with phpbb however so i need some extra fields populated in the session table. In application.rb i put a before_filter to update the session table I have a model for the sessions $ more app/models/session.rb class Session < ActiveRecord::Base set_primary_key "session_id" set_table_name
2006 Nov 04
0
Appending a String to A Field
I have the following update method and need to append a subdirectory to a single field.. def update @product = Product.find(@params[:id]) if @product.update_attributes(@params[:product]) flash[''notice''] = ''Product was successfully updated.'' redirect_to :action => ''show'', :id => @product else render_action
2008 Jun 07
5
Can create record but can not update it => has_many through
Hi All, I have a problem using has_many through association. I can create a product without problem, but when i edit it, i got this NoMethodError: undefined method `reciters='' for #<Product:0xb71a77e8> Did i miss something to code? I provided the codes below. Please help Thanks, Dida product_controller.rb ====================== def create @product =
2006 May 19
2
update_attributes
My application is so far mostly built from scaffold. When I edit an existing record (I''ve turned off validation) the update method is called. I get this error: NoMethodError in <module>/<controller>#update You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.+ I get the same error when
2007 Jan 10
0
many_to_many relationship problem
Hello everyone, i wonder if someone can help i''m a newcomer and this problem is driving me crazy. I have this two models with a habtm relationship Entidad(entity) and Persona(person), on the people view i want to see the entity/es he belongs to and viceversa, so far so good. The thing im getting stuck is with the form that handles the editing to add more people to an entity, heres what i
2006 Jun 27
6
Custom action on Active Record Validation Failure?
Instead of having it highlight the bad fields when you enter in a record that fails validation, is there a way to make it do an action? I''m looking for something like this: validates_uniqueness_of :user_id,:url => {:controller => "headline", :action => "index"} so that on failing the uniqueness check, it would go to the headline controller. --
2006 May 29
1
validation in a "subform"
I''ve been following the rails/osx tutorial at http://developer.apple.com/tools/rubyonrails.html This develops a simple application with expenses and accounts. Near the end of the tutorial, there is a view which allows expenses to be added to an account. This view has the "parent" @account rendered, then iterates throught @account.expenses to display the existing accounts,
2006 Jan 15
0
update_attributes not working
I dont know if its me or the dodgy win-32 intall of ruby/mysql, but I can''t seem to get update_attributes to work. In my user controller, I have: def update @user = User.find(@params[''user'']["id"]) if @user.update_attributes(@params["user"]) flash["success"] = "Updated Successfully" redirect_to :action =>
2010 Mar 10
2
Decimal fields generated in Rails 2.3.5 act like strings, sort of
Hi All, I just created a new CRUD "expense" (using Rails 2.3.5 scaffold) which included "amount:decimal". When I: 1. populated the amount field of a new expense with 5 characters: 12.50 and 2. saved the new record I got a display of the new record that showed Amount to be merely "12". I clicked Update and put my cursor over the data field for Amount and got a
2006 Apr 18
4
how would you take the duplication out of this?
i have these two really similar methods in my addressbook controller. def edit_company @company = Company.find(params[:id]) if request.post? and @company.update_attributes(params[:company]) flash[:notice] = ''Company was successfully edited.'' redirect_to :action => ''show'', :id => @company end end def edit_person
2006 Jun 19
1
How can I tell what fields have been updated?
I''ve scoured the Wiki and gone through the documentation with a fine toothed comb, but I can''t seem to find this answer. I want to keep a history of the changes made to a record, but can''t seem to find out what fields have changed. I''m sitting in the update function, as you can see below... I want to be able to get a list of what has changed so I can add
2006 Apr 27
2
NoMethodError - why?
Getting this error when hitting update. NoMethodError in Article#update You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occured while evaluating nil.update_attributes Source code. def create @article = Article.new(params[:article]) @article.user = @session[''user''] if @article.save
2013 May 20
0
db connection returns stale values
Hello, I''m working on a rails 3 app for a legacy oracle db. I have a controller that saves object graphs (accepts_nested_attributes_for) but I noticed the post-update JSON response still contains the pre-update values. After some debugging, it appears the database connection is returning stale values (find(), reload(), etc., all return pre-update values; but SQL clients and
2009 Nov 18
4
rails newbie : routing error
After much ado about the naming of model adn controllers... model : Expense controller : Expenses route : map.resources :expenses Here I am using mysql database and created a unique index, since db:migrated created an id object and made it as primary key. Now in the def create @expense = Expense.new(params[:expense]) if @expense.save flash[:viola] = ''New expense saved.. be
2007 Sep 14
5
controller.expect_render has me beat!
Hi, A controller has a method with the following def update ... if @config.update_attributes( params[:new_config] ) redirect_to :action => :index else * render :action => :edit, :id => params[:id] # this line here* end ... end The example has the following it ''should render the "edit" config url on an unsuccessful save''
2006 Nov 04
0
Using Field Helpers to Edit a Related Model Object
Hello folks, Here''s a question about creating an edit screen for a model and a related model. On page 355 of the AWDWR book (printed page 464 of the 2nd edition pdf), there''s a little table showing how form parameters map to the params object. One of them is: user[address][city]=Wien ... maps to params as ... { :user => { :address => { :city =>