Ruby on Rails Thursday, March 31, 2016

> It depends on whether that is ever supposed to be nil. If it is then
> you just need to test for that in your code before using it.
>
> Colin


In my controller's edit_privilege method I changed the below line

from
@user = User.active.first(:conditions => ["username LIKE
BINARY(?)",params[:id]])
to
@user = User.active.find_by_username(params[:id])

and it solved the problem. but dont know why not the above line working?


def edit_privilege
@user = User.active.find_by_username(params[:id])
#User.active.first(:conditions => ["username LIKE
BINARY(?)",params[:id]])
@employee = @user.employee_record
@privilege_tags=PrivilegeTag.find(:all,:order=>"priority ASC")
@user_privileges=@user.privileges
if request.post?
new_privileges = params[:user][:privilege_ids] if params[:user]
new_privileges ||= []
@user.privileges = Privilege.find_all_by_id(new_privileges)
redirect_to :action => 'admission4',:id => @employee.id
end
end

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/65370b55dd3db2d399151af5e58f6f9a%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment