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.

Filter by
Sorted by
Tagged with
0 votes
2 answers
560 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 ...
4 votes
3 answers
3k views

Is Ruby on Rails a suitable framework for a desktop application?

I was wondering if there are obvious advantages and disadvantages to using Ruby on Rails to develop a desktop application. RoR has great infrastructure for rapid development, proper implementation of ...
0 votes
0 answers
90 views

Best practice for defining "constants" within top-level blocks

Normally, when a static value is used multiple times in a Ruby context, you'd define it as a constant. However, in some cases, the context is a block for some DSL at the top level of a source file (...
0 votes
0 answers
44 views

Synchranization issue in async jobs created and finished before main thread ends

Main execution thread creates asynchronous job (started and executed by different process) that works on same data that the main thread. For example we create some database entries, that we want to ...
0 votes
1 answer
187 views

Firebase Auth system with Rails API design

TLDR; How can I utilize Firebase Auth in my iOS application and sync the Firebase ID with a user in my API? I am in the process of designing an iOS application that reads from a Rails API. When first ...
3 votes
3 answers
3k views

Is is OK to use a non-primary key as the id in a rails resource?

I am getting ready to set up a resource for some new api calls to my rails application. I am planning on calling the resource devices ie resources :devices This is going to represent android mobile ...
1 vote
2 answers
436 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 ...
0 votes
0 answers
41 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
1 answer
68 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 ...
6 votes
3 answers
3k 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 ...
-1 votes
1 answer
683 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 ...
3 votes
1 answer
172 views

Reorderable parent/children hierarchy in a relational database

