What is this in rails?

    create! do |success, failure|      
      success.html { redirect_to admin_blogs_path }
    end

Seems to be doing alot but where is it....is it part of rails

Answers


Presuming this is being called in the context of an ActiveRecord model, this doesn't appear to be core. The function of create! is to either successfully create the record or throw an exception if a failure occurs. As such, the failure block wouldn't execute.

What it might be is a wrapper around the ActiveRecord object used by an ActionController instance and handles states accordingly. You may want to see where this method is defined in order to get a better sense of what it's doing.

One way to track down mystery methods is this:

raise method(:create!).source_location.inspect

You'll get an array that lists the source file and source line if it can be resolved.


Need Your Help

tar: how to bundle the “extract to directory XXX” info inside a tar file

shell tar

I know 'tar xf -C DIR' will untar the files in DIR, but is there an option to bundle the "-C DIR" information within the tarball when I create the tar file, so that when I use 'tar xf' the files wi...