similar to: saving an ActiveRecord without trigging the callbacks

Displaying 20 results from an estimated 2000 matches similar to: "saving an ActiveRecord without trigging the callbacks"

2006 Jul 17
5
Keeping attributes of two models in sync
Hi, I have a Product and a corresponding Keyword (1:1 via belongs_to and has_one). I want to ensure, that two attributes (:name) of the two models alway stay in sync. What''s the easiest way to accomplish that? I did play around with before_/after_save hooks and with AR::Observers but in the end I''d always get infinite recursion... Thanks, Timo
2010 Oct 01
20
Paperclip not executing FFMPEG properly
Im using a customs processor to run ffmpeg on a video to create a thumbnail. So far so good. Except when I do: cmd = "-i #{@file.path} -f flv -s 320x240 ~/Downloads/foobar/q.flv" success = Paperclip.run(''ffmpeg'', cmd) Console is reporting: ffmpeg ''-i /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE+++TI/-Tmp-/stream, 16824,1.mpeg -f flv -s 320x240
2006 Aug 15
1
Update attribute without validations or any save hooks?
If I wanted to update an attribute with calling any validation or any of the before_save and after_save hooks, how would I go about doing this? Supposed the update_attribute method calls the before and after save methods. Thanks for your help. -- Posted via http://www.ruby-forum.com/.
2008 Feb 25
6
Event Calendar/Scheduler Implementation
Hi there. I am a RoR newbie and come from the Java/C# perspective. After digging into Rails I would like to convert an ASP.NET project -that served as a protoype- to RoR. The only thing that I havenĀ“t got a good solution for is handling calendar events. With that I specifically mean creating, moving an event or a set of events as well as recurrence handling - similar to Google Calendar if you
2012 Nov 10
6
Suggestion: `before_save on: :create` should either work or raise an exception
There''s a small inconsistency in ActiveRecord''s callback syntax that has tripped me up before. It wouldn''t be a big deal, but it can lead to a silent failure. I''d like to suggest that it either be made consistent or be made to fail loudly. The issue is that to do something before validating, but only when creating, you use `before_validation on: :create`,
2010 Aug 18
11
When after_save isn't after the save....
I have a Production model, which represents a farmer''s crop. After create (via after_save) I call a method that creates one or more Supply models, which represent a week of anticipated product harvest. After each of those are created, a class method gets called that tries to match each new Supply with outstanding orders for the same time period. If a match is made, a transaction (an
2009 Jan 18
2
after_save -- stack level too deep
Hi all, I''m running into a brick wall trying to figure out my problem here. I have a model that has a boolean property called "paid". I''d like to add the following to my model: def after_save self.amount == self.splits.sum(:amount) ? self.update_attribute (:paid, true) : self.update_attribute(:paid, false) end The problem is, when I do this I get an error that
2008 Feb 28
2
change drop down list to radio buttons
In my RoR app I would like to change a drop down list, which dispays a list of colors selected from the database. Instead I would like to create a radio button for each color. The user is allowed to check one color and this will be saved back into the database as the color for this user. I don''t know how to do this. Currently it looks like this: <%= select(:user, :color_id,
2008 Mar 11
4
Host recommdations
Hi I want to host a simple site with Ruby quickly at first no DB - just a site that can run a Hello Ruby script will use a template page Also I am very new to this so help will be need any suggestions for a Ruby Hosting service? ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page.
2008 Mar 07
6
creating a model registry
Hi all, This is a problem I''ve approached so many times and always worked around, that now I want to solve it once and for all. Say I have something like this: --- class X < ActiveRecord::Base acts_as_wacky end module Wackinator class ControlAllWackos @@wackos = [] def self.kill_wackos @@wackos.each(&:kill) end end def acts_as_wacky
2007 Aug 30
1
belongs_to with foreign keys that reference non primary key columns
Hello, I have a situation where the foreign key into a table doesn''t correspond to that table''s primary key: my_table ------------- id (pk) name ... other_table -------------- id (pk) my_table_name (fk references my_table(name)) ... I want to be able to say something like: class OtherTable < ActiveRecord::Base belongs_to :my_table, :foreign_key => { :my_table_name
2006 May 18
3
ActiveRecord after save new and old values
I want to write a function that after an ActiveRecord saves successfully, can show me what the before and after values of a particular column are. Is this possible without creating a separate object before modifying the current one? -John
2006 Feb 11
5
after_(read|find) callback?
I am pondering the possibility of encrypting/decrypting some fields in a SQLite backend on-the-fly. The point of the message is not security, I know that''s broken, but whether there''s a technique that provides on-the-fly save/read filters. Of course the solution would need to work transparently in joins, so user.posts.last.title would do the right thing if title
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
2012 Jul 07
18
Problem processing text file after uploading
I''ve got a web-app currently partially working. The user uploads a .txt, .docx or .doc file to the server. Currently the model handles those files, saves some metadata (the extention and orig filename) then saves the file to the hard drive. Next it converts the doc and docx files to plain text and saves the output to a txt file. My problem is I want to copy the plain text contents of
2006 May 09
11
model filter?
Hi All, Is there a way to filter / modify the output of a model class before it''s returned to controller/view that''s calling it? Example: I have a field phone_number which I always want to preformat using the number_to_phone() helper.... Any help is appriciated. Thanks! -- Posted via http://www.ruby-forum.com/.
2008 Mar 18
2
update_without_callbacks?
Is there a new way to call a method similar to "update_without_callbacks" on an "after_save"? I need to calculate a total amount on a row after the row has been saved. --~--~---------~--~----~------------~-------~--~----~ 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
2008 Jul 28
1
callback executed like after_save but after transaction
I''m trying to add some code for my ActiveRecord class so that it is executed whenever an object is updated, this code is a seperate process that reads from the same table represented by my model class so when it runs it needs the database to be up to date. In the following situation this is fine: # MyModel def after_save `/usr/local/bin/update_models -i #{self.id}` end # controller
2008 Oct 28
7
aasm callback order?
Hello! Sometime ago I ran across a webpage where someone had identified the full callback sequence for an object lifecycle including AASM with it''s :enter and :exit and whatnot callbacks. Unfortunately, I can''t find it and searches don''t seem to help. Does anyone have a reference to a page that shows the callback sequence with Acts As State Machine (the gem)? I think
2008 Feb 01
3
Which version of Ruby for Rails 2.0.2?
I''m using ruby 1.8.6 p111. But some people seem to think that version 1.8.5 is better. Should I give it a whirl? --~--~---------~--~----~------------~-------~--~----~ 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