ruby on rails - Accessing a parameter within a plugin -


I am trying to modify the vestal_versions plugin to accept a parameter set on savings. This will work as a new flag to determine when it will make modifications on updating parameters. Currently it will always run on updates when a new revision is required. The affected area of ​​the unplanned plug-in code is here:

  after_update: create_version ,: if = & gt; : Needs_version? Def create_version versions.create (: changes = & gt; changes.slice (* versioned_columns) ,: number = & gt; (last_version + 1)) reset_version end  

See on the submission "Balrevision = N" how will I pull in this parameter and what I will use to condition it when only run "balreview = y"? It seems that to modify the after_update filter would it be clean?

Here's the log of the data being provided on the update.

  Processing Notes # Controller # Update (for 521.0.0.1) 2009-12-05 at 13:25:45 [PUT] Parameter: {"Authenticity_token" = & gt; "#########################=", "Id" => "4", "forcerevision" => "n" , "Note" = & gt; {"Notebook_id" => gt; "", "public" = & gt; "n", "body" = & gt; "One Version Note", "Title" = & gt; "Version Note Test", "Flag" = & gt; "Important", "Star" = & gt; "Wrong", "tag_list" = & gt; ""}}  

The easiest way to do this An attr_accessor will be added when a model is announced to be edited.

Then override need_version? To check that feature,

anywhere in LaserLemon: :: VestalVersions :: ClassMethods # versioned Add this line:

  attr_accessor: force_reversion  < / Pre> 

Then rewrite lasermemen: VestalVersions :: InstanceMethods # needs_version? To check this feature:

N.B. Because of which the checkboxes are controlled by "0", that is considered incorrect for the checkboxes and bullion fields, but this is the correct value in Ruby. So we can not just check whether force_reversion does not evaluate incorrectly.

  def needs_version? ! (Versioned_columns and changed) .empty? || ! [Zero, "0", 0, false]. Include? (Force_reversion)  

and you are all set. Just pass any value to Force_reversion as if it was a column.

Following the above modifications with the following model:

class user

  @ user.update_attributes (: Force_reversion => true: unversioned_column = & gt; ; New_value)  

Or in a form:

  & lt;% = form_foruser do | F | & Gt%; & Lt;% = f.label: force_reversion, "New Version Force"%> & Lt;% = f.check_box: force_reversion% & gt; ... More fields ... & lt;% end% & gt;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -