Category "ruby-on-rails"

Rails: rendering a partial for a nested resource

# routes.rb resources :topics do resources :bookmarks, except: [:index] end The view files for my Bookmark model live in app/views/topics/bookmarks: I re

How do you send JSON data in a rails-ujs Rails.ajax POST call (not using jQuery)?

I have a React client app that needs to talk to a Rails API. I want to use the rails-ujs method Rails.ajax. For example: Rails.ajax({ type: "POST", url: "

Ruby On Rails - NoMethodError: undefined method `[]' for nil:NilClass

I'm trying to run on a new computer some ruby code and I receive the following error (rails db:migrate --trace) ** Invoke db:migrate (first_time) ** Invoke db:

rails generated CSV file can't be downloaded

I'm trying to export my database to CSV file and download it but it doesn't download. I have a form with 2 different actions, Export to CSV and Export to JSON I

Is it OK to specify a schema in `table_name_prefix`?

TL;DR: Is it OK to specify a schema in table_name_prefix? We have a large Rails application that is not quite a traditional multi-tenant app. We have a hundred

Line break when combining image_tag and text in Rails navbar

I want to combine a logo and the brandname as text in my bootstrap based navbar. The problem is I can't figure out why there is a line break and the text not on

Heroku error: "key must be 16 bytes" but the key I have inputted is 16 bytes

I am launching to Heroku for the first time and I am getting the error "ArgumentError: key must be 16 bytes". I have run rails credentials:edit to generate a

How do I get the size of a ruby object in mb in Rails?

I want to query an ActiveRecord model, modify it, and calculate the size of the new object in mb. How do I do this?

ArgumentError: wrong number of arguments with `bundle exec rake db:migrate`

I'm trying to install Discourse in macOS for development, following the steps mentioned here: https://meta.discourse.org/t/beginners-guide-to-install-discourse-

Rails, uninitialized constant Faraday::FlatParamsEncoder in sunspot solr

I'm using rails 4 and sunspot solr, when I pass the params to the controller for performing the search, i'm getting uninitialized constant Faraday::FlatParamsEn

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