Model student, subject, marks. Application logic [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 6 years ago.
Improve this question
I have Student that has_many Subjects thas has_one Mark. Where should I write logic to sum all student marks from one subject ? Im beginner so any links to documentation or somewhere else are appreciated.

Almost any time I need to interact with multiple models, I use a plain old Ruby object (aka, a "PORO"). I personally call these 'managers', but I believe it's more common to call them 'service' objects (or some variation). Google 'Rails service objects' and that ought to get you started.

Related

Rails: How to lock ActiveRecords in order to avoid collisions in data trafic? [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 2 years ago.
Improve this question
How can we lock an ActiveRecord and complete the operations on it before allowing another thread or request to make changes to the ActiveRecord?
I am building an eCommerce site which currently has a huge discount
campaign. Only one unit of your product left. And many people want to
buy it at the exact same time. In such scenario, I need to lock the
product?
In Rails, you could use with_lock
https://apidock.com/rails/ActiveRecord/Locking/Pessimistic/with_lock

Best way to implement "custom" currency in rails? [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 trying to add a feature in my Rails web-app called "tokens".
It would be a currency of sort which would be exchanged between users for some services.
ex: "Let me stay one night at your place and I'll give you one "token" "
Is there any good rails gem to help me with this? To be precise this "token" system would be completely separated from any real-world currency, you wouldn't be able to buy it, you'd get some of it when you register or invite new users.
Thanks
The closest I could recommend is merit, look at the points option. It works similar to coins.
current_user.add_points(10, category: 'One night stay')

What Sort of Things Would a Programmer Put in the ActiveRecord::Base class? [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
So I am new to rails and just started learning it today. I was wondering what sort of code a programmer would put in the ActiveRecord::Base class. I have a general idea about MVC so I want to know specifically about the Base class not about what I would generally find in the Model.
Thanks. :)
The programmers who create Rails put this into ActiveRecord::Base.
An average programmer who uses Rails (i.e. develops a Rails application) would typically not touch it.

Rails: Users save they favorite posts [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 9 years ago.
Improve this question
First sorry for my English;
For learning purpose I have create a blog with authentication ( I am using Devise), Now I want that user to be able to save other users posts so when they visit the Saved posts pages they will see posts saved, how can I do it
You can model the association
Business Logic
Users can have multiple posts
Users can save multiple posts
A Post can be saved by multiple users but have one owner

How do i look at the relationships being created at Rails boot up? [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 8 years ago.
Improve this question
I would like to see the wiring that is going on behind the scenes and double-check that i have defined my relationships correctly.
It's not really clear what you're looking to do with the relationships, but every ActiveRecord subclass defines a method called "reflections" which you could use to inspect all of these relationships. Each reflection tells you what kind of relationship it is, what options there are, and tons of other info.
MyClass.reflections

Resources