Questions tagged [ruby-on-rails-5.2]

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

1
vote
2answers
26 views

Empty Post in Rails 5.2

I'm trying to add the helper _form of my Comment model inside Advertisement view. I call the helper <%= render 'comments/form', comment: @comment %>in the route /advertisement/:id So here is my ...
0
votes
1answer
18 views

Unable to display image using variant with ActiveStorage image_processing gem

Currently I'm working on a Rails 5.2 application. When I try to display a profile's avatar in a show.html.erb template using variant it doesn't work <%= image_tag @profile.avatar.variant(...
0
votes
0answers
13 views

Heroku deployment react_on_rails with gitlab-ci

I installed react on rails this morning to test. But it is impossible to successfully deploy it on heroku. I use gitlab for continuous development. .gitlab-ci.yml : production: type: deploy ...
1
vote
0answers
27 views

How to disable auto generated routes by Active Storage

I am upgrading an existing application to Rails 5.2. Old application is using Paperclip for file storage and I am trying to move that to ActiveStorage. My app expose an API that allows users to ...
0
votes
1answer
62 views

Dynamic scope with or method in Rails 5

Some scopes of my Unit model: class Unit < ApplicationRecord scope :committees, -> { where(unit_type: UnitType.committee) } scope :departments, -> { where(unit_type: UnitType....
0
votes
1answer
40 views

Why does active_storage:install's migration (v5.2.1) generate invalid MySQL syntax when run?

I've upgraded a Rails 4.x app to v5.2.1. The upgrade went fine and the app runs well. However, I've now run rails active_storage:install, which creates a migration to create the tables for ...
0
votes
0answers
39 views

Issue upgrading rails 4.2 to 5.1

My first time trying to upgrade rails from 4.2 to 5.2 and am having an issue configuring the middleware. To debug it I ran rake middleware and this was the result. I'm not using ActionDispatch::...
0
votes
0answers
32 views

ERROR column “reset_password_token” of relation “users” already exists Devise

I'm currently trying to configure Devise in a Rails 5.2 application. I get the following error: PG::DuplicateColumn: ERROR: column "reset_password_token" of relation "users" already exists : ALTER ...
0
votes
0answers
31 views

When is ActiveStorage::IntegrityError raised?

My app (locally) raises ActiveStorage::IntegrityError error, whenever it tries to attach a file. How can I get out of this error? I have only one has_one_attached and I don't know how that error gets ...
0
votes
1answer
25 views

Rails 5.2 fonts folder in assets throws a 404 (Not Found) error

I'm currently working on a Rails 5.2 application. I installed an npm package. Within this package there is a fonts folder. In the config/application.rb file I configured the assets pipeline to include ...
0
votes
1answer
24 views

I can not create a user through the console PG::UndefinedTable: ERROR: relation “team_members” does not exist

I can not create a user, I get an error. I'm trying to add another model, but I can not connect it to the database, I'm getting an error and can not execute Rails db: migrate team_members.rb class ...
0
votes
0answers
13 views

Rails ActiveStorage attachment to existing S3 file

I'm building a PDF parser that fires off a Sidekiq worker to OCR parse data from a document stored in S3. After parsing, the data is stored in the Document model. How do I append the existing S3 ...
-3
votes
1answer
61 views

no implicit conversion of String into Integer error in ruby on rails

I want access each of 1_1 1_2 1_3 from my rails views , Now how i can define each of this in my Odd class to access them ? I get this error no implicit conversion of String into Integer on this line ...
0
votes
2answers
25 views

ActiveAdmin admin_users table devise users table logging in issue [SOLVED]

Following is my setup devise (4.4.3) activeadmin (1.3.0) Rails 5.2 I created a user table with devise. installed active admin and used the normal method and created admin_users table. NO I AM NOT ...
0
votes
0answers
22 views

Devise not logging into active admin [duplicate]

Following is my setup devise (4.4.3) activeadmin (1.3.0) Rails 5.2 I created a user table with devise. installed active admin and used the normal method and created admin_users table. Routes file ...
0
votes
2answers
32 views

Validation tests in Ruby on Rails always false

I am writing some unit tests in Ruby on Rails. Even when I expect the test to have an outcome that passes the validation, the test fails. Here is my model that I am testing: class Post < ...
0
votes
0answers
46 views

Is is possible to do only one db call in ActiveRecord's `uniqueness` check?

I'm going through RoR tutorial book and I'm at the model validation part. This is how my model looks atm: class User < ApplicationRecord validates(:name, presence: true, length: { ...
1
vote
0answers
16 views

how to apply two serializers in one action in rails 5?

I want to serialize incoming_requests and outgoing_requests with a few column values with customized name. Without serializer, I wrote codes like below. def index incoming_requests = FriendRequest....
1
vote
2answers
79 views

Javascript in a fresh Rails 5.2.1 app on Heroku doesn't work properly

I think there is a big problem with JavaScript files in Rails 5 apps in Production environment on Heroku. It works locally though My configuration: Windows: 10 Education Rails: 5.2.1 Ruby: ...
0
votes
1answer
37 views

undefined method `to' for #<ActionDispatch::Routing::Mapper: (NoMethodError)

I have a rails 5.2 app with the following in config/routes.rb root to: 'home#index' Upon running rails s, I get the following error : undefined method `to' for #
0
votes
0answers
18 views

Webpacker not load styles from singlefile vue components

I cant make Webpack in Rails application to load styles from style-section of .vue-file. ( https://github.com/BabichSA/webpacker-rails-vue ). I have separated file .scss file in ny javascript folde ...
0
votes
2answers
25 views

Rails form_with (remote: true) errors

I need some help here, I'm getting a error when I try to update a model using ajax from Rails (form_with / remote: true). I was able to work fine with XHR requests for urls that were resources by ...
0
votes
1answer
59 views

Adding image to seed database in rails 5.2 active storage

Just trying to add an image to my seed file. Having a little issue when trying to add using the new active storage in Rails 5.2 Can anyone spot what's happening. Here is the code followed by error in ...
-5
votes
1answer
43 views

Get “wrong number of arguments” on ruby on rails

wrong number of arguments (given 2, expected 1) SportsController class SportsController < ApplicationController def index @sport = Sport.all @events, @errors = Bapi::Inplay.all(query) ...
1
vote
1answer
40 views

Rails 5.2: how do I revert the Postgres specific interpretation of an array in 'where' as a parameterized IN clause?

After upgrading from Rails 5.1 to Rails 5.2, only for Postgres (using the pg gem, but not with MySql) the implementation of queries like Foo.where(id: [1, 2, 3]) changed from SELECT "foos".* FROM "...
0
votes
1answer
50 views

Rails 5.2 asset helpers not including fingerprint digests

I am in the process of upgrading our product from rails 4.1 to 5.2. I'm hung up on what appears to be an asset pipeline related issue. When I load the app in our browser, I see the following error in ...
0
votes
1answer
19 views

Active Storage: Update S3 on Model Update, Delete S3 on Model Delete

I am using Active Storage on Rails 5.2.1 I have followed the tutorial and I am using the credentials to set it up in my storage.yml amazon: service: S3 access_key_id: <%= Rails.application....
0
votes
0answers
63 views

Rails convert secrets to credentials

I updated my Rails app from 5.1.6 to 5.2.1 and we were using secrets before. We'd like to switch to credentials since it was supposed to replace secrets. There are a couple of things I'm wondering: 1)...
-1
votes
3answers
31 views

How to display data using a namespaced controller rails 5.2

I have an admin namespace with items as a resource in it: namespace :admin do resources :items end My items controller located in app/controllers/admin/ looks like this: module Admin class ...
1
vote
1answer
41 views

How to add file privacy(public or private) to google cloud storage files with active storage in rails?

I am adding files to google cloud storage bucket with active storage. I don't find any way to specify the file privacy, whether it is private or public and the expiration time, and how to resign the ...
0
votes
0answers
14 views

Checkbox with remote: true to update boolean without javascript

I am trying to utilize remote: true to allow a user to update a boolean value. The following works to "check" the box (update value to true), but does not work when attempting to "uncheck" the box (...
0
votes
1answer
31 views

Rails conditional form_form controller and action parameters

Maybe I'm going against convention here, but I have a form used by multiple controllers and I want to customize where the submit action gets sent. I have tried: <% if local_assigns.has_key? :...
0
votes
1answer
34 views

Routing in rails 5.2

I have a RoR app with an admin_controller, the admin is able to CRUD Item, now I am a bit confused when it comes to routing. How can I create the app in a way that I can have a link to new_item be ...
0
votes
2answers
25 views

Ruby on Rails Ajax with Remote Forms

Hello when I add the comment in my application in the form that I have with ajax, I have to reload the browser to upload the comment. In the browser I get this error that I supposedly have in this ...
1
vote
1answer
66 views

Rail 5 swap ActionDispatch::Reloader with a custom reloader

We have a use case for mounting a mock engine to process sessions when developing locally in which a custom session middleware calls the mock engine via Net::http request when a request comes through. ...
0
votes
1answer
13 views

Install of activerecord-jdbc-adapter from Github (51.1) fails

I am trying to install the latest jdbc adapter, as I want to use it with Rails 5.2.1. But during the installation this error occurs. As I am not into Java at all I have no Idea what to do. Any ...
2
votes
1answer
61 views

How do you solve N+1 for ActiveStorage URLs?

How do you preload all the records with their URLs? This is what I am doing in my jbuilder to get the URLs: # views/users/index.json.jbuilder ... json.avatar_url user.avatar.attached? && ...
1
vote
1answer
46 views

cannot :destroy if last existing

The Setup I'm using Rails 5.2 and CanCanCan. rails g scaffold Hotel name rails g scaffold PriceGroup name hotel:references hotel.rb has_many :price_groups, dependent: :destroy validates :...
2
votes
0answers
181 views

Rails Active Storage Variant Options

Steps to reproduce class Product < ApplicationRecord has_many_attached :images end In view: <%= image_tag(url_for(@product.images.first.variant(resize: "100x100", flip: "-90"))) %> ...
1
vote
2answers
83 views

Rails 5.2 MiniMagick::Error when using image variant with ratio and active storage

On my local the following code works fine from a view... image_tag image.variant(combine_options: {resize:"1200", gravity: "Center", crop: "6:3"}) On production Digital Ocean Ubuntu 16.04 it errors.....
0
votes
0answers
20 views

File field - ActiveSupport::MessageVerifier::InvalidSignature

Rails 5.2 active-storage. I have a <%= form.file_field :header_image, class: "" %> => upload works fine form field helper creates that html code: <input type="file" name="profile[...
1
vote
1answer
137 views

Fixing 'Your Ruby version is 2.4.4, but your Gemfile specified 2.5.1' error with rbenv and rails 5.2

I know there are many many questions about this with various ruby versions. I believe I have exhausted all of the normal fixes (which usually work). This is an application that has been working, in ...
0
votes
1answer
23 views

Best practice for only running a group of validations when a certain condition is met?

I have a Review model that has 3 validations that should only be run if the status of the review is "submitted". Here is my current model... class Review < ApplicationRecord enum status: ...
0
votes
0answers
12 views

Which logger for Rails that gives Controller Name, Service Name

Currently I'm getting this in my log files. [42ba6cd6-f648-4f69-9a0b-999c3d410bd0] Adding a new account I want it to include the caller. [42ba6cd6-f648-4f69-9a0b-999c3d410bd0] [module=Api::...
0
votes
0answers
28 views

Migrating a Rails application that uses Active Record to MongoDB

I have written a Rails (5.2) application that uses the default Active Record ORM, and Devise for authenticating users. It has a few other models and associations: User has_one Card User has_many ...
0
votes
0answers
25 views

Where to save customized functional_test template?

I want to customize the controller test which is generated by rails g scaffold. I found the template file at https://github.com/rails/rails/blob/master/railties/lib/rails/generators/test_unit/...
0
votes
0answers
46 views

jsonapi-resources custom action

I need to add a custom action to my jsonapi-resources controller. This action just creates e new version of a preexistent CollectorContent model instance. My implementation (just copied from here): ...
0
votes
0answers
38 views

How to set up pdftk path in Rails app - Cliver::Dependency::NotFound (Could not find an executable [“/vendor/pdftk/lib”] on your path

I'm currently working on a Rails 5.2 application where I'm using gem 'pdf-forms', '~> 1.1', '>= 1.1.1' I'm currently trying to fill some PDF with data from a JSON response. def parse_pdf ...
0
votes
1answer
29 views

active_record-acts_as gem updating created_at multiple times

I'm creating a Rails 5.2 e-commerce application. I am using the active_record-acts_as gem to simulate multi-table inheritance that has a parent class named Product and multiple subclasses (Book, ...
0
votes
0answers
55 views

Rails 5.2 & Bootsnap: NameError while using app/lib file

I just upgraded to Rails 5.2 and have run into the following issues in development mode, while using a class JsonWebToken from my app/lib folder in my ApplicationController. NameError - uninitialized ...