News Articles ruby-on-rails

Rails form – change select options based on another selected option through JavaScript

I am looking for a way to change the options in a rails form.select field through JavaScript based on the selected option for another select field. The way I was trying to do this before was by using two separate fields with the same object and different sets of options, like so: <%= form_with(model: my_model) […]

Whenever I start my app using `npm start` it brings me to the Ruby on Rails Homescreen instead of my index.html file

all. I am somewhat new to software development, but I know how to use React/Redux very well, as well as Ruby-On-Rails. I am trying to have a React Frontend powered by a Rails backend. I understand conceptually how node.js works, but not exactly the minutia. My app worked perfectly in the beginning stages before I […]

Getting items from one table that don’t have a corresponding foreign key in another table

Hi I am working on a react app that is on a ruby on rails server setup, that uses postgres. I have two tables in the database, movies and genres. In the movie table, there is a field genre id. And in the genre table its ID is how it links to movie table’s genre […]

Undefined variable $alert-padding-y

I have imported my css and js files and started my web app but this is what is shown as soon as I access the page. I have imported bootstrap and added a line to precompile but the error still shows up. Is there something I am missing out? Error: SassC::SyntaxError – Error: Undefined variable: […]

Submitting a Remote Form via rails-ujs

I’m slowly modernizing a legacy Rails app, and am trying to swap out jquery-ujs for rails-ujs. I’ve installed rails-ujs via the asset pipeline, and know that this is working as expected: in my browser’s console, I’ve got access to the Rails object. But, when I try to use the Rails.fire event to submit a form, […]

Add Gridlines using ChartKick in Rails

Using ChartKick with and chart.js I want to add horizontal gridlines. Data range is 100 to 200, but default goes from 0 to 200 with one horizontal line at 100. I’d like to have the range be from 100 to 200 with horizontal lines every 10 units. <% begin_tracking = Time.zone.parse(‘2021-03-24 18:33:00-07’) current_date = Time.now […]

how to add js in rails 5?

I am new in rails I was making project in which I implemented devise now I want to do some js like when user clicks on input field then do something but I didn’t find anything helpful mostly there are latest rails 6 question/answers I want for rails 5. I also found most users used […]

Ruby on Rails does not include Authorization token on header when request by axios in React, but it does work with Postman

I’m currently working on a backend API using Ruby on Rails, Devise, and Devise-JWT, with NextJS on the frontend client, using axios for requests. I’ve been trying to access the Authorization token from the header (once the user logs in), to then store the token into localhost but it doesn’t come within the header on […]

Changing pages disables navbar menu on Ruby on Rails

I have this problem. When the screen width goes below 1024px, the navbar changes to a responsive navbar that activates when a burger menu is clicked, this is made using javascript (it is being correctly compiled, the file is imported in application.js). This functionality works fine, but when I change pages (from home to store […]

Converting typescript to javascript

Is there currently any converters online that could convert ts to js? I would like to use the components from here, but they’re all written in ts and my rails app doesn’t support it. for example this file import { Controller } from "@hotwired/stimulus" import { useTransition } from ‘stimulus-use/dist/use-transition’ export default class extends Controller […]

Converting typescript to javascript

Is there currently any converters online that could convert ts to js? I would like to use the components from here, but they’re all written in ts and my rails app doesn’t support it. for example this file import { Controller } from "@hotwired/stimulus" import { useTransition } from ‘stimulus-use/dist/use-transition’ export default class extends Controller […]

Rails API service throwing 401 Unauthorized in React running on Chrome locally

I am running rails api service with React as frontend, While running it locally I am getting 401 Unauthorized error. On rails users are authencated via session, and the problem occurs in chrome only, on Firefox data is fecthed with 304 Not Modified status. Any help highly appreciated. Source: React – Stack Overflow

Dynamically set a number in a classname depending on the number of elements in a loop

The thing is a little bit difficult to explain for me, so I’ll do my best. I have a slider, and inside it a each loop returns 3 elements (three products), and I want to set a classname "slider-n" where n is the element number (it should be 1, 2 and 3). I can’t, for […]

Uncaught TypeError: $(…).barrating is not a function – Rails / Turbolinks

I’m using Barrating Javascript from https://antennaio.github.io/jquery-bar-rating/ on my Rails application which uses Turbolinks for the page loads. I’ve included the barrating.min.js in my javascripts and i’m loading it in my application.js using //=require – it all loads in fine. I then have a ratings.js located in my assets/javascripts area that makes the call to create […]

What is the proper way to call javascript functions from within a rails view?

I’m really new to rails and the asset pipeline has been tripping me up for a bit. From what I understand, all javascript files in the assets/javascripts directory are compiled into one singular js file called application.js that contains all the functions in all the js files in the directory. My first question is, what […]

Ruby On Rails using Jquery for Dropdown

I’m trying to use Jquery for my Web App using Ruby On Rails. But I got a problem that the Toggle() only works for the home page. Here are some of my files: _header.html.erb <div class="topnav"> <% if user_signed_in? %> <!– <div class = "show_username" style = "float: right" href="Show Username"><%= current_user.username %></div> –> <div […]

Problems with passing data to Javascript from a Rails view via <%= content_tag %>

I’m rather new to Rails and to programming in general, and I’m having issues passing data from a <%= content_tag %> in a Rails view to a Javascript function (in this case, specifically making use of fullcalendar). Inspecting the rendered page’s HTML source shows the data properly ending up in the resulting div, but the […]

Javascript Event Listener not executing within Rails App

After scouring the internet, and rewatching as many explanations as I could I am just not getting the result I was expecting. The expected result is when a User selects "All Appointments" that it switches from the calendar view to a list view. I can see the correct route is being called in Calendar (http://localhost:5000/appointments#calendar) […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.