Skip to main content

Questions tagged [ruby-on-rails]

Ruby on Rails is an open-source web development framework written in Ruby. If your question code is written in Ruby on Rails, tag with Ruby as the language tag. Many things are defined by convention, freeing you from having to re-invent things to stay productive.

38 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
0 answers
5k views

spec_helper.rb for RSpec, Capybara, FactoryGirl, Spork and Devise

Having been through hundreds of often-conflicting posts on testing with RSpec, Capybara, FactoryGirl, Spork, Guard and Devise without Cucumber, this is the spec_helper which "seems to" work. I'm ...
user avatar
4 votes
0 answers
116 views

Heterogenous tree in the application domain: How do I represent them?

The Domain I have three types of items in my domain: ItemA, ItemB, ItemC. (I can't use their real names.) ItemA has one attribute: thing_id. ItemB has 6 attributes: thing_id, name, description, ...
Eva's user avatar
  • 1,115
3 votes
0 answers
34 views

Using Pundit Policy Scopes with Searchkick Results

We are using Searchkick to run our elasticsearch and Pundit to authorize users for specific actions. Below is our module SearchkickScope that does it's best to ...
Romuloux's user avatar
3 votes
0 answers
119 views

Assigning raffle numbers to users in Rails

Background One part of our Rails app is running a Raffle, usually twice a month, with around 600k entrants each round. Each raffle ticket record will have at least a unique raffle number (consisting ...
user63764's user avatar
3 votes
0 answers
40 views

Rails route structure for managing tags

I'm hoping someone could vet my route structure as I've really been struggling with getting something that feels right. Right now I have this nested resource structure: ...
Dyl's user avatar
  • 31
3 votes
0 answers
93 views

Implementing secure API for use between other internal apps

My team and I are trying to implement a secure API and would appreciate some feedback on the following: If there are areas of improvement in the current code to improve security Recommendations on ...
Kay E's user avatar
  • 31
3 votes
0 answers
112 views

Retrieving data from the movie database

I am trying to retrieve the series, seasons and episodes from the movie database, however I am pretty new to Ruby on rails and I feel like what I am doing could be improved a lot. I use an ...
L. Faros's user avatar
  • 233
3 votes
0 answers
315 views

Ruby on Rails portfolio website

I've been learning Ruby on Rails for the last few weeks. I've decided to do a portfolio website using Ruby on Rails to showcase all of my projects. Can you look through my code to see what you think? ...
Sarah's user avatar
  • 401
3 votes
0 answers
40 views

Updating ActiveRecord with text from a joined table

I have an Active Record update with the following data model: TvMenuProfile has one rich_text_special ...
Joe Masilotti's user avatar
3 votes
0 answers
118 views

Custom MySQL duplicate_key update queries

The goal is to create an activity or update its counter if it's already present. And to be super accurate, the code avoids race conditions with a custom ...
user1035375's user avatar
3 votes
0 answers
70 views

Fat Controller Action - Deep nested filters

I have this really really long controller action and would like someone to help me break it down. ...
Filipe Chagas's user avatar
3 votes
0 answers
289 views

Multiple many-to-many filter with range using filteriffic

I should say that the code I have works. I feel like there has to be a much more efficient way to do it (especially when I just crashed my server with it). Relevant schema: ...
Jon Heckman's user avatar
3 votes
0 answers
570 views

Rails app that scrapes forum using Nokogiri gem

I've built a website that scrapes a guitar forum's pages and populates Rails model. I'm using rake task along with heroku scheduler to run background scrapes every hour. On the homepage, the forum ads ...
Jamie B's user avatar
  • 315
3 votes
0 answers
1k views

Moving from Solr (Sunspot) to ElasticSearch (Tire), Review needed

I would like a review regarding the following code in which I index and search the City model. Currently both solr (with sunspot gem) and elaticsearch (with the tire gem) are show. I am migrating from ...
Bruno Miranda's user avatar
2 votes
0 answers
191 views

jQuery validation for multi-page registration form

I use JS/JQuery validation for radioboxes, input field etc. Because of AJAX I use one global validation (in a separate file) and 4-5 other files to coverage actions in a relevant registration form ...
mr_muscle's user avatar
  • 197
2 votes
0 answers
78 views

TDD for Ruby On Rails API for group event items

I found myself working in this coding exercise for a work offer. I tried to apply TDD in the process but I didn't get any feedback from the company and I really would like to know what can be improved ...
Ibrah's user avatar
  • 21
2 votes
0 answers
63 views

Counting how many questions in each category are tagged

I have a homepage that shows how many questions are in a certain category which is done through tagging. The functionality is working great, it tells me how many of each there are. However, newrelic'...
mazing's user avatar
  • 121
2 votes
0 answers
993 views

Rails CRUD feature specs (RSpec and Capybara)

The following feature spec tests CRUD operations for the users resource in a Rails 4.2.8 application. It includes tests for filtering, sorting and pagination ...
BrunoF's user avatar
  • 155
2 votes
0 answers
635 views

Module to dynamically generate controller concerns

I'm rebuilding a Rails project from when I started developing, and I wanted to figure out how to really DRY my controllers out—without making them unreadable by doing half/all of the work in a ...
Phillip Longman's user avatar
2 votes
0 answers
30 views

mapping event uuids to events in ruby

I have quite an interesting challenge for you today. The following code will produce a map with events as values and event uuids as keys. I've also listed out the spec for it. I would like to know ...
Calin's user avatar
  • 121
2 votes
0 answers
478 views

Scoping through embedded document in MongoId

I'm using MongoId in a Rails project. I need to select some products which contain some SKUs which has an embedded document. The models are respectively Product and ...
Laurent's user avatar
  • 203
2 votes
0 answers
59 views

MySQL Workbench RoR Migration Exporter

I created plugin for MySQL Workbench that allows you to export an ER Diagram to RoR migration files. I would like to know if any other developers appreciate it. export-rails-4-migrations_grt.py <...
user3432195's user avatar
2 votes
0 answers
82 views

ActiveAdmin menu-generating mixin

I've written an ActiveAdmin mixin, such that you can include it and call simple_menu_for Foo, to reduce duplicate code when working with simple models. Here is the ...
Mike Belyakov's user avatar
2 votes
0 answers
464 views

Custom bang! method and Rails validation

I have a model called booking. ...
lulalala's user avatar
  • 121
2 votes
0 answers
60 views

Modeling a temperature recording device in Rails

The app will allow users to login and upload a CSV file that contains temperature data from a device. This data will be stored and the user can view all these downloads and select one from a list to ...
Kazi's user avatar
  • 21
2 votes
0 answers
78 views

Fetching photos and tweets related to selected publications

1) Postgresql 2) User has_many :reports 3) Report belongs_to :user 3) Report belongs_to :publication 4) Publication has_many :reports 4) Publication scope :photos, -> ...
Legendary's user avatar
2 votes
0 answers
417 views

