Category "ruby-on-rails"

How to use stimulus components with rails import maps

I want to include this stimulus component into my brand new rails 7 app: https://www.stimulus-components.com/docs/stimulus-dropdown When I follow their setup ap

net::ERR_INCOMPLETE_CHUNKED_ENCODING nginx

I have 2 RoR web applications hosted on 2 different servers. For one particular page, the request is served from the second application. For rest of the pages,

Divider in divs with Tailwind

I have this now <div class="w-2/3"> <h2 class="text-2xl font-semibold">Ordered Items</h2> <table class="w-full border-collapse"> .....

ActiveModel serializer inheritance

say I have this serializer class FooSerializer < ActiveModel::Serializer attributes :this, :that, :the_other def this SomeThing.exp

How to find where a view partial is used?

How do you go about easily finding out where a Rails view partial is used? In what views, controllers etc. This is handy when working on an app that someone e

Rails 5 reads environment variables as string in YAML file

I have a Rails 5 app and I am trying to import my Environment Variables in a yaml file, which I can then import in the environment.rb. My config/aws.yml looks a

How to correctly use Devise + Confirmable + fixtures

I'm using Devise + Confirmable for user authentication and Minitest + Capybara + fixtures for testing. I can make working logged in tests for users as long as I

Change the default value for table column with migration

I try to change the default column value from false to true. But when I run rake db:migrate VERSION=904984092840298 I got the following ERROR. StandardError: A

Why won't Rails.cache store API responses?

I am trying to cache the results of API calls. My application makes multiple calls with the same result and I would like it to use the cache to save time. When

Empty file_field on submit: param is missing or the value is empty

I have a application with dragonfly to manage my image uploads: ruby 2.1.3 rails 4.1.6 The upload works but on update action, when the file is empty, I have the

How to rename a rails 5 application?

Is the rename gem the best way to rename my rails 5 app? Also, is there any notes I have to keep in mind when renaming my app?

Rails: During asset precompile throws error key must be 16 bytes

I am storing my secret key in environment and /config/environments/production.rb has config.require_master_key = true uncommented config.require_master_key = t

Is it better practice to specify a Rails version or branch in a Gemfile?

I'm presently using gem 'rails', '~> 5.0.0' in my Gemfile. I just learned of a different way to specify a Rails branch, which is: gem 'rails', github: "

Does an OAuth Consumer validate a bearer token with the OAuth provider on each request

To learn more about OAuth, I'm trying to write an OAuth 2.0 provider and also a consumer. I'm kind of using the Doorkeeper Gem as a reference for my provider, b

Create an ActiveRecord::Relation in rails 6 with a different table

I am trying to upgrade partitioned gem in order to use partitioning with Rails 6.1 (I am upgrading an existing Rails application). I have managed to get everyth

Encoding 4 byte UTF-8 character to JSON from Rails produce invalid character

I have a web service in rails (3.2.19) that encode a JSON to be read by some iOS or Android apps. The json might contain any characters, but it seems to fail ev

How can i create JSON array of JSON objects in ruby from a loop

I am trying to loop through some video objects and i am trying to build a JSON array that looks like this: [{"event_name":"video_completed","object_id":1234567

Rspec 3 how to test flash messages

I want to test controller's action and flash messages presence with rspec. action: def create user = Users::User.find_by_email(params[:email]) if user

To show your comment first if you are logged (and if you left a comment)

I am editing a Book-page improving the Comments-Area. Now it is a "classic" area where the latest 3 comments are showed. But I want to edit it showing first the

How do I drop a foreign key if it exists in Ruby on Rails?

There's a function called index_exists? in ActionRecord, but no foreign_key_exists? on Rails 4.2.7. So when I call remove_foreign_key :parties, :franchise_gr