Displaying 20 results from an estimated 3000 matches similar to: "reintializing a model object to invoke model callbacks"
2006 Jul 06
1
<model>.update(...) not calling before_update callback.
Hi,
I''m doing a <model_name>.update(....) but I''m noticing that my
before_update callback is not being called. If I do a find and then a
save!, I notice that it is called. The problem with a find and save in
my case is that I''m not able to set all my attributes in one shot by
saving params["user"] and since I can''t do this, my overloaded
2006 Feb 21
2
ActiveRecord before_ callbacks question
Hi!
I need to set the primary key in a model and postgres table to something
different than id. View Edit and such works in the scaffolded
controller. However if I click in the controller below the list of data
onto New then I get an error message like this:
Showing app/views/admin/_form.rhtml where line #5 raised:
undefined method `nr_before_type_cast'' for
2009 Mar 05
6
About before_* callbacks
Hi
I have an problem about before_* callbacks.
I have a model named: Event
And I don''t want anyone to destroy or update any records in Event
model.
So:
[code]
class ActiveRecord::Base
before_destroy :log_illegal_operations
before_update :log_illegal_operations
private
def log_illegal_operations
Event.create({:key => "illegal operation", :value =>
2006 Jun 06
4
Checking if a directory is empty using File
Hi,
I have one minor issue. I''m trying to check whether a directory is empty
given some path to the directory.
My code does the following:
if(File.directory?(dirpath)) # dirpath = public/images/1
if(File.zero?(dirpath))
FileUtils.rm_rf(dirpath)
end
end
The problem is, while testing this, if I put a file in the directory and run
the above code, it still ends up deleting the
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
2015 Apr 05
3
[LLVMdev] alloca not in first bb behaving differently
Here is some IR that is working and executing as expected -- All allocas
are in the first basic block, and only updates happen in other basic blocks.
define i32 @f() {
entry:
%x = alloca i32
store i32 333, i32* %x
%i = alloca i32
store i32 11, i32* %i
br i1 true, label %if.then, label %if.else
if.then: ; preds = %entry
store i32 3, i32* %i
2006 Jan 03
2
Stopping a save from the before_save
What''s the better thing to do in a before_save if you don''t want the
save to continue?
raise an exception, or do an errors.add or both?
Thanks,
Chris Nolan.ca
http://kweschun.com/ - Do you have a Kweschun?
2015 Apr 05
2
[LLVMdev] alloca not in first bb behaving differently
It's not great IR, but it doesn't look like it should actually crash, just (without SROA) produce comparatively bad code. The alloca is only referenced in the basic block that it exists. If this isn't expected to work, then we should probably improve the documentation of alloca in the language reference.
David
> On 5 Apr 2015, at 04:55, Eric Christopher <echristo at
2013 Sep 17
1
[LLVMdev] [lld] Handling non SHF_ALLOC sections.
On Mon, Sep 16, 2013 at 6:48 PM, Shankar Easwaran
<shankare at codeaurora.org>wrote:
> Hi Michael,
>
>
> On 9/16/2013 7:23 PM, Michael Spencer wrote:
>
>> Debug info linking is currently broken due to how we handle reading and
>> laying out non SHF_ALLOC sections. I posted a patch that partially fixes
>> this, but it's both the wrong approach and
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
2015 Apr 05
2
[LLVMdev] alloca not in first bb behaving differently
Thanks all.
David why do you say it is particularly bad IR (other than not having gone
through SROA). Is it the multiple blocks for early returns? That is how I'm
supporting early returns in the middle of a basic block. I couldn't find
any other way.
On Sun, Apr 5, 2015 at 6:24 AM, David Jones <djones at xtreme-eda.com> wrote:
> Data point:
>
> I use (rarely) alloca in
2006 Jul 21
1
Capistrano before and after tasks
I try to extend db:test:copy_structure task to poulate test database
with some existing data everytime i run it.
It seems that "after_" task is not called as should be:
> namespace :db do
> namespace :test do
> task :after_clone_structure do
> puts "after_clone_structure_to_test"
> end
> end
> end
Anyone know what I am doing wrong?
2006 Aug 25
7
disabling automatic indexing in acts_as_ferret
I''d like to be able to enable/disable the automatic indexing of
documents acts_as_ferret does. Something like MyModel.disable_indexing
MyModel.enable_indexing would be perfect. I need this because I do some
indexing that requires visiting the parents of the model objects and my
import method imports the children first, so the information isn''t there
yet. I''d like to
2006 May 30
3
expected, got Fixnum problem.
Hi,
I was wondering if anybody knew what ''<some type> expected, got Fixnum''
means? My code looks like the following:
begin
anevent = Event.new
anevent.title = params["event"]["title"]
anevent = session[:user_id]
com = Community.find(params[:id])
com.events << anevent
rescue Exception => exc
...
end
But I get an
2006 Aug 01
8
Decoupled observers for controllers?
In the Rails Recipes book the recipe "Keeping track of who did what"
explains how to do decoupled observing of models.
In my application I''d like to do a similar thing but watching the
controllers. For example, when somebody hits the login method of the
Security controller, I''d like to make a note of it. In this case I
could observe the User model and watch for
2013 Jan 01
1
Error Processing Drive
Hi chaps,
So my general problems with disks disappeared once I understood it was
an SELinux problem. However I''m still finding in the DomU when I run
through my kickstart that I''m getting an error which says:
"Error processing drive: xen-vbd-51712 ........ this drive may need to
be reinitialized"
See: http://d.pr/i/YrH8
If I go ahead and reinitialize it, the
2017 May 17
2
Callback re-registration after libvirtd restart
Hi all,
I'm using libvirt-go and I following code to listen for lifecycle events:
func event_listen() {
log.Printf("event_listen %s", conf.Libvirt.LocalUrl)
hv, err := libvirt.NewConnect(conf.Libvirt.LocalUrl)
lifecycleCallback := func(c *libvirt.Connect, d *libvirt.Domain, event
*libvirt.DomainEventLifecycle) {
event_message(c, d, "lifecycle", event)
2017 Jun 26
1
64bit feature in ext4
At the moment, Syslinux doesn't support the 64bit feature of EXT4
(which is now set on by default).
Considering the following code, I am wondering whether such support can
be added to Syslinux.
GRUB2 supports the 64bit feature of EXT4 since:
2012-07-02:
Experimental support for 64-bit
http://git.savannah.gnu.org/cgit/grub.git/commit/grub-core/fs/ext2.c?id=
2013 Sep 17
0
[LLVMdev] [lld] Handling non SHF_ALLOC sections.
Hi Michael,
On 9/16/2013 7:23 PM, Michael Spencer wrote:
> Debug info linking is currently broken due to how we handle reading and
> laying out non SHF_ALLOC sections. I posted a patch that partially fixes
> this, but it's both the wrong approach and doesn't handle multiple input
> files with debug info (wrong relocation values).
>
> The first issue is representing non
2006 Apr 26
0
Observer method names
I haven''t seen it documented anywhere, but can observer methods be given
a prefix in their name like ''after_'' followed by my controller''s method
name?
For instance I have a couple of methods called ''create'' and
''create_reply''. Can I have ''after_create'' and ''after_create_reply'' in
my