Rspec test reuse code for before_filter and method

Consider following example (controller): ...
Gandalf StormCrow's user avatar
2 votes
0 answers
68 views

Sports statistics controller

Is there too much logic in this controller (should I migrate them to the model)? How else can it be refactored? ...
j.hwang's user avatar
  • 21
2 votes
0 answers
33 views

Joining models to get records

Is there a better way to refactor the join and fetch the required attributes or is there any better option here? ...
Ajay's user avatar
  • 121
2 votes
0 answers
53 views

Directions to refactor class for GPS track points

The story started here (Parsing GPS Data) and continued here (Class for median filter) I've done a lot work and faced new questions. In short - I made: Classes for parsers. TrackParser and ...
Aleksandr K.'s user avatar
2 votes
0 answers
439 views

Rake import from external database tasks

The application I'm working on runs import tasks each night to get information from an external database and processes and writes it to the local PostgreSQL database. This is so it can be viewed in ...
bnussey's user avatar
  • 121
2 votes
0 answers
363 views

Written worker using sidekiq for activerecord class

I have two model classes as follows: ...
user3752649's user avatar
2 votes
0 answers
1k views

Multi-page form with each step loaded via Ajax

I've building a multi-step form that saves data in multiple models. The "base" or parent model is the Venue, and has_one or has_many other models. In the screen below, the "Basic Information" tab is ...
Narayana's user avatar
  • 713
2 votes
0 answers
226 views

Converting data in a Rails Migration using the model

Lets imagine we have an Article entity, with data imported from a legacy database. It contains an appendix column with type <...
user22717's user avatar
1 vote
0 answers
882 views

Authentication Using Next Auth + Rails API Server

so I have a Nextjs frontend that is using Next Auth for authentication. This will be using a variety of Oauth providers but for this example and to prove the concept I am just using the ...
Romuloux's user avatar
1 vote
0 answers
1k views

Unit-testing authorization policies in Rails with RSpec

The following specs test the authorization setup of the Post resource in a Rails 4.2 application. The Pundit gem is used for authorization but I believe the specs ...
BrunoF's user avatar
  • 155
1 vote
0 answers
1k views

Converting ActiveRecord array to JSON

I have two tables, devices and device_properties. The devices table columns are as follows: ...
Dobz's user avatar
  • 111
0 votes
0 answers
28 views

Is the pattern I'm using for flash messages (with Turbo/Hotwire) in Rails 7 during a failed create action clean?

Rails 7.1.2 I have a form to create a new Employer that exists on the Employers#index view ...
J.R. Bob Dobbs's user avatar