Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Strong Parameters</h1> <p>This has been an issue with rails for a long time, in Rails 4 they are introducing "Strong Parameters"</p> <ul> <li><a href="https://github.com/rails/strong_parameters" rel="nofollow">https://github.com/rails/strong_parameters</a></li> <li><a href="http://railscasts.com/episodes/371-strong-parameters" rel="nofollow">http://railscasts.com/episodes/371-strong-parameters</a></li> </ul> <p>You can use strong parameters gem in rails 3 applications as well</p> <h1>Alternative: Context Attribute</h1> <p>Another way to do it, introduce a context variable on the user model - *Note I am not familiar with the 'as' option for attr_accessible*</p> <pre><code>class User &lt; ActiveRecord::Base attr_accessor :is_admin_applying_update validate :company_id, :presence =&gt; :true, :unless =&gt; is_admin_applying_update validate :disabled, :presence =&gt; :true, :unless =&gt; is_admin_applying_update validate :first_name, :presence =&gt; :true, :unless =&gt; is_admin_applying_update # etc... </code></pre> <p>In your admin controller set the is_admin_applying_update attribute to true</p> <pre><code>class Admin::UsersController # ... def update @user = User.find(params[:id]) @user.is_admin_applying_update = true @user.update_attributes(params[:user]) </code></pre> <p>NOTE: you can also group the validations and use a single conditional</p> <ul> <li><a href="http://guides.rubyonrails.org/active_record_validations.html#grouping-conditional-validations" rel="nofollow">http://guides.rubyonrails.org/active_record_validations.html#grouping-conditional-validations</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload