How to model common information for Rails application [closed] - ruby-on-rails

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 4 years ago.
Improve this question
I'm a bit new in rails development I'm modeling a website with few resources and so far so good. But here is my question:
I would like to allow the admin users to manage information show in most of the pages: Application name, telephone number, address, default email and this kind of things.
My current idea is make a model Property with name and value, but somehow I'm not convinced about this approach because I'll need to access the database to get this values for every request.
Thanks everyone for your time! :D

This seems like an OK approach. If you implement caching, it no longer will hit the db with every request, and honestly it probably isn't really that big of a deal even without the caching. Build it the way you need, and optimize afterward, if necessary.
With all this being said, it may be worth considering how much things like the phone number are going to change, and balance the cost of developing a dynamic solution against the time it would take to change once, 3 years from now (if the number ever does change), in a partial.

Related

How to make one page real-time in Rails app? [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
I have an app that is already fully built, the only thing I'd like to add is real-time rendering of one of my pages.
Suppose it is a page with all the pizzas. When pizza is added to the database, I'd like page to show it without refreshing.
I know you can do it with websockets, but is there any easier way? Could, eg, AngularJS help here (as I understand it refreshes the page contents as soon as model is changed)?
Well you could make a small service in Angular that asks the server like every 15 secons or so, to see if there are new pizzas added to the database. (Say the last time you took the pizzas from the server you had 15 of them returned. Now you send that number 15 back with the check request and compare it with the database)
If so, it will call the query method in the pizza Angular service to fetch the new pizzas.
If this is a small table with often changing info then I would also suggest to migrate this model into Redis instead. Asking info repeteadly from Redis is a lot cheaper than it is to ask like this from a database.

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.

What stage to add authentication? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm about to start building a Rails app that will eventually need to vary CRUD access by user (i.e. which pages do they see, which can they edit, etc).
Is there a best stage of the development cycle to incorporate this?
Part of me feels like it should be the very first thing, since almost every piece of the interface will in some way rely on checking the user's ID, and it will be an inherent part of the DB structure.
Another part feels that this would overcomplicate things to start out with, and that I should instead build the core parts of the app, then layer on the authentication/authorization later.
Are there any best practices around this sort of thing?
I would say that if your system will rely on some kind of authentication... Why wait?
Let's say that you start developing your application without the authentication layer but at the same time you know that at some point you will have to do it. That means that at some point you will develop the authentication layer, and most likely you will have to refactor what you have already built to adapt it to this new layer.
Also, to try to convince you a little bit more...When you say:
I should instead build the core parts of the app
You should consider that the authentication module might be a core part of the app too...
I prefer to do it early, but you really have roughly the same amount of work in front of you regardless of when you do it. It really a matter of opinion on when you prefer to do it.

When should I implement my authentication scheme? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am definitely going to use an authentication scheme (Devise) with 3 roles: user, admin & sponsor. The question is: should I implement authentication right away or wait until I have my other models/views in place first?
I think it is usefull to do it as first, so you can easely integrate them in other models, eg. log that a user does something, you will also be able to set weather a user should have access to a specific controller.
Unless, you have a good reason to not do it...
A rather unexpected question, but you can safely create your authentication routine right away. In any project i create, authentication is definitely one of the first things i code, most times using Sorcery instead of Devise.
IMO it doesn't really matter, but why not do it earlier than later? It's pre-built, allows early testing (and testing it often), and allows access control needs to evolve organically rather than waiting until they all pile up and you have to do it all at once.

Learning New Skills and Keeping Up to Date: Advice on Memory Retention [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I'm having a difficult time retaining the programming skills I'm actively trying to learn in an effort to apply for a junior developer position.
What I'm finding is that I can easily master isolated topics (for example, details about how Java's Container classes work and the different ways to sort a given container), but I find that when I move on to new topics I forget maybe 80% of what I learned (a few months down the road).
Sure, with good notes, I can get back up to speed much more quickly, but my question to those of you who are already in the professional field - is this common (this constant need to re-learn things you once felt you'd never forget)? If so, how do you get around it? Should I accept that I'll probably only be an expert in the narrow domain that I currently use on a day to day basis?
My father always said:
You don't need to know everything, you
only need to know where to look it up
(roughly translated).
Going with your example, if you find you need to sort a collection very often you will remember after you've done it a few times, if you don't do it for a long time you will forget it again. That's perfectly normal imo.
So what I'm trying to say is there is no point in knowing stuff off the top of your head if you don't use it anyway as long as you know where you can look it up if you need it again.
I hope that made sense.

Resources