how can I pass a variable from a model method to the controller that
calls this method?
In the below code, I tried by placing “return @errormessage” in the
model method and then trying to retrieve it in the controller, but it’s
wrong. What’s the correct way to do that?
Here’s what it looks like until now (simplified)…
In my controller:
if @user.does_my_check_pass? # <= calls the model method
flash.now[:error] = @errormessage # <= the variable from the
render :update do |page|
page.replace_html ‘flash_messages’, flash_messages
In my model:
if […some conditions…]
return @errormessage = “There was an error.” # <= the variable
Thanks a lot for your help!