M
Mc Ieong
Hi! I am a newbie in Ruby programming. I wrote the following functions
and they works fine, but it seems very stupid of not using just one
parameterized function to update the same fieldsfirst_name,
:last_name), can everyone give me some hints about that ?
def update_first_name
if request.post?
if !params[:data].nil?
Employee.update(params[:id], :first_name => params[:data])
end
end
rendernothing => true)
end
def update_last_name
if request.post?
if !params[:data].nil?
Employee.update(params[:id], :last_name => params[:data])
end
end
rendernothing => true)
end
Thanks in advance.
Ieong
and they works fine, but it seems very stupid of not using just one
parameterized function to update the same fieldsfirst_name,
:last_name), can everyone give me some hints about that ?
def update_first_name
if request.post?
if !params[:data].nil?
Employee.update(params[:id], :first_name => params[:data])
end
end
rendernothing => true)
end
def update_last_name
if request.post?
if !params[:data].nil?
Employee.update(params[:id], :last_name => params[:data])
end
end
rendernothing => true)
end
Thanks in advance.
Ieong