1

I'm doing an app with Rails + Angular, with authentication via Devise. I haven't understood yet how I can save in angular the information after the login, such as user_id. And how can I use that information with ngRoute, and be able to do the correct GET and POST

Also I don't really understand what angular-resource is doing. I've been reading a lot of blog posts and questions here but I'm still confuse about all this

1 Answer 1

2

To let angular recognize current user id, what you can do is write it to javascript in layout file,

<% if current_user %>
  <script>
    var current_user = <%=raw current_user.to_json  %>
  </script>
<% end %>

Angular resource is javascript object wrap angular $http service, which allow you to interact with your rails resource. see the official doc

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.