iOS Swift 3 "Login" apps: Best Method for storing/passing a User - ios

I was simply wondering what the best practice(s) were for passing/storing a User (I created a custom "User" class) when using a login-type application? I am trying to pass the appropriate logged-in user from the login screen to the rest of the application(embedded in a tab bar) or store it appropriately.
Any help is greatly appreciated!

Using a singleton is a tested (and my method-of-choice) practice when it comes to storing something like a user.
This link here should be a good starting place for you!
This link is more relevant for swift.

Related

Post on a different page in ruby on rails

I have been trying to solve a problem for some time in ruby on rails, but I haven't been able to achieve it and I can't seem to find a solution online (it must be easy but I am not sure what is the write thing to search for)
So, in my web application, I have a CURD table and I use modal to create new items in there:
Image 1
Image 2
This is working perfectly fine. What I would like to do is that when this is created I'd like to post in a different page that " ABC have been created by X User"
In my case that would be the chatbox container:
Image 3
So in my case, the green box is where I would like to say of what has been created and who has created it. I know that it is not a complex problem but I just can't seem to find the solution and I have been trying this for days.
Would really appreciate your help. Please let me know if you don't understand the problem and I can elaborate.
Thanks in advance.
Kind Regards,
Usman
You can create a separate model Notification (or similar name), and use an after_create hook in your original model to automatically create an instance of Notification. The Notification could store the information you want to display as attributes. From there, you'd have to figure out how to display the notification in the correct place on the 3rd page. One approach would be to query all your posts and notifications and sort them by created_at. There's other ways, it's up to you.
I get what you're saying.. but I am a little confused on the first part. So I have a model called Solr that has all the records associated with its User. What do I put in the after_create hook method to display records according to the timestamp in my Chat Box/ Events Log? Do you have an example of a similar implementation?
PS - Why do you say that I need to create a new model why can't I use the same model?
Thanks.

Section wise form for iphone application

Req UII am new to ios app development.
I need to make a user registration form where user can fill their details in 3 section- personal, professional and final registration.
I don't want to create a long form. Instead of that i want to create an UI like the attached image.
Please help me to achieve this.
Any tutorials/ blog which can help me to achieve this will be much appreciated.
try to use a segmented controller with 3 section you will show part of the form depending of view you want and all #IBOulet will be in the same view
here is a tutorial for it
https://www.ioscreator.com/tutorials/segmented-control-tutorial-ios10

Lazy registration with RESTful routing in Rails

I'm stuck figuring out the best practice...
I want to create a "following" system in a way that a user can follow a car (getting email updates when car price changes, etc). The part of implementation that's giving me headaches is when I want to introduce lazy registration by only using email.
Everything needs to work as AJAX requests.
In the interface, there will be a button to trigger the follow action, which will check if the user is registered or not. If a user is logged in, create a new CarSubscription item, otherwise display a form where he could type his email address. Once submitted, the form should create a user with no password (if email exists, ask for the password and log in) and then it should create the relationship item.
The challenge here is to use redirection after submission of the form to the CREATE action of the CarSubscriptionController. Since I can't redirect using POST I can't simulate the CREATE or DESTROY action.
The non-RESTful solution would be to create 2 actions under cars_controller: follow and unfollow and let them do the logic of creating entries and deleting them. That would enable me to just store the request path and use it after the user enters their email and logs in.
How can I achieve what I want using RESTful resources?
After trying to describe my problem here, it seems it's way too complicated and I am indeed very stuck... There are 3 different controllers and possibly 4 requests in this scenario.
Any help would be tremendously appreciated!
Please see my flow chart below:
Not an expert here, I don't know if it's the best solution, but what I have done in similar situation is :
In your controller, respond with javascript instead of redirecting the user
In your javascript file, use $.post(...) to issue a POST to your controller action
Et voilĂ !
You can also use ActiveResource to achieve this, but I actually never tried that solution : http://api.rubyonrails.org/classes/ActiveResource/Base.html#label-Custom+REST+methods
Person.new(:name => 'Ryan').post(:register)
Hope this helps
I had a very similar need and had trouble pulling the various bits of info on how to do this with Devise and Rails together into a working example. Here's a fully working example based on Rails 4, Ruby 2, and Devise 3.0:
https://github.com/mwlang/lazy_registration_demos

Rails How to easy show hide user fields?

I want easy implement a show hide funktion on sertant fields. Like birthday or email for a user. Example if the user has chosen to hide his email it wont display in his profile.
How do i create this?
Best regards,
A Rails (3) beginner
One option would be creating a model to store user preferences in to keep track of what the user wants to show/hide. Another option is to use one of the gems out there that will help you accomplish this task.
Just looking on github, I came across https://github.com/pluginaweek/preferences.

using authlogic to auto create users bypassing explicit user registeration

I'm wondering how to go about using Authlogic to auto register a user who chooses to use open id. Right now they have to register first before being able to login in, even if they choose open id, but I'd prefer if they could just login directly provided I get all the necessary details from the open id provider. But I'm not sure how to go about doing this?
Would I do it inside my user session controller or is there some fancy way to extend authlogic inside the model?
If someone could point me in the right the direction, i'd be grateful.
Here's an example of what I have now with the two pages:
http://morning-warrior-55.heroku.com/
Thanks,
Gaizka's version seems to work beautifully for me.
http://github.com/gaizka/authlogic_openid
Thanks, here's the example of it working:
http://big-glow-mama.heroku.com/
http://github.com/holden/authlogic_openid_selector_example/tree/with-facebook/
You have to use auto_register method in your UserSession model. Although i did try to solve the very same question. I succeeded with first time login/registration only.
Second time when user tries to login, the system tries to register it again.

Resources