Forum: Ruby Ruby code refactoring

Ecec81af7caddc8730eee285475df4da?d=identicon&s=25 ruby rails (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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.