I'm struggling on a design question for my Ruby on Rails website. I'm working on an estimation tool for construction companies for renovation projects. It orders items this way by default: Room (ex: ...
1 vote
1 answer
194 views

Best way to renew OAuth token before expiry

I am building a simple application built in Rails that allows the client to connect to a third party api to sync customer data. The customer inputs their username and password and my application ...
0 votes
0 answers
74 views

Sharing ActiveRecord class between two Rails app with gem

We have several Rails applications using the same ActiveRecord, Book. For simplicity let us assume we have only these two: BookWarehouseApp (that deals how new book are added, or other inventory ...
1 vote
2 answers
947 views

How to overcome the fear of building a web application with a recurring payment system? [closed]

I'm a Ruby on Rails developer. I'd like to create a web application. I will let users get a payed subscription to use the product. So I will need a recurring billing system (e.g. via paypal). But ...
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,...
1 vote
1 answer
1k views

Rails model inheritance without STI or polymorphism?

I have a Rails app with HighSchoolTeam and ClubTeam models. I'm currently using Single Table Inheritance (STI) with Team. That means I only have a Teams table in my database, no High_School_Teams or ...
1 vote
0 answers
22 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 ...
4 votes
1 answer
2k views

Best way to build a JSON API coupled with HTML views in a Rails project

I've got a Rails eCommerce project communicating with an iOS app. The iOS app receives JSON data from the Rails back-end, but there's also HTML rendering when a user comes to the project from his ...
1 vote
2 answers
1k views

Should feature branches always branch from develop?

I'm a Rails developer and I've always had this doubt, let's say I have to develop things for the user's controller and views (branch feature/users-endpoint) and imagine I end up developing several ...
1 vote
1 answer
298 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
2 answers
1k views

MVC - Database search logic in View or Model

Special Note: I asked a very similar question on Stack Overflow, but I have since decided the problem should be solved from a design standpoint rather than an implementation standpoint. I have ...
1 vote
0 answers
299 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 ...
6 votes
3 answers
588 views

What is less desirable: Inefficient code or maintenance overhead?

In our Ruby on Rails app, we have a set of conditions to define the status of a user. Currently, there is logic that checks if those conditions are true given a user. We are in the process of writing ...
1 vote
0 answers
61 views

Building a schedule app - best design pattern for collection on Rails API

I’m building a web app using Rails API on server side. The goal is to make a planning manager. I want my users to be able to plan ‘daily’ events, which will display at some specific weekdays, with ...
0 votes
0 answers
212 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 ...
9 votes
2 answers
404 views

Best practices for internationalization: composed sentences?

I am working on a project where clients are able to create objects in a database. Each of these objects has a description string that describes the object. Let's assume we are looking at an object ...
7 votes
1 answer
1k 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 ...
2 votes
2 answers
124 views

Best practice to add polymorphic attachments to a post

I'm currently trying to figure out how to solve following problem: I have a model called Post that has, among other attributes, link_1_text, link_1_url, link_2_text and link_2_url for users to add ...
0 votes
0 answers
52 views

Good practices: using member routes or filter on search scopes?

I want to know which practice is more convenient having the following example, (my app is a Rails app but this can be applied on any framework) I am trying to create an endpoint which contains author ...
3 votes
1 answer
316 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
1 answer
152 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 ...
17 votes
6 answers
17k views

Rails - Does using partials slow views rendering?

I'm having performance issues on a Rails 3.1.0 application, now I've done dome changes on my queries with AR and so but views still takes too many time to render, I've divided the views, loops and so, ...
4 votes
5 answers
5k views

How did the "Rails can't Scale" meme start?

One meme about Rails is that Rails can't Scale. Is it known how this meme started? Was there a particular blog post that argued this is the case?
2 votes
3 answers
1k views

Reconciling MVC with a strategy pattern

I am working on a Rails application which employs a classic MVC as its fundamental structure. In that structure the controller is supposed to be responsible for "which view to render when". Now after ...
5 votes
2 answers
1k views

Can a model have itself as a foreign key?

I am doing a coding project in rails. I have a user model, and I want to add a "spouse_id" to it (which would reference other users). Can a model reference itself in a foreign key?
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 ...
1 vote
2 answers
429 views

Using self.method vs the scope :method DSL

According to the Thoughbot Rails Style Guide, we should Use def self.method, not the scope :method DSL. My question is: is this simply for the sake of choosing one of these styles and sticking ...
-1 votes
2 answers
626 views

Argument for staying on Rails instead of migrating to .net MVC?

I work for a Rails SaaS platform that was recently acquired by a primarily Microsoft shop. They are pushing the issue we need to rewrite the entire application in .NET. It's very clear they know ...
0 votes
1 answer
51 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
51 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 ...
5 votes
2 answers
1k views

Benefits of using a JS Framework

I am starting a new project and trying to decide if I should use a Javascript framework (like vue.js or react) and create a Ruby on Rails API, or use Ruby on Rails to server-side render pages and ...
1 vote
2 answers
1k views

Should I be writing feature or request specs?

I've been writing model specs for a while now and I'm gradually moving towards integration testing. Right now, I'm looking at the best way to test the output of my ActiveAdmin dashboard but I'm unsure ...
0 votes
2 answers
4k views

How can I implement an escrow payment system in my website? [closed]

I'd like to build a web service similar to Kickstarter that allows users to pledge money to an idea, tho I'm unsure how I can implement this kind of payment system. If the the idea receives a ...
2 votes
1 answer
305 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 ...
-1 votes
1 answer
75 views

Measure ActiveRecord performance in `limit` method [closed]

How can I measure ActiveRecord's performance? My query has where and an order by clause, and on top of that I want the top row: User.where(…).order(id: :asc).limit(1) Knowing that the order by ...
0 votes
1 answer
286 views

What are best practices to maintain a list in the database in Rails?

I have list boxes and model relationships in the database. I'm doing the following migrations to maintain lists, rename items, and add items: def up Fund.create min: 0, max: 1_000_000 ...
1 vote
2 answers
83 views

Should I structure/process data for a view in an MVC architecture?

I've got a view that renders a menu. These menu items are dynamic, in that they only appear based on some conditions (authorization, for example). I have two options: Hard code the menu in the view ...
5 votes
1 answer
319 views

How should Rails be set up with an SPA client like Aurelia?

Let's suppose I have a backend with API-only Rails. There is also a Javascript single-page application (Aurelia, but could be something else) talking to this API. Should I keep these together, in the ...
4 votes
1 answer
343 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
2 3 4 5 6