Ruby code refactoring


I have 4 actions in my controller and I have some conditions to be
checked inside each action. what is the best way to do so? For Eg. the
condition to be checked for each action is below

if params[:id] == $
@rec = $
elsif params[:id] == $
@rec = $
render :json=>{“Error”=> “Person with #{params[:id]} does not
exists”} and return

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs