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
16 views

How to update a Ruby on Rails website form http 1 to http 2

Currently using Rails 5.2 and Ruby 2.3 with the server: Nginx with passenger please tell the changes that are required to update the website from HTTP version 1 to HTTP 2. Virtual Host : server {...
1
vote
0answers
46 views

CSV.foreach Memory usage keeps increasing

My import speed is slow, it takes 2.5 hours to process a 13K line CSV file. I am wondering why my memory usage keeps going up, as I increase the file size? I am using foreach, so I thought memory ...
0
votes
1answer
32 views

Rename strong params involving a belongs to association id

When I'm using rails strong params and I need to receive an id of a belongs_to association, I normally reference the district model, like this: params.require(:place).permit(:district_id) Then I ...
1
vote
1answer
27 views

Rails Join not showing fields from related table [duplicate]

Profile.joins(:course) does not display the :course fields. I have tried Profile.joins(:course).select('profiles.*,courses.*') and it appears in the select, but not the from command, so none of the ...
0
votes
0answers
19 views

Cookie Cannot be expired by rails

I've been trying to use the rails ActionController cookies tool to expire a cookie that is set by a different application on the same subdomain. Essentially a legacy app sets a cookie called "ORG_SID"...
0
votes
1answer
14 views

request active storage image show only one not all images

As Rookie Rails, i am able to get all images to display on the html.erb as using model as has_many_attached :images but i have tried many different way like this code below <div class="row"> ...
0
votes
2answers
21 views

Images on Active Storage not displayed on the ERB page but another ERB page are displayed

I am bit lost somewhere, as I have build gallery with active storage and it's fine and I am able to see images and upload the images Here is a screenshot But one problem, as I try to create a new ...
1
vote
1answer
25 views

ActiveRecord::StatementInvalid (PG::UndefinedFunction

I have a checkbox field (car_options) that stores an array of values for a number of selections. I need to query all Car records that contain any of the values in another array. ["a","b","c","d","e",...
1
vote
0answers
79 views

Joins one way, but not the other

I can do this join: User.joins(profile:[:address, :activity,:hobby]) However, I can not do this.. Address.joins(:profile) I get: ActiveRecord::ConfigurationError (Can't join 'Address' to ...
0
votes
2answers
29 views

Rails query object not loading

I have a query object in Rails 5.2.2 app/queries/car_query.rb class CarQuery attr_reader :relation # code end when I reference it in the console, I get Error NameError (uninitialized ...
0
votes
2answers
23 views

simple_form accept a hash for collection input

Current behavior With simple_form you need to pass an array: <%= f.input :my_field, collection: [[true,"Yes"],[false,"No"]] %> Expected behavior It would be nice to be able to pass a hash, ...
1
vote
2answers
35 views

Loading a YML file in Rails, and maybe using a i18n file instead

I have a dropdown.yml file that stores all my dropdown values for my multi-select fields in my forms. It is not environment dependent, so I do not have :development, :production, etc. I would like ...
0
votes
0answers
11 views

how to access application helper method or variable inside devise conroller

I have a helper method defined in my application controller helper_method :current_tenant def current_tenant if ActiveRecord::Base.connection.schema_search_path != request.subdomains[0] ...
2
votes
2answers
46 views

When to use related table vs constant for drop down or multi-select fields?

I have a number of drop down fields some with 2, 4, 10, and 50 choices. This are has_one and belongs_to relationships. I also have a few many to many relationships. Currently, I am using a Module ...
0
votes
0answers
12 views

Is a presenter needed when you are referencing related tables? [closed]

What is best practice when dealing with presenters in rails? In the following post.. Decorator/Presenter/Exhibits and helpers it shows an example of a presenter module/class. In a simple case like ...
0
votes
1answer
10 views

How to add ChartKick chart as Mailer attachment?

The newer version of Chartkick has a download option that displays a button over the javascript chart, when clicked will open a new browser window and render the chart as an image. This is great. ...
1
vote
2answers
33 views

How to pass parameters from controller to serializer in FastJsonAPI?

I have a controller method drop_down_values in which I select a set of values and respond in json ,building the object using a serializer. I am using FastJson Api. I want to know , how can I access ...
0
votes
2answers
33 views

include data from one table to attachment in Rails

I need show avatar from user in posts list, in "show" avatar work. Controller def index @posts = Post.all @user = User.find(@post.user_id) end View index.html.haml = render @posts _post.html....
0
votes
1answer
43 views

After setting to_param method, nested resource cannot be created

I have 2 models, Room and Message, Room has_many :messages. The url for rooms#show was rooms/:room_id, I used to_param method to show url as rooms/:url_token. After it I failed to create messages ...
0
votes
1answer
30 views

Decorator/Presenter/Exhibits and helpers

I have read: Concerns, Decorators, Presenters, Service Objects, Helpers, Help me Decide and trying to figure out the difference between presenters, view objects, decorators, exhibits, and helpers. ...
1
vote
1answer
34 views

Configuring ActiveStorage to use S3 with IAM role

I'm trying to configure ActiveStorage to use S3 bucket as a storage backend however I don't want to pass any of access_key_id, secret_access_key, region. Instead, I'd like to use previously defined ...
1
vote
0answers
13 views

ActiveStorage in views/rendering

I dont understand well of active storage documentation. I am using <%= image_tag current.user.avatar.variant(resize: "600x400") %> this in view but so slow in rendering while calling 10 images ...
0
votes
0answers
13 views

password reset link send to mobile number in rails 5.2

I am using devise gem for authentication in rails 5.2. I am using reset password functionality of devise to create user by email through "send_reset_password_instructions" in-build method of devise, ...
0
votes
2answers
24 views

Rails5 not precompiling assets on Heroku

Simple Rails 5.2 app with NO assets folder in /public (and therefor no manifest file) When deploying, Heroku does no precompile the assets, it does not run the rails assets:precompile command at all. ...
0
votes
2answers
20 views

Rails 5 ActiveRecord - combine OR adn AND clauses

I can't figure out the right syntax to use when including several models and using AND or OR clauses. For example, there Shop model that has_one relation with Address model and belongs_to with Country....
0
votes
1answer
81 views

i18n file location and format for Named Spaced Form Object

I have a form object app/form_models/car_registration/basics.rb module CarRegistration class Basics < Base include ActiveModel::Model delegate :name, :name=, to: :vehicle end end ...
0
votes
2answers
53 views

Error (private method `select' called for nil:NilClass):

Why would I be getting this error? How do I fix it? ActionView::Template::Error (private method `select' called for nil:NilClass): class MyformObject include ActiveModel::Model #...
0
votes
1answer
29 views

Devise issue with LDAP Auth in Prod Only

I'm on Rails 5.2 and I have devise with LDAP setup and working in Development. Deploying to prod with capistrano though it errors out when put my username and password in. I get a nomethod error in ...
0
votes
1answer
41 views

Look up the class a method was delegated to? (Rails)

If I use delegate :Mayfield, to: :user What can I call on :Mayfield to see it was delegated to the :user class? SOLUTION: NOT POSSIBLE
1
vote
0answers
45 views

Active storage saving attachment even after error

Any suggestion on this front? partner.rb LOGO_VALIDATIONS = { max_size: 2.megabytes } has_one_attached :logo validate :validate_logo_attachment def validate_logo_attachment if logo.attached? &...
1
vote
2answers
98 views

Simple Form- control width of label and input (with bootstrap)

I am using Simple_form and Bootstrap. I would like to use a horizontal wrapper, but I need to make the label wider and the input narrower. I would like to do this with bootstrap 4 vs custom css. The ...
0
votes
1answer
39 views

Call create action from different controller

I would like to create a booking from bookings#new and rooms#show. When I try to create it from bookings#new it works, but when try to create it from rooms#show it shows me the error: 1 error ...
1
vote
1answer
40 views

Simple_form with Form Object missing Mapping

I am using simple_form_for <%= simple_form_for( @form_object, url: wizard_path, :method => :put) do |f| %> <%= f.input :website %> <%= f.submit %> </div> <% ...
0
votes
1answer
29 views

Rails 5 API - how to create and use a custom serializer with Active Model Serializer for the same model(s)

How is it possible to create a custom serializer for the same model ? I already have ShopSerializerdefined as follows: #serializers/shop_serializer.rb class ShopSerializer < ActiveModel::...
0
votes
0answers
43 views

Rspec devise sign in issue

devise confirm and sign_in are not working with rspec. Getting this error when running spec Expected response to be a redirect to http://test.host/accounts/1 but was a redirect to http://test....
0
votes
0answers
15 views

has_one and has_many association throw[ wrong number of arguments (given 1, expected 0)] when passed with proc shortcut

I had rails 4.2 and ruby 2.3.5 and I'm upgrading it to rails 5.2 with ruby 2.6.1. With older rails version(4.2) my UserAuthenticatedSerializer is working fine and was giving a proper response. ...
0
votes
2answers
58 views

NoMethodError (undefined method) from Private method in class

Why can't I use a private method from within my class? How do I fix my code to prevent the error? module CarRegistration class Basics < Base fields_of_model(:car).each do |attr| ...
2
votes
1answer
86 views

Query an array of hashes (Rails 5.2)

data = [ { name: :name, model: :Address, field_type: :string }, { name: :country, model: :Address, field_type: :string }, { name: :street , model: :Address, ...
0
votes
0answers
7 views

How do I override inherited load_resource in CanCanCan

I'm using Rails 5.2.x with CanCanCan 2.3.0 In ApplicationController I have the standard load_resource authorize_resource And for most controllers that's perfectly fine. But for one controller the ...
0
votes
0answers
25 views

Initializer rspec test passing, but actual code breaks when tested manually

I have an initializer in Model: def initialize(user=nil, attributes={}) @user = user indifferent_access_attributes = attributes.with_indifferent_access (self.class.seller_fields & ...
0
votes
2answers
66 views

Factory_bot ActiveRecord::RecordInvalid

Can't understand what's that error comes from, that's why my title is so awkward. All of my specs raises ActiveRecord::RecordInvalid error in random (one test raises, next one no). Here is the link to ...
1
vote
1answer
26 views

Initializing new object with parameters fail without symbols

def initialize(user=nil, attributes={}) @user = user (self.class.car_fields & attributes.keys.map{|i| i.to_sym }).each do |f| car[f] = attributes[f] if attributes.key?(f) ...
0
votes
1answer
22 views

integrate Chartkick with a rails 5.2 api only app?

When integrating the chartkick gem in my rails api-only app, the documentation states that the js needs to be improted like this in the application.jsfile. The app being an api-only app doesn't have ...
1
vote
1answer
41 views

Create FactoryBot User with has_one relationship

Background: I am trying to create a FactoryBot object which is related with has_one/belongs_to User has_one Car Car has_one Style Style has an attribute {style_number:"1234"} Question My ...
0
votes
0answers
28 views

Rails 5.2 Callback for Active Storage Blob?

How can I implement a callback (like before_save) on ActiveStorage::Blob? I try to add the follow to my Initializers folder as blob.rb: require 'active_storage/blob' class ActiveStorage::Blob ...
2
votes
0answers
22 views

Rails environment variables vs Rails 5.2 credentials

I just wanted to know what the specific differentiation is between environment variables ENV[SOME_VARIABLE] vs. Rails 5.2 credentials Rails.application.credentials.some_variable When should I use ...
0
votes
0answers
9 views

Resque logger: Not printing Active Records errors

I noticed the resque logger it's not printing ActiveRecord errors like this that I can clearly see if I manually trigger the method via "Rails console". How can I print everything to STDOUT? ...
1
vote
0answers
13 views

How to manage rails style.css and style.scss both present in rails project

Hi My I am using the Rails 5.2.1 ruby 2.4.0 I have style.scss and style.css both files present in the rails project. The application is working fine on the Development environment. But in the ...
0
votes
1answer
48 views

Rails 5 api controller not receiving params sent by frontend app [duplicate]

I'm creating a new distributed application using React for the frontend and Rails 5 for the backend. I'm new to Rails, so I couldn't figure out a solution for the issue I'm running into. The issue ...
1
vote
0answers
48 views

How to handle ActiveSupport::MessageVerifier::InvalidSignature errors for ActiveStorage direct uploads

I have a form where a user selects a file to upload. The file is uploaded once the file is selected using ActiveStorage direct uploads. There is a submit button that is not clickable until the upload ...

http://mssss.yulina-kosm.ru