In my api::controller i have few methods which follow the same type of
structure .
like :-
def index
render json:{:status => false, :message => 'qw'} if
params[:type].nil?
@stats =
ChildStat.get_child_stat(@child_profile.id,@profile.id,params[:type])
render json:{:status => false, :message => 'Child stats not
found'} if
@stats.empty?
end
def child_vaccines
render json:{:status => false, :message => "Please specify type:
weekly, monthly in parameters "} if params[:type].nil?
@vaccines =
ChildStat.get_child_vaccine(@child_profile.id,@parent_profile.id,params[:type])
render json:{:status => false, :message => "Child Vaccines not
found "}
if @vaccines.empty?
end
def child_meals
render json:{:status => false, :message => "Please specify type:
weekly, monthly in parameters "} if params[:type].nil?
@meals =
ChildStat.get_child_meals(@child_profile.id,@profile.id,params[:type])
render json:{:status => false, :message => "Child meals not found
"} if
@meals.empty?
end
So the above three methods follow the same structure . I am thinking to
refactor or else write them in more compact form .
I needs your help or suggestion for this .
thanks.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/1740555a-c712-49c6-8a4c-8fd405073ba4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.