I’ve recently decided to pick up Rails, this happened after a newly discovered infatuation with Ruby, I'm practically scratching the surface.
I, as most developers (experienced or otherwise) trying to pick up rails, have discovered how greatly it relies on COC(convention over configuration), having said that, I'm finding it increasingly difficult to find answers the more specific my questions get so thought I might ask the community :)
Even after visiting the second page of the google search results.
I'm building a web app that relies heavily on an external API, and I'm not quite sure how to deal with activerecord (since I don't think I'll be using is), but I do need to use sessions. What is the Rails best practice in this situation?
**I still want to use all the built in features that Rails offers.
I was thinking maybe I should create the models to represent the data pulled from the web services, and populate them from the requested data.
Or
Maybe disable Rails active record when creating the app, and manually creating a single model for session.
Assuming I won't need activerecord what are the best ways to handle sessions in Rails?
How often should I rely on JavaScript while building a Rails app?
I really appreciate any help, and any Getting-Into-Rails advice is more than welcome.
You can choose to store your session data in a database using ActiveRecord but this is certainly not a requirement. By default, Rails uses Cookies to store session data. This is provided by CookieStore.
So when a user logs in to your Rails application, you can first authenticate their credentials with your API and on success, store their user_id
(or token or whatever you're using to identify this user) in the session. On subsequent requests, you can use the value stored in the session to identify the user.
In terms of structuring your models to talk with your API, ActiveResource is a good option although you may find it a bit finicky depending on the API you're consuming. Her is another alternative.
If the API you're using is a REST API that communicates via JSON, those libraries should work fine for you.
So to answer your questions...
Hope this helps.