Questions tagged [ruby-on-rails]
Ruby on Rails is an open-source web development framework optimized for programmer happiness and maintaining sustainable productivity. Many things are defined by convention, freeing you from having to re-invent things to stay productive.
277 questions
0
votes
1
answer
86
views
How to handle data isolation in one DB when handling SQL queries as user input in Rails
I have a task to develop a website that allows storing of data resources from other APIs and users can analyse and visualize this data. This data is sensitive and data leakage should be minimal.
I ...
-1
votes
1
answer
876
views
rails, how to refactor nest if statements? [duplicate]
I'm working a project where I found another developer wrote a method as you see it below.
How would I clean those IF statements and refactor this method.
Also is it ok ti set a variable to nil ?
def ...
6
votes
3
answers
4k
views
Tracking flakey tests in Ruby on Rails / Rspec - is there a way to do this?
Currently working on a Ruby-on-Rails codebase, testing is done with Rspec. We use BuildKite to run tests.
We are in a situation where sometimes tests will fail, and upon a retry or two, pass. AKA, we ...
0
votes
2
answers
761
views
Database dictionary table versus code defined enum
For the following table structure, for the metric_id column, what are the advantages of having a JOIN dictionary table versus an ENUM dictionary defined in the code?
Assuming the metrics dictionary is ...
1
vote
0
answers
31
views
Best RoR pattern for special instances of a subclass
I'm trying to figure out the best way to "partially" use the validates_uniqueness_of validator for a particular case of problem.
Let's say I have a Book class with multiple comments, with the Comment ...
1
vote
1
answer
354
views
How to efficiently process CPU intensive tasks on the server in the background
I built an audio processing web app using Rails. The user uploads a song to the website. The song is then decomposed into individual elements and then modified and recombined.
I am using a an open ...
1
vote
0
answers
374
views
Is it better to have a default avatar library on client or server side?
I have a webapp using ReactJS as the frontend and Rails as the backend service.
I have an account manager, where a user can choose multiple avatars from a default library. This library contains ...
0
votes
0
answers
53
views
Ruby on Rails newbie question, regarding general design for models/controllers for feedback app/ my thinking
I am working on a little project which essentially allows me as the administrator to upload new products to the app (each product would be a video explaining product) which would have its own specific ...
0
votes
0
answers
258
views
Call external API during validation (Rails)
I need to validate a value with data from an external API.
The easiest way would be to add a validation rule in my model, call the external API and do my check.
But it feels very dirty to call an API ...
7
votes
1
answer
2k
views
Implementing A "Draft" Mode For Posts
My team is debating how to transition a portion of our Rails application to allow "drafts". For simplicities sake, we can imagine a Post object where we want to allow a kind of draft mode.
Our real ...
1
vote
1
answer
188
views
Ruby on Rails: primary SQL db and secondary No-SQL db without models
I have in mind to develop a Ruby on Rails app with two different databases.
In the primary SQL db - let's say MySQL, for instance - I'd keep my app items, e.g. user profiling, user-user interactions ...
2
votes
3
answers
2k
views
Convincing a development team to use a better design pattern [closed]
I recently joined a company where I was tasked with building a system for one of their clients. The work I've done is so far working well, but the most senior developer on the team who's been with the ...
0
votes
1
answer
63
views
Fastest way to return a list of records depending on many many-to-many relationships
I'm developing an API in Rails and the following requirement is established (it's really more complicated, but I want put a simple example):
There are users and messages.
users have a gender (...
-1
votes
1
answer
60
views
Implement Customizing records
I have the following tables:
Organization.
Articles
Templates
Organization is the parent of both articles and templates.
On the articles index page, I display (by default) all templates for the ...
2
votes
1
answer
373
views
Is the URL 'users/new' RESTful?
I was in a job interview demo-ing a RESTful API in Flask when an argument broke about the API. The interviewer argued that the URL for adding a new user (/users/new) is not proper REST.
My API ...
3
votes
1
answer
361
views
How can I appropriately model relationships that have a cyclical dependency?
Let's take two simple Rails models, Post and PostRevision.
class Post < ApplicationRecord
# Attribute: Status (ex: draft, public, private, deleted)
# Attribute: Views
# An owner, likely a ...
1
vote
2
answers
458
views
Can we use shared schema multi tenancy(using tenant_id column to scope) combined with separate schema approach
I am working on a ruby on rails learner project that uses multi-tenancy. This project has states(tenant) and cities(sub-tenants). User can only belong to one city. For first level i.e for states I ...
2
votes
0
answers
370
views
Single page React on Rails app vs Multi page React on Rails app [closed]
I've been looking around hoping to get some perspective of the pros and cons of using a Single Page React App vs. a Multi Page React App. The end product of the project is a page with 5 tabs, each ...
4
votes
1
answer
365
views
Between JS clients and a Unity game server : TCP or UDP?
I'm currently building an interactive game which has a very special use case : The game is displayed on a giant screen on stage in a theatre, and the audience can play it with their smartphones (http:/...
1
vote
1
answer
441
views
Fat or slim job code in Rails?
I have a Rails 5 application with Resque as the background job backend.
A typical job does quite a few things, mainly it collects stuff from HTTP services, processes and aggregates some of the ...
6
votes
2
answers
706
views
How do I create idiomatic error interfaces in Ruby?
I'm developing a Ruby on Rails app. The app contains a service wrapping an external REST API, called from a controller, with several possible error states. The current implementation returns the ...
1
vote
2
answers
4k
views
Decoupling REST API and frontend web application
I'm learning Ruby on Rails coming from Node.js/express and had a few design questions. I used React.js for the frontend in my Node apps and I'm planning on continuing to do so in my Rails apps.
What ...
3
votes
3
answers
26k
views
Database design for a role based access system?
I'm considering different designs for a generic role library gem.
The first is based off the Rolify gem but with a has_many through: relationship instead of HABTM. HABTM tables are "headless" in ...
1
vote
1
answer
2k
views
Classifieds categorization best practices and concepts
Im writting a web-page in Ruby on Rails , so i can learn the language and framework better.
I have a User model which has_many Classifieds models which has_many Photos which accept_attachment :image.
...
4
votes
2
answers
2k
views
Where to store configuration URL variable in Rails?
I have an external ecommerce link that varies based based on environment (testing and production systems).
Where should it go in Rails?
Possibilities include:
a conditional directly in the template, ...