I have 2 Ruby on Rails 4 apps on the same server (they do not - and should not - share database):
deploy@Ubuntu-1404-trusty-64-minimal:~/applications$ ls
app1 app2
How do I exchange data between app1 and app2?
My current implementation is unstable and not secure:
app1 requests app2 to update first and last name of the user with username bobby
:
# app1
HTTParty.get("https://app2.com/update_full_name?username=bobby&first_name=Bob&last_name=Dylan")
app2 receives app1's request and processes:
# app2 app/controllers/some_controller.rb
def update_full_name
user = User.find_or_create_by(username: params[:username])
user.update_attributes(first_name: params[:first_name], last_name: params[:last_name])
end
I have read that ActiveResource has been removed from Rails 4. I never really understood ActiveResource anyway, so I will not explore it further and will prefer a different solution.