Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
18 views

Is it usually good practice to declare an association methods in two models despite only using the association on one side?

Let me elaborate. Say I have a model called Credit that is categorized by a Role model. A real life example would be a track from an album. The track will have credits detailing its' contributions: ...
6
votes
1answer
264 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 ...
0
votes
0answers
43 views

Rails Devise & React with Graphsql

I am trying to fix an authorization/authentication strategy for a Rails app (5.2). I am migrating the front-end w/o an API. I have however connected the backend through a GraphQL flow. I am planning ...
0
votes
0answers
31 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 ...
1
vote
1answer
52 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
3answers
144 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 ...
0
votes
3answers
555 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
votes
2answers
222 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
1answer
47 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 (...
2
votes
2answers
60 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 ...
-1
votes
1answer
50 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 ...
4
votes
2answers
555 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 ...
2
votes
1answer
153 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
1answer
37 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 ...
4
votes
1answer
216 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
2answers
58 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 ...
0
votes
1answer
179 views

Can we use shared schema multi tenancy(using tenant_id column to scope) combined with seperate 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
1answer
62 views

Design tables and models for shipment and changes and keep it normalized

Our company buys second hand valuables (item) from clients and resell them for them. In order to do the client comes to our site and ask for a shipment he may choose the time that the delivery man ...
2
votes
0answers
241 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 ...
0
votes
1answer
125 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 ...
4
votes
1answer
248 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:/...
0
votes
1answer
900 views

Scheduling notifications reminders for users

I am trying to design the best way to send reminders to users for events they are registered for: reminders should be sent 72, 48 and 24 hours before the event reminders cannot be sent twice (so user ...
1
vote
1answer
149 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 ...
4
votes
1answer
271 views

Caching data in a Rails variable instead of querying the database?

I have a list of about 15000 items in my database, every one of them has a unique ID and name. New items are added regularly but usually not more than ten a day. My frontend uses a form with ...
7
votes
2answers
379 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 ...
6
votes
1answer
273 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 ...
1
vote
2answers
2k 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 ...
4
votes
3answers
427 views

What are the different approaches to filtering on aggregated data?

I have a feature I'm building that aggregates data across about a dozen or so tables. This data is aggregated from a heavily joined query. This page then has a lot of filtering, sorting, counting, and ...
2
votes
3answers
11k 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
1answer
97 views

API oriented web app for both public and private consumptions in Ruby

In traditional Rail app, we need to deal with controller/model/action and has a view that generate HTML output. Now There are many JS framework like backbone/react that allow us to code client side ...
1
vote
1answer
912 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. ...
0
votes
4answers
414 views

How deal with negative feedback on code style from senior developer? [closed]

Background I have been programming mainly in Python in the past years and mostly on my own projects. I have developed some of my own small stilistic conventions like leaving 4 numbers of empty lines ...
4
votes
1answer
624 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,...
-3
votes
1answer
792 views

Web framework to consume external API [closed]

I'm currently joining a project in which there's a core REST API already developed which is used for a mobile app. The next step will be to build a web app which should also consume the API. My doubt ...
0
votes
1answer
151 views

database architecture for ecommerce app

I’m creating an app that allows users to post, sell, and purchase items. Every item has a count integer attribute that is set by the initial user and which is reduced by n with each purchase. When ...
18
votes
5answers
3k views

When to use inheritance, when to use 'just a boolean field'?

In our Rails application, we are adding notifications. Some of these are blocking: They stop the progress of whatever resource they are added on, because some information on that resource is missing. ...
3
votes
2answers
128 views

Rails' MVC vs Microsoft MVC - where to put logics?

Some time ago I switched from Microsoft ASP.NET 2.0 (WebForms, never knew Microsoft's MVC) to Ruby on Rails and learned it's MVC approach, after which some things in ASP.NET MVC seem to be weird. In ...
5
votes
0answers
319 views

Rails on AWS Elastic Beanstalk - limitations

I have been looking at AWS Elastic Beanstalk service for the deploymeny of my rails application, and I came to think it was actually a bad idea given some specific requirements of my application. But ...
3
votes
0answers
852 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 ...
0
votes
0answers
16 views

Regional test-of-concept environment, whose database must be merged back to the main server afterwards

My client wishes to launch a specific version of the Rails platform I am developing that will be restricted to a particular group of users (some sort of test-of-concept). I will have another server ...
1
vote
2answers
786 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 ...
2
votes
2answers
3k views

Does RESTful response always return a 404 and empty content when an array is expected but the result is empty?

I worked with Ruby on Rails and RESTful api before and now with Django Rest framework. For this question let's say we only consider the case of JSON but not XML. It seems that when we expect an ...
2
votes
3answers
202 views

Using multiple languages

I currently have a website running PHP laravel. We came to a point where we want to add a user-backend -- where users sign-up and can access functions when logging in. My question is; Is it possible ...
5
votes
1answer
285 views

Increase code duplication to simplify business rules in views

I am in the process of writing a Ruby on Rails web application for my university's department. For some of our resources in the web application, e.g. Project, are complex with their view layer logic: ...
4
votes
1answer
1k views

How to implement a (truly) global variable in a Rails app

How can I best implement a global counter in a Rails API app? (A central component in a system with several.) Basically I have a transaction id I need to increment and roll over past a maximum value. ...
1
vote
1answer
287 views

Ruby: Abusing mixin

I'm currently working with some code that IMO has abused ruby's mixin features. Given that I'm new to ruby, I wonder if MO in IMO is correct or not. My primary question is what makes more sense (and ...
1
vote
0answers
118 views

Why separate routes and controllers in MVC backend applications?

I've dabbled in a few MVC frameworks (like Rails and its ilk) and I've noticed that the file that defines restful routes often go separate from controllers which hold the actions executed through ...
4
votes
1answer
269 views

Adding permission levels in Rails

So I'm making a bug tracker to help me learn Ruby on Rails. My current setup is something like this: Each Project has_many :metadata and has_many :permissions, through: :metadata. Also some other ...
-2
votes
2answers
121 views

Tables vs. Booleans: Which of the two are more secure for setting admin roles in an app? [closed]

I'm currently in the process of setting up roles where there are regular users, admins, and super admins, each of which have special permissions. I deferred to this post on how to do so. It ...
0
votes
1answer
1k views

Best way to design a database interface [duplicate]

This is my situation I have a website, mobile client and desktop client. They can all pretty much do the same operations (website might be able to do more now but in the future they might have the ...