News Articles ruby-on-rails

Webpack not loading font from plugin in Rails

I’m new to Webpack and I’m trying to load the stylesheet of a plugin lightgallery installed through yarn add. I can successfully load the JavaScript. However, the stylesheet crashes when trying to load a font: Error: Cannot find module ‘../fonts/lg.woff2?io9a6k’ It gets loaded as follows: app/views/layouts/application.html.erb: <%= stylesheet_pack_tag ‘application’, media: ‘all’, ‘data-turbolinks-track’: ‘reload’ %> app/assets/javascript/packs/application.scss: […]

Combining multiple objects into one Redux reducer to implement an all encompassing search feature

I am new to React and Redux and am trying to figure out how to best implement certain functionality. I am building an app in which a user can add a business, event, or professional to a database (Rails backend) after signing in. I want to store all of these various object types into one […]

Reuse socket connection while avoiding stale React hooks closure

Here is a simplified version of my problematic code. I’m trying to create a socket connection (Rails Action Cable) in such a way that it doesn’t get recreated on each render (tried that first and Chrome crashed). At the same time the code that needs to run when an update comes in over that socket […]

How can I simulate hitting enter or clicking outside a filled form to send data to server?

I have a Rails app and and a form using React. When a user fills a field, the data is sent the moment they press enter on their keyboard or when they clicks anywhere else on the page. I’m testing this feature and I’m trying to reproduce the same behavior but what I’ve tried so […]

How do I get an object (in React via POST) to save under the correct foreign key (Rails backend)?

I am building a React/Redux spa with a Rails backend. I am stuck with figuring out how to fix what seems to be a foreign key reassignment at POST request. The association I have in the backend is Daycare has_many :toddlers and Toddler belongs_to :daycare. The schema shows that toddlers belong to daycares through the […]

Rails HABTM post on React

well we have a litle bit situation here! after setup a has many through association how the hell associate some tags on post creation with react and formData post? So i placed the post model, tag model, and postform react page iv’e tried to append the selected tags using the post[tag_ids][] on append method and […]

Frontend Handling: FILES/CSV with Rails API

I have a Rails API endpoint which sends a csv file on API request: def download_csv headers = [‘column one’, ‘column two’, ‘column three’] csv_data = CSV.generate(headers: true) do |csv| csv << headers csv << ["A", "B", "C"] end csv_data.strip send_data( csv_data, filename: ‘attachment.csv’, type: :csv, disposition: ‘attachment; attachment.csv’, ) end Problem: When i hit […]

How to check if user logged in using React and Embedded RuBy (erb)?

I am working on the task where I should allow the user to perform some actions if it logged in and in case if it’s not I should redirect the user to the Login page. The project itself is built using Ruby on Rails, Reactjs. It uses embedded ruby (erb) to display the Login button. […]

How to Make your Rails App Work with the Mac M1 Chip [SOLVED]

Get your rails app running from terminal using the following steps on MacBook M1 Chip. Read the full story Source: Hackernoon

TypeError (no implicit conversion of Integer into String) on Redmine with only one user

When i want to make a response from issues, we insert the parent code issue and log print the error: Started POST "/projects/territoriosinteligentes/issues" for at 2021-10-05 12:47:38 -0500 Processing by IssuesController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"gV0qTgeB0kAuwA5noFBh3bKbVfTeIgheS71Ku8v1fFD0jFb1Kp1gsLb5+cu6sFZ1Ga6lg6hc7qt/pWnOJ50hjA==", "issue"=>{"project_id"=>"159", "tracker_id"=>"4", "subject"=>"MEMORESP", "status_id"=>"1", "is_draft"=>"0", "priority_id"=>"2", "assigned_to_id"=>"", "parent_issue_id"=>"1630", "due_date"=>"", "description"=>" MEMORESP rn"}, "was_default_status"=>"1", "assigned_user_ids"=>["282"], "estadoPeticion"=>"0", "idciu"=>"", "commit"=>"Crear", "project_id"=>"territoriosinteligentes"} […]

How to create frontend UI with bootstrap form in rails?

Here i have bootstrap action form for rails application i want to create frontend UI signup form for interactive user interface. Below is my code for signup from <%= simple_form_for(@user, url: signup_path) do |f| %> <div class="input-group"> <span class="input-group-addon" id="sizing-addon0">@</span> <%= f.input :username, input_html: {class: ‘form-control’}, placeholder: ‘username’ %> </div> <div class="input-group input-group-lg"> <span class="input-group-addon" […]

Rails infinite scroll save scroll position if use back button or refresh the page

`"show.html.haml" %script{:src => ""} :javascript $(document).ready(function() { if ($(‘.pagination’).length) { $(window).scroll(function() { var url = $(‘.pagination .next_page’).attr(‘href’); if (url && $(window).scrollTop() > $(document).height() – window.visualViewport.height – 50) { $(‘.pagination’).text("Loading More Videos….."); return $.getScript(url); } }); return $(window).scroll(); } }); .wrapper-v .button-link-v %p#instavoto2 #{@profile.line2} %br/ %p#instavoto2 Total videos present: #{@profile.posts.count} %br/ #posts = render @posts .pagination […]

Can’t get update action in Nuxt and Rails

What I want to come true I’m developing with Nuxt and Rails, and I’ve been using the update action. #Code This section describes the interaction with Rails. store/index update (context) { const list = context.state.todos.list const selectedBook = const postItemsAttributes = => { return { id:, content: item.content, status: false } }) […]

How to make animate.css work in rails? As animate-rails is not working on heroku

animate-rails is not working on heroku, but working on local. Coffeescript is working on heroku production though. rails version: Rails ruby version: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20] Below is the code in the respective files: Gemfile gem "animate-rails" application.css.scss *= require animate application.js import ‘animate.css/animate’ package.json "animate.css": "^4.1.1" production.rb config.assets.compile = false html […]

Data input is not moving from Front End to Back

I have a DB full of tickets, each with attachments. Each ticket currently has an image attachment and my current goal is to have a text input (in VueJs), which will attach that text input to the ticket. However, after inputting ‘Hello World’, I can see in my VueTools that the data component has picked […]

Hosting on netlify

My pg is running locally and with lsof -i :5432 my pg is running on my account just fine. But when I try to host on netlify I get In Gemfile: pg Error during gem install when trying to deploy the site full log below I have also tried deploying to heroku as well but […]

How to track the flow of data from a Vue component to a Rails App?

I have a text input box along with 2 images attached to a ‘Case File’, I can see when I type in the box that the data contains in my message input in the same array as the images. But when I view this data in my Rails Model, the message input is nowhere to […]

【Rails6】Action Cable don’t GET ‘/action’

I try to use Action Cable on Rails6. I can broadcast from controller like below, but can’t receive this on browser. ActionCable.server.broadcast "message_channel", message: message.content For doesn’t GET /cable on local server log, I guess this causes because my application working on browser doesn’t initialize Action Cable correctly. Please tell me how to initialize Action […]

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.