Forum: Ruby Ruby code refactoring

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
54569182ca70ea857943ecbbb82c2864?d=identicon&s=25 ruby r. (rubyonrails)
on 2014-04-22 07:14

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 topic is locked and can not be replied to.