News Articles ruby-on-rails

How to connect Ruby on Rails 6 ActionCable to Frontend (React Native & VueJS)

I’m trying to create a live chat app using Ruby on Rails 6 with ActionCable. So, I have ChatChannel to get update, if there has a new room chat. class ChatChannel < ApplicationCable::Channel def subscribed stream_from ‘chat_index’ # stream_from "some_channel" end def unsubscribed # Any cleanup needed when channel is unsubscribed end end That it’s […]

How to redirect user to sign in page if not logged in

I am trying to redirect the user to sign-in page if the user tries to access MyAccountController. Now the issue is that the sign-in route is defined in router.js and I am not able to figure-out a way to access vue routes in rails controller. class MyAccountController < ApplicationController before_action :authenticate_user! before_action :require_user private def […]

how can call rails service in vue

I just want to call the twilio serivce on < a > tag when click on verify number service should be call and check if number is valid then proceed next otherwise show error but i don’t know how can i do this. service/twilio.rb def call(number, message) account_sid = ENV[‘TWILIO_ACCOUNT_SID’] auth_token = ENV[‘TWILIO_AUTH_TOKEN’] @client = […]

Javascript Ruby On Rails

I got stuck in a few lines of code with Javascript in Ruby On Rails. <script> function myFunction() { document.getElementById("myDropdown").classList.toggle("show"); } // Close the dropdown if the user clicks outside of it window.onclick = function(e) { if (!e.target.matches(‘.dropbtn’)) { var myDropdown = document.getElementById("myDropdown"); if (myDropdown.classList.contains(‘show’)) { myDropdown.classList.remove(‘show’); } } } </script> If I leave this […]

Rails Teaspoon Test "ReferenceError: Can’t find variable: Intl"

I am currently trying to run tests on my Rails application (Rails 5.2.5, Ruby 2.7.3) and when I run the command bundle exec rake test teaspoon I get the following error… Error: ReferenceError: Can’t find variable: Intl To try and resolve this, I have used npm install intl and yarn add intl, yet I still […]

Css changes are not being applied in rails app

I am working on rails app and now I am having trouble. Early when I use to change my frontend styling and apply changes in css then they quickly show up on reload in brower. But in present, don’t know but something went wrong. Whenever I change css and save it then onload, things remain […]

ActiveStorage::FileNotFoundError in direct upload Attach using Amazon s3 presigned url

I’m using presigned_post for generating signed_url to upload file to s3 directly from client. The file is getting uploaded correctly and returning response with a generated blob_signed_id. However , when I try to attach the file to the object , it is showing FileNotFoundError. def generate_url load_aws_credentials load_bucket blob = create_blob presigned_url = @s3_bucket.presigned_post( key: […]

Why my new CSS code is not loading anymore in my test environment?

I work on a Rails app with Rspec & Capybara in my test environment. For few days now, any changes I apply to my CSS is not anymore compiled when I launch my tests. The former CSS is well compiled but not the new one. No problem to load the new JS. I don’t really […]

Animation resetting when clicking anchor point using jquery & js

I have a background animation (some bubbles), and everytime I click a link in the navbar that jumps to an anchor point on the same page, the animation resets. I’m using ruby on rails and jquery, here’s the code: /* _navbar.html.erb*/ <div class="navbar"> <div class="logo"></div> <div class="navbar-items"> <div class="item"> <a href="#section-one">Home</a> </div> <div class="item"> <a […]

Rails API pushes has_one: image from Model items to Cloudinary but cant

I have a question that I have been stuck on for over a month and would appreciate any help. I have a Rails API with a model Items that has_one: itemPphoto. I am using activeStorage to upload the images to Cloudinary. I am also using Administrate gem which is where I use the form to […]

RubyOnRails como cargar estilos y js de Metronic7 [closed]

Hola amigos recién empiezo a usar RoR y me gustaría montar en mi sitio el framework Metronic pero por más que intento cargar los css y los js de Metronic7 siempre me da un error en consola, me ayudarían con algunos pasos para dejar esa parte funcional Gracias a todos* Source: CSS – Stack Overflow

How to read realtime ActiveRecord in Ruby on Rails

I want to read DATA which I have recently save in rails console to show up on my index page by real time. Rails 6.1.4 Ruby 2.7.0 How should I do? or Does anyone have got a solution for making this? Source: JavaSript – Stack Overflow

how to get an element from other ruby file

I want to change the background color of a class in fixtures class, but I dont know how to get the element (I am trying to change it from another file). How do I get the card element from page_edit.html.erb file, as shown below? I want to change the background of(db>fixtures>page_template.rb ): <div class="card" style="…"> […]

I am pretty nervous about studying Computer Science, I don’t know what I will/can do after graduation and what jobs I could go for [closed]

I am a first year undergrad and I am currently studying Computer Science. I feel really unclear about my future path and I have no clue about what I need to do during the first/second/third year of university. I heard that there are lots of graduated students who are struggling in finding a job after […]

Yarn test to detect compile time errors in rails vue app

If we run yarn build, the build is failed due to syntax error in SCSS but when I run yarn test:unit, the tests get passed. Is it possible to check compile time errors before the test suites run so that It can cause build to fail in CI/CD tool. One solution is to execute yarn […]

CDN Bootstrap not applying in Ruby on Rails

I was unable to load the web app with gemified bootstrap so I decided to use the CDN bootstrap for a change. Added this line in my index page but it does not apply on the web app. What could be the problem? <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> Source: CSS – Stack Overflow

use vue routes in rails controller

I want to redirect the user to sign-in page if the user tries to access myaccount controller. Now the issue is the sign-in route is defined in vue router and I am not able to figureout how can I access vue routes in rails controller. class MyAccountController < ApplicationController before_action :authenticate_user! before_action :require_user private def […]

Swiper doesn’t work after migrate from webpacker to esbuild on rails 7

I’m not sure what I’m wrong with my code, my image slider has been working well it shows 3 images on one slide but after I removed "webpacker" and "webpack", and installed "jsbundling-rails" and "esbuild" the image slider doesn’t work and it shows only 1 image Here’s my code <div class="listing-slider-wrap fl-wrap"> <div class="listing-slider fl-wrap"> […]

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.