Questions tagged [ruby-on-rails-5]

For issues specific to version 5.x.y of Rails. If your question applies to Ruby on Rails in general, use the tag [ruby-on-rails].

Ruby on Rails 5 is the previous major revision of Ruby on Rails, "an open-source web framework that's optimized for programmer happiness and sustainable productivity."

Multiple sub-versions have been released, namely 5.1 and 5.2. Questions regarding specific sub-versions of Ruby on Rails 5 can also be asked on the appropriate tags:

Resources:

See also:

9415 questions
2
votes
1 answer

Rails console executing a stale copy of the code

I have a strange issue with rails console. In fact, I am modifying the code of class function (static class). class SomethingWorker @queue = :resque_queue def self.perform(method, *args) send(method, *args) end def self.async(method,…
Charmi
  • 594
  • 1
  • 5
  • 20
2
votes
1 answer

Rails 5 strong parameters doesn't allow UploadedFile

I'm porting a Rails 4 app to Rails 5 and experiencing some odd behavior with strong parameters and Rack::Test::UploadedFile. I have a test/controller combo that does something like this: # The test post images_url, as: :json, params: { image: { …
kyrofa
  • 1,759
  • 1
  • 14
  • 19
2
votes
1 answer

Rubocop.yml excludes being ignored

My excludes are being ignored. .rubocop.yml Rails: Enabled: true Exclude: - 'db/**/*' - 'config/**/*' - 'script/**/*' - 'bin/{rails,rake}' - 'vendor/**/*' - 'spec/fixtures/**/*' - 'tmp/**/*' Rubocop…
user2012677
  • 5,465
  • 6
  • 51
  • 113
2
votes
1 answer

ActiveRecord query for all of last day's data and every 100th record prior

I have a process that generates a new record every 10 minutes. It was great for some time, however, now Datum.all returns 30k+ records, which are unnecessary as the purpose is simply to display them on a chart. So as a simple solution, I'd like to…
stevec
  • 41,291
  • 27
  • 223
  • 311
2
votes
1 answer

Devise: Redirect authenticated users to a single subdomain in Rails 5

I have a Rails 5 app that uses Devise for user authentication and currently shares the user session across the primary and sub domain. I would like to change this behavior so that authenticated users are routed to the subdomain sub.example.com while…
akaimo
  • 146
  • 2
  • 12
2
votes
0 answers

Calculate ranking based on table's score field

I have 3 models 1) business item 2) business service ranking 3) leaderboard class BusinessServiceRanking < ApplicationRecord belongs_to :business_service belongs_to :leaderboard belongs_to :category end class Category <…
Vishal
  • 7,113
  • 6
  • 31
  • 61
2
votes
1 answer

Google analytics with Rails 5 and ActiveAdmin

I've followed these steps and I successfully see traffic going to my site, the problem is I can see the traffic of every controller/method EXCEPT those within the admin namespace, because the script at app/views/layouts/application.html.erb (the one…
Patricio Sard
  • 2,092
  • 3
  • 22
  • 52
2
votes
2 answers

Rails 5: Why isn't will paginate working?

I've added the gem, restarted the server. In my index action I have: def index @listings = Listing.paginate(page: params[:page]) end I reload my view. It works. I then drop in the pagination links: <%= will_paginate @listings %> I get an…
user3574603
  • 3,364
  • 3
  • 24
  • 59
2
votes
2 answers

Detect file type and resize if image

I have model Attachment whitch supprted pdf's and images. How to detect if its image and only then resize it ? When it's paperclip everything Was simple. but now ? ;) class Attachment < ActiveRecord::Base has_attached_file :attachment, …
AdamM
  • 163
  • 1
  • 1
  • 9
2
votes
1 answer

How to use the Attribute API inside a concern in a Rails?

I have a simple generic model rails that looks like this: class Thing < ApplicationRecord attribute :foo, :integer include AConcern end And it include a basic concern that looks like this… module AConcern extend…
CafeHey
  • 5,699
  • 19
  • 82
  • 145
2
votes
1 answer

Rails gem acts_as_list: How to handle reordering of list items when a list item is destroyed?

I'm using acts_as_list v0.9.17 this way: class ListItem < ActiveRecord::Base acts_as_list scope: [:column1_id, :column2_id], :add_new_at => :bottom end When a new (scoped) @list_item is created, say the one where column1_id is 1, column2_id is 11…
Backo
  • 18,291
  • 27
  • 103
  • 170
2
votes
1 answer

Rails Server Extremely Slow in Development

I've got a rails 5 application that is very slow after I boot the server or change a .rb file. Below is my cli output after I booted the server with rails server and loaded a simple page. Also, if I change a model, controller or helper, the server…
Cannon Moyer
  • 3,014
  • 3
  • 31
  • 75
2
votes
1 answer

Rails use Model method in a group query

I am using has_ancentry gem and I want to have the category count is this format "Technology / Laptop (50)" where "Technology" is parent category. "Laptop" is child category, and "50" is the count of my grouped query categories =…
sparkle
  • 7,530
  • 22
  • 69
  • 131
2
votes
1 answer

Rails export multiple csv in same view

I have two csv exports on the same view, both with different data. Currently it's just downloading the same data for both. View <%= link_to "Trials export", data_path(format: "csv") %> <%= link_to "Results export", data_path(format: "csv")…
DollarChills
  • 1,076
  • 1
  • 15
  • 33
2
votes
1 answer

Why does Puma respond slow or hang in clustered mode on Ruby 2.5.4

I'm adding this question because it took me a long time to even figure out that it was caused by upgrading to Ruby 2.5.4. I'm not sure of the minimal case that can reproduce this issue, but I'm running a Rails 5 app on Puma 3.11 in clustered mode…
mltsy
  • 6,598
  • 3
  • 38
  • 51
1 2 3
99
100