I have a form that allows a User to add/edit the additional Users or LoginUsers to/on their account, but the wrong validations are run when updating a User to be a Login user or vice-versa. For more clarity (with only one case shown): class User < ActiveRecord::Base end class LoginUser < User validates_presence_of :login validates_presence_of :password end class UsersController < ApplicationController ... def update @user = @account.users.find(params[:id]) # revoking login privledges if @user.is_a?(LoginUser) && !params[:allow_login] #switch the type here, tried a few different things but none work @user[:type] = "User" end if @user.update_attributes(params[:user]) flash[:notice] = ''User successfully updated.'' redirect_to(edit_account_path) else # edit action rendered with errors on login and password render :action => "edit" end end ... end Can someone help me solve this? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jared Moody wrote:> I have a form that allows a User to add/edit the additional Users or > LoginUsers to/on their account, but the wrong validations are run when > updating a User to be a Login user or vice-versa. > ... > # revoking login privledges > if @user.is_a?(LoginUser) && !params[:allow_login] > #switch the type here, tried a few different things but none work > @user[:type] = "User"@user.save_without_validation! @user = User.find(@user.id)> endTry adding the above two lines. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ 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 from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---