Displaying 20 results from an estimated 3000 matches similar to: "ActiveRecord not updating record"
2005 Mar 02
4
Don''t Try This at Home (rails --help)
So I was attempting to determine what version of Rails I was running;
I first I did rails -v which went off and created a -v directory. I
then did a rails --help which created a --help directory... I dont
know if you have ever tried, but deleting a directory named --help
from the cli is about impossible! I had to write a ruby script to
clean up the mess I made!
2008 Mar 11
6
saving an ActiveRecord without trigging the callbacks
Hello,
How can I save an ActiveRecord without trigger before_save,
after_save, etc?
Thanks for the help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group,
2006 May 30
2
acts_as_queue
wondering if anyone tried this patch. (i havent, seeing as its 1228
lines long, 10 months old, and cant take serious a patch many orders
larger than competing web frameworks)
in many cases i want to keep about 10 things around, eg recent searches,
new items (spanning multiple classes), referers, page views, without
logging them for perpetuity. so i guess this isnt a normal queue, more
like a
2009 Jan 11
6
Why does ActiveRecord allow perception of success when updating an ID, however it doesn't really work(i.e. no change in database)?
Hi,
Why does ActiveRecord allow perception of success when updating an ID,
however it doesn''t really work(i.e. no change in database)?
Here''s an example. The update of "id" versus update of a non-existent
attribute.
?> ai = AccountItem.find(:first) => #<AccountItem id: 1, account_id: 1,
date: "2009-01-11", amount:
2006 Mar 11
2
ActiveRecord increment confusion
Part of my application counts the number of times a link was clicked.
The Link.click function should increment the @link.clicks attribute.
I assumed
def click
@link = Link.find(params[:id])
if @link.increment(''clicks'')
redirect_to @link.url
else
flash[:error] = ''Could not update clicks''
redirect_to :action =>
2006 Mar 23
1
validations.rb of ActiveRecord - bug or misunderstanding?
Either I''m not understanding how things are used, or this might be a bug
in ActiveRecord. I''m using version 1.13.2.
In my version of activerecord/lib/active_record/validations.rb (the svn
trunk version is browsable at
http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/validations.rb
), I have:
def update_attribute_with_validation_skipping(name,
2006 Dec 14
3
Problem with ActiveRecord and Associations
Hi,
I''m having what I believe to be a typecast problem with ActiveRecord and
Associations. In the code below, I need to flag a contact record for
deletion if the contact doesn''t have any addresses or books records:
sql = "select id, delete_flag from contacts where id = #{params[:id]}"
contact = Contact.find_by_sql(sql)
if (contact[0].addresses.count +
2005 Oct 19
4
ER strikes back
Hi Railers,
A long, long, time ago, i made a Framework/CMS in php.
There were two core models: Content and Content_type.
Content_type was only a list of content types (as expected): new, article, etc.
Content_type was not mandatory, but it allowed later to "deactivate"
types of contents, for example.
So then Content stored the common attributes/properties between the
different content
2006 May 19
1
ActiveRecord: Minor saving problem
This is probably a very stupid error on my side, but I am doing my
first steps now and I don''t see what is wrong.
I have companies and I have users. A user can create a company. When
the user does he''s automatically a member of the company. A company
should be able to have multiple users off course so every member of a
company can add other users who don''t have a
2006 May 02
9
Updating only one field
At present, I use an update like this to set the user''s last login time:
authenticated_user.update_attribute(:last_login, Time.now)
However, this calls the following, updating all fields:
UPDATE users SET `last_login` = ''2006-05-02 13:27:41'', `hashed_password`
= ....
Is there any way I can tell ActionRecord to only update the one field?
I don''t really want
2006 Jul 17
6
Best Practices: Splitting the "view model" from AR model
All,
I''m starting to see view state information creeping into my model class.
For example, I have text fields in my view that need to be set a certain
way depending on whether or not a checkbox is checked. And while the
values of these text fields ultimately do represent database columns
that are related to the backing AR object, the text_field values also
represent attributes on a
2006 Dec 08
9
How to update partial attributes of a object from a form?
I have a user table, and it has forty columns, including name, gender,
address, email, phone...
So my @user object will have forty attributes.
I divide these attributes into 4 groups... namely ''general info'',
''personal info'', ''contact info''... and I make separate forms to edit
these 4 different group attributes.
The problem is when I update
2007 Jan 05
4
How To Spec Controllers with Finders
Given this code (which renders rjs), I''m faced with the fixture-
driven way of spec-ing or mocking. How the heck to you mock this so
the code at line (2) and (4) work right? I''m still struggling with
mocks but it seems like this can be done. Forgive the naivety of this
question.
1. def change_quantity
2. @line_item = LineItem.find_by_id(params[:id])
3. unless
2007 Jan 10
6
Updating an attribute in db
Hello
I am a Ruby newbie, thus a rather simple question.
My list view shows table records and enables user to click a button in
order to change value of one attribute in given record. I use this code
to invoke a method from controller:
<%= button_to "Change", { :action => "edit", :id => prog.id_prog } %>
My method looks like this (just a simple one - to set the
2011 May 21
1
Consequences of overriding update_attribute to force validation?
I know the debate of whether this should validate has been rehashed
many times. My question is, what are the consequences of overriding
this method to force validation? Will this break fundamental things?
Will it break plugins? Is there a reason not to have a strict
validation option?
In my code I will never use this as I consider it a terribly broken
method, but some gems use it and in one case
2006 Mar 29
5
How to skip password validation when updating other fields?
Besides the hashed password, which is saved to db, I have two
password-attributes in my User model:
attr_accessor :password, :password_confirmation
I have validations on these attributes, and I need them to work both on
create and update, since I have pages for changing and resetting the
password.
Now when I want to update just the user''s login name, I guess I have the
next
2006 Jun 27
4
Use link_to in a controller?
Hello.
I realize that link_to is a helper that generally only has use in a
view file, but recently I have come across a situation where it would
be useful in a controller. I am trying to create a flash[:notice] and
I want to link to another page. Of course, I could hard code the HTML,
but for the sake of consistency, I was wondering if there is a way to
abstract it from within the controller
2006 Jan 17
2
update_attribute and validations
Just in case it saves someone else the several hours of insanity I just
went through, update_attributes will not save unless the model
validations are satisfied, but update_attribute (the singular form)
will save the attribute to the database even if the model validations
would fail!
This appears to be a feature, not a bug
(http://api.rubyonrails.com/classes/ActiveRecord/Base.html) although
2006 Feb 27
4
update_attribute with Validation?
Does anyone know of a way to update individual attributes with
validation? update_attribute disables the validation checks in the
record model, so I''m wondering if there''s a workaround for this.
In my application, I want to allow the user to update some or all the
attributes without having to enter :password and :password_confirmation,
both of which are subject to
2006 Apr 14
2
spot the error (I can''t, I''m new)
I have a form that I want to use to update multiple
objects. In the controller,
@grades = Grade.find(params[:grade].keys)
@grades.each_with_index do |grade, i|
grade.update_attribute(params[:grade][i])
end
all_valid = @grades.inject(true) {|memo, c|
c.valid? && memo }
this doesn''t update the attributes as I would expect.
(I would just use