Rails: where to store something global is controlled by controller? [closed] - ruby-on-rails

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have Users in my app. Each of them has a Facebook profile (Koala is used for this).
So, I should store graph object anywhere. Next I should set facebook id for this graph. I do it from controller because user click "Sign in" and signs in.
Suppose User has friends: I want to get them by user.friends. This method should return facebook ids of user's friends. So, this method should use graph.
How to make all of this correct?

Hm... If I understood you correctly, you want to create and store global #graph object per User after he signs in. I think, we meet here with stateless property of HTTP protocol and one way to avoid it - using Rails session object. But this is wrong way in my mind.
Another way - create #graph every time after User signs in. And another way - using something middleware machinery, like Redis. You can store in Redis any information about User in string. For example, you can store in it set of User Facebook friends and get them any time you need.
But surely there is another way, I think )

Related

Using deeplinks to share User profile [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Currently, I'm using firebase to store the users in the database but I wanted to add a link to each specific id so the user is able to copy their profile link and send it to a friend if they have the app or not, I read a little bit about dynamic links from the firebase as well, but still lacking the idea of how to connect a users profile to a deep link.
Wrap user id (or profile id) somehow like: link.co/user_id
In dynamic link handler method you have to get user id (or profile id) from link and send it to ProfileViewController, then you simply open it as you always do from other place in application.
There's good article to read how exactly you will do this: https://www.yudiz.com/deep-linking-in-ios-using-firebase/

How to save the state of the application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm working on a project in which I'm using oauth to authenticate with peoples stripe account. Part of this process is to send the user off to the stripe website, and then after they log in they are sent back to my application. The problem I'm having is that the stripe authentication is part of a set up process. So I'd like them to return to the place they were before they were sent away, i.e the same page and the state of the form they were in to be the same.
What would be the best way for me to do this, I've thought about saving the form state in the session, the problem with this is it requires a lot of awkward parsing, and can be quite brittle.
Any help would be greatly appreciated.
I'd create a database record before you go to Stripe keying with a GUID and then store the GUID in the session. Then when you come back you can load the database record and recreate whatever you need.
When redirecting the user to the OAuth form on Stripe's site, you can pass a state variable. Stripe will pass back the same variable when redirecting the user back to your return URI.

Instagram-API integration authentication [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm developing an online platform, where one type of users (User Type 2) create a profile in an web-app and submit data into the web-app. Another user type (User Type 1) is then able to view this data from an iOS-app. See image below for overview.
I want the User Type 1 to be able to (without logging into instagram) watch User Type 2s Instagram Images.
I have been playing around with the Instagram-API, registered as a developer, and registered a client app, which is now in sandbox mode. But I find it a bit hard to get started, and a grasp about which user types need to be authenticate.
Is it possible to make the iOS-app Authenticate with the API in the background, and then pull images from any instagram user?
If so, what is the simplest way to get started at pulling images down to the iOS-app? Maybe you have some good suggestions or tutorials...
Technically, you don't need to authenticate to get a user's photos. You might need it for the iOS SDK, but if you want to use HTTP calls you can get a JSON blob of all the photos by just adding /media/ after the user address, like so: https://www.instagram.com/dnlrsn/media/.
Obviously, this doesn't allow for interacting with the images, but from what I understood from your question, you don't need that.

Solution for voting without attachment to a model? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
My application is one page contract. I would like users to be able to sign the contract by clicking on a button. The contract is not a resource; it's plain HTML.
Every solution I have found so far relies on having a model that acts as votable. How can I implement a simple button that users may only click once, and display the number of users who have clicked it?
It's not possible to do this with static pages, at least not in a way that is clean and secure.
Think about it this way: every user is looking at a copy of the contract, which is being displayed to them on their browser (the client). If you want users to be able to cast votes that persist and be aware of votes cast by other users, then you need a server that keeps track of it centrally. That's why the solutions you have found so far rely on having a model, presumably backed with a table.

asp.net mvc4 get user information when user reload page [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I created custom login which use FormAuthentication. When user use login page, I get user information and save to session variable. If user check remember password, after user close page and reopen, authentication of user is authenticated, in this case, I can not get information of user.
How do I retrieve information of user in this case
Use cookies to store user id or something unique. Then get it and query database for example.
My solution:
After the user log, I create random TOKEN key, save it into DB to specific user, and add to Respone Cookie (the lifetime of the cookie, you can specify the desired).
Then, when user come again, I get cookie and check it value. If everything is correct, install the session variables.

Resources