I'm new to developing Ruby On Rails but have started creating a website for a mobile application that my friends are making. They are storing all of the data (Usernames, photos, posts...) on firebase (firebase.com) so we can all access it.
In broad terms I'm trying to figure out how to implement a lot of this with Ruby On Rails. Looking at most tutorials for rails, it seems like they assume the website has its own database. For instance when a user signs in, I use the user model to save the name, email and password. However this saves it to the rails database and not to firebase where all of the current usernames and passwords are stored. Should I ignore the standard rails method for user authentication and just sign the user into firebase or should I save this data to the rails database. If so, how to I keep that database in sync with firebase?
Related
I have a simple app where 200 people registered via facebook or normal email login. I wrote another version of the same app and deployed it to another server with higher RAM.
How do I transfer the user data like login creds to new server? I used Devise gem(if that helps).
PS: My database design also changed a lot.
Devise Gem uses DB to store the encrypted credentials. You would need to migrate the Database if the new machine also has a new DB. But if you are only migrating the application, then you can directly point to the same DB and things should work as they are.
I have a Rails app that successfully talks to a Postgres database. The app has full Postgres access rights and is successfully talking to the database.
I use Devise to authenticate my users. I know this is independent of PG but I mention it to make what I want below somewhat clearer.
The app maintains a (Devise) table of users. The app has several users and I want to have each user have different access (roles?) to the database.
I want to create a sandbox where User can issue PG commands but has, for instance, only readonly access rights to the database.
How do I do this. I've searched Google for several hours but I've come up with zilch.
How can I have API methods in a rails app receive user input, then make calls to a web API (e.g., Twitter) instead of querying the local database within the rails app? I also would like to store the user query in the local rails database. So the workflow would be like so:
User enters a query term in the app
Store the query term in the local database
Send out a call to a web API (e.g., Twitter API) - retrieve the data
Present data from the web API
I understand how to call web APIs in Ruby, but not sure where in a Rails app I put methods to do so, and how they are linked to user input.
I am somewhat new to Rails. I have looked at many tutorials, etc., but can't seem to find any help on this topic.
You can use gems like
https://github.com/jnunemaker/httparty
https://github.com/taf2/curb
or you can do it manually
How make a HTTP request using Ruby on Rails?
I am interested in deploying a Node.js along side my Rails application server. Just as a reference, I plan on using socket.IO to create a chat server, so users will be able to chat inside of my web application.
My current application uses Authlogic to authenticate users. I would like to ensure that only a user cannot read other users' messages, so I will need to authenticate the user session somehow. My Node.js will have access to my database, and I know Rails can store the sessions inside of the database, so I would like to use this feature to authenticate chat users. The problem is, I have no idea how to go about doing that. I'm not even sure what information is present in the session, and I do not know how I can use this information to authenticate a user.
Thanks in advance!
The rails session is tricky to use from other languages: it's just a serialised ruby object and pretty much the only documentation for the marshal format is the implementation/rubyspec.
However authlogic doesn't actually store anything in the session: it has a separate cookie (user_credentials by default, assuming your model is User)
The data in that cookie is "#{user.persistence_token}::#{user.id}", so you should be able to easily verify this from your js code
So I'm making a rails app that also utilizes node.js for realtime features. What is the best way to authenticate the users on the node app, if they were created with devise on rails? I've been thinking about saving the session id in the db, and then validating with that, or maybe displaying the user id in the page and then sending that to the node app when they connect. Or maybe something else entirely would be best. I'm using mongoose for my node orm and mongoid for ruby.
Storing the session id in your database is a valid approach, I do that in my own applications.