Category "ruby-on-rails"

Adding scope to get objects in reverse order of their created time in rails

I'm new to Ruby on rails and programming. I am working on a exercise where I have a Post model,and I need to add a new scope to it to retrieve its objects in re

Rails log too verbose

How can I prevent Rails to log too much? Here is a typical trace in my production.log file, many partials, cache hits... It's useful in development but I don't

Rails Routes :shallow => true

Wondering why my /articles route is not coming up when I apply :shallow => true? routes.rb resources :users, :shallow => true do resources :articles e

How to replace " into space or delete first and last symbol?

I get xml data and I get value from it. I need to delete symbols [ and ] Here is my code, that gives me error about undegined variable: @xml = XmlSim

Application.js not compiling after upgrading to Rails 7 on heroku with esbuild

I updated my app on Heroku from Rails 6 with Webpacker to Rails 7 with esbuild. The error I receive on production is as follows: The asset "application.js" is n

Generic Ruby solution for SQLite3 "LIKE" or PostgreSQL "ILIKE"?

I am using SQLite3 for development and PostgreSQL for deployment. However, I am facing the following problem: My simple search using SQLite3: def self.search(

Connecting to WSL2 server via local network

I'm developing a rails app using WSL2/Ubuntu on my Windows 10 machine, which is great! The problem is I can't connect to my server from another computer in the

Ruby on Rails session[:counter ] increases by two

I am studying pragmatic bookshelf lessons. I try to make a session counter. my store controller is class StoreController < ApplicationController def

Why it runs twice when seed in rails?

I just put puts "test" in the seeds file , when I run rake db:seed, I saw there are 2 lines "test"

Rails: simplest way to put a blog on a subdomain

I've been digging around on subdomains in Rails for a couple days and haven't found a good explanation of this yet... I have a rails app which has a blog integ

Stripe recurring/subscription billing best design/practices?

I'm coming off putting together my first site with stripe, but I feel like I could have designed my stripe integration much better than I had. The main issues t

is there a way to set after_commit callbacks to a specific ActiveRecord transaction

I am creating a ActiveRecord transaction this way ActiveRecord::Base.transaction do MyModel.create!(name: "value") OtherModel.create!(name: "value") end

Bundler could not find compatible versions for gem "bundler":

Complete new person to Ruby and Rails here... Have tried some tutorials in the past, but that's about it. I'm trying to follow 'Ruby on Rails 3 Tutorial' book

<%= stylesheet_link_tag "application", :media => "all" %> <----- This piece of code is not allowing my ROR application to load locally

After installing Twitter bootstrap, I ran 'Rails server' and now the application will not load. This is the error cannot load such file -- less (in C:/Sites/c

Failed to build gem native extension: Unable to install Rails + MySQL2

I am on MAC OS X LION and keep getting error message Failed to build gem native extension when trying to install rails and mysql. This is what I am doing. I en

How do I dynamically add my Ngrok tunnel to config.hosts in Rails 6?

I'm trying to whitelist my ngrok tunnel hostname in config.hosts but it changes every time I start Ngrok. Is there a way to get the public url of my Ngrok tunne

Rails: select unique values from a column

I already have a working solution, but I would really like to know why this doesn't work: ratings = Model.select(:rating).uniq ratings.each { |r| puts r.rating

Designer learning Ruby on Rails?

I already started learning online but everything out there seems oriented to developers not designers with no baggage. I'm a graphic designer and I'm coding re

What happens after I add an index to a large table in a production Rails app and then migrate?

Rails 3.2 app running on Heroku with Postgres. I added an index add_index :lines, :event_id Events have_many Lines. There are about about 2 million Lines and

Rails i18n inflections for error messages

Does anyone know how to define a gender for the attributes in a model? So when error messages appear I can give them a specific gender such as: La direcci&oacut