Category "ruby-on-rails"

how to check if has_one exists without loading associated model

I have a simple has_one relationship class User < ApplicationRecord has_one :detail has_many :courses end class Detail < ApplicationRecord belongs_

Error when installing Ruby on Rails: "Failed to build gem native extension"

I'm running Crunchbang 11 (Debian-based). I'm trying to install Ruby on Rails, like this: gem install rails --version 4.0.0 I get the error "Failed to buil

Unable to export traces to OpenTelemetry Collector on Kubernetes

I am using the opentelemetry-ruby otlp exporter for auto instrumentation: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/exporter/otlp The otel

Difference between after_create, after_save and after_commit in rails callbacks

The difference between after_create, after_save and after_commit in Rails is that: after_save is invoked when an object is created and updated after_commit is

Undefined method `after_create_commit' for Message:Class Did you mean? after_create - Rails action cable tutorial

I've tried to follow the ActionCable tutorial - Site point and I convert this tutorial to using MongoDB . But I have the problems with devise NoMethodError in

Namespacing service objects in Rails 6 with Zeitwerk autoloader

Rails 6 switched to Zeitwerk as the default autoloader. Zeitwerk will load all files in the /app folder, eliminating the need for namespacing. That means, a Tes

Multiple route aliases in Rails 4

I have a Rails 4 application with some routes: resources :users resources :notifications resources :comments ... My client asked me to have urls in english a

heroku rails build fails with crazy error... possibly node issue?

I have an app that I haven't updated in like a year or so, today I make 1 tiny change, doesn't break anything, but when pushing to master I got a lot of stuff..

Can't see reason for Compiling… Compilation failed: (Executor::NonZeroExitStatus)

Deploying on beanstalk. Using rails with webpacker. Compiling… Compilation failed: (Executor::NonZeroExitStatus) We can't seem to get anymore in

Rails authentication strategy

Hope this is not too broad but after a lot of googling I am not sure where to start. I am looking for a introductory/noob overview to help me get started on bui

Running migrations with Rails in a Docker container with multiple container instances

I've seen lots of examples of making Docker containers for Rails applications. Typically they run a rails server and have a CMD that runs migrations/setup then

Rails 4 stylesheet_link_tag sometimes uses relative paths?

I have this weird problem, where sometimes, stylesheet_link_tag links to the relative path to the wrong path? The exact same code works whenever I try to debug

How do I add an uncountable inflection for a non-word character in Rails

In a Rails app I have a number of measurements to display in a human readable form that include both a value and units. Sometimes the units string needs to be

Rails action Mailer raise_delivery_errors, how does it works? How to detect bounces?

I have a Rails 4.2.0 application which sends lots of mails, it's a elearning platfrom. At the moment I have problems with bounces, Lots of the Mails coming bac

Errno::EACCESS: Permission denied @ dir_s_mkdir

I am pretty new to Ruby.. was following the instructions on TeamTreehouse installing Ruby Development Environment on OSX (Yosemite). When I got to the step to

Testing login flow with RSpec in Rails app

I'm using RSpec to test controller behavior in rails. One of the expectations I have is the following scenario: User attempts to access a protected (requires l

Testing associations with rspec: Category does not have a post_id foreign key

I'm trying to test some associations with RSpec but I get these failures: Category Failure/Error: it {should belong_to :post} Expected Category to have

Rails: make authentication to swagger API via devise or other

My goal is log in to Swagger API to get access to endpoints. With auth token in future. I tryed to put Devise line in ApplicationController: before_action :au

GroupingError: ERROR: column " " must appear in the GROUP BY clause or be used in an aggregate function

I am trying to create a list of unique patients who have left comments. The code words fine until I upload to heroku where it doesnt work in postgresql. This

ruby-build: definition not found: 2.2.1

I want to install new version of ruby by rbenv install 2.2.1, but I get the error ruby-build: definition not found: 2.2.1 The following versions contain 2.2.