Retrieve rails/devise current_user from Backbone?

(Just beware that only public information should be accesible in the client side).

Up vote 2 down vote favorite 1 share g+ share fb share tw.

I have an app where I manage the sign up/in/out with Rails through Devise. When I'm logged in, i'm redirected to Dashboard#index where Backbone start. I would like to retrieve somehow my current_user.

Id and current_user. Token in Backbone. My only idea is to have this in my dashboard.html.

Haml :javascript window.App. Current_user. Id = "#{current_user.

Id}" window.App. Current_user. Token = "#{current_user.

Token}" ruby-on-rails devise backbone. Js link|improve this question asked Mar 6 at 11:25damienbrz3517.

(Just beware that only public information should be accesible in the client side) For a more elegant solution you can create a UserSession Backbone model and fetch it from the server as normal Backbone model. Window.App. UserSession = Backbone.Model.

Extend({ urlRoot: "/session" }); If don't want to make this extra request you can load the model explicitly with data already available in template rendering time: window.App. Current_user = new window.App. UserSession({ id: "#{current_user.

Id}", token: "#{current_user. Token}" }).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions