similar to: Making touch more efficient

Displaying 20 results from an estimated 10000 matches similar to: "Making touch more efficient"

2012 Oct 23
7
Not updating the updated_at field
This is for Rails 3.1.1 I have a field called last_seen in a model. This field will be updated when the something about the record is seen in the real world (don''t worry about this part) So I go x.update_attribute(:last_seen, Time.now) and the following happens is UPDATE "blah" SET "last_seen" = ''2012-10-23 08:57:46.179288'', "updated_at"
2008 Apr 07
7
Saving attribute
Something is getting lost here. def create @home = Team.find_by_user_id(current_user.id) for player in @home.players player.update_attribute(:game_id, @game.id) end end def show @players = Player.find_all_by_game_id(params[:id]) end view <%= @players.size %> # mistakenly equals zero Played with the console and everything should be working fine...
2011 Aug 14
5
Puzzled with form on multiple table rows
I''ve got a table of events, and each event has a boolean attribute is_ten_event. On each row of the table is a chekbox to edit the value of is_ten_event, so that multiple rows can be edited with one submit. In order to allow boxes to be un-checked as well, the logic in the controller works like this get array of events from checkboxes that are ticked. make all events.is_ten_event =
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is something borked? >> c=Contact.last => #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone: 2147483647, account_id: 8, created_at: "2009-11-27 18:16:25", updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone: false,
2013 Jan 20
20
ActiveRecord::Persistence.increment! requires a row lock to ensure isolated updates
The method is here: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/persistence.rb#L288. The method takes the in-memory attribute value and increments it by the specified amount. A safer approach (from an isolation standpoint) would be to let the database determine the value. Instead of telling the database what value to persist in the database, the SQL can written
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:
2008 Jun 16
2
call_backs Is it?
Hi I have the models 1.ServiceDeskTicket with fields id --- number --- service_desk_status_id -- created_on -- updated_on etc 2.ServiceDeskActivity with fields id -- service_desk_ticket_id -- description -- created_on -- updated_on 3.ServiceDeskAttachment id -- service_desk_ticket_id -- attachment -- created_on -- updated_on Relations as ServiceDeskticket has_many
2011 Nov 02
4
undefined method `updated_at' for #<Classified:0x686c5e4>
HEllo, I have the following problem with rails, I am new in this...is there anyone who explain to me what´s happens? Thanks See below: NoMethodError in Classified#show Showing app/views/classified/show.rhtml where line #17 raised: undefined method `updated_at'' for #<Classified:0x686c5e4> Extracted source (around line #17): 14: 15: <strong>Date Posted:</strong>
2009 Oct 16
5
Rails 2.3 Model.touch(:column) always also updates :updated_at???
Hi, Am I the only one (i.e. something I do is wrong), or does the touch- method always update updated_at, even though giving it a column to use INSTEAD is meant to update just that column??? Thanks, Michael
2008 Nov 13
5
Touch an ActiveRecord - timestamps
When I update an ActiveRecord, i would like to "touch" one of the related objects, that the updated record belongs_to, in order to update the timestamps on the parent record, although i don''t want to change any of the data in the parent. Whats the accepted way to do this? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You
2010 Nov 19
1
Help: delegated association 'App' returning ActionDispatch::Integration::Session instead
class Foo < ActiveRecord::Base has_one :bar delegate :app, :to => :bar end class Bar < ActiveRecord::Base belongs_to :app def self.attribute_column_names return @@attr_columns if defined?(@@attr_columns) readers = content_columns.map { |n| n.name.intern } - [:created_at,:updated_at] @@attr_columns ||= readers.map { |k| [k, "#{k}=".to_sym] }.flatten end
2006 May 19
5
How to determine if an object has just been created
Is there a built-in way to determine if a model object has just been created (ie. this object was the one that was originally persisted)? I can''t see it anywhere in the AR code, but thought I''d check. I want something like: p = Person.create p.original_instance? # true Is this built-in or should I just patch AR? -Jonathan.
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
2009 Jun 27
1
Problem with :touch in belongs_to
I''ve read in rails api that there is a touch parameter and I want to use it in my application. I have something like that class User < ActiveRecord::Base has_many :phones after_update :updated def updated ... end end class Phone < ActiveRecord::Base belongs_to :user, :touch => true end I want that every change of any phone number would change User updated_at
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
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,
2011 May 28
4
Rais 3, nested attributes problem with paperclip
I have two models, one model girl and one girl_photos (a file upload asset). The only code I have in models which describes the association is: For the girl => belongs_to :girl and has_attached_file :photo For the model girl_photos => has_many :girl_photos and accepts_nested_attributes_for :girl_photos I''ve tried to save as a nested attribute the photo, it saves the association
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
2010 Apr 15
12
[PATCH] Add :touch option to has_many associations
Hi, it would be nice to have the touch option in has_many associations also. I have a scenario like this: An user has some credit (money) and some advertises. Each advertise can be enabled or disabled depending on some rules. One of the rules is that the user should have money. Each time the money of the user change, the advertises are touched, enabled/disabled and then cached, as they are much
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