I'm trying to refactor my code according Rails Best Practice. Now I'm face with a problem where I have to instance variable at controller and I can't move them to model. Here we are:
feedbacks_controller.rb
def get_feedback
...
@employee = Employee.find_by(:name)
if @employee.blank?
...
else
@client_feedback = Feedback.new(:screen_name => @screen_name, :feedback => @feedback)
@client_feedback.employee_id = @employee.id
@client_feedback.client_id = @employee.client_id
@client_feedback.location_id = @employee.location_id
@client_feedback.save
According to Rails Best practice Move Model Logic into the Model all assignments inside the else need move on to model, my doubt is how I will start the @employee
instance variable inside of model?
Aucun commentaire:
Enregistrer un commentaire