Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Browsing all 4623 articles
Browse latest View live
↧

How Do I Install bundler and jekyll?

I have ruby installed and tried installing bundler jekyll but nothing is downloadingI've tried running gem install bundler jekyll and just gem install bundler jekyll in vs code terminal and my...

View Article


Replacing if in ERB with a method

I want to replace this code---myyaml: me: :name: "John" text: | My name is <% if me %><%= me[:name] %><% end %>---With something like this:---myyaml: me: :name: "John" text: | My name...

View Article


Error trying to connect external db with Rails

Guys im trying to connect my application to an external database to consume it.I configured the database.ymlI created a model to the external database.Postgres version is: psql (PostgreSQL) 17.0OpenSSL...

View Article

Implement a method that takes takes 2 parameters and returns a hash with the...

I am currently learning Ruby through the odin project curriculum. This is the project description:Implement a method #substrings that takes a word as the first argument and then an array of valid...

View Article

Why does ActiveSupport add method forty_two to Array [duplicate]

You can see the method here.Is this a joke?

View Article


How to update Ruby with Homebrew?

I want to know how to update to the latest stable version of Ruby with Homebrew. I am not interested in using RVM. Thanks.

View Article

How to make a Ruby gem executable

I can use gems like RSpec or Rails or Pry by calling their respective gem names, e.g. rspec, rails, pry on the commandline. How can I achieve this with gems I create? I'm using bundler for the basic...

View Article

Ruby on Rails, How to make a controller render different page without redirect?

Let's say we have the following pagesclip/show/111image/show/222sound/show/333where 111,222 and 333 are the IDs for different contributionsI developed a new controller called "show" that will detect ID...

View Article


Problem loading files using importmaps in rails 7

I am working on a rails 7 app that is using importmaps for all JS related stuff. For reference, I am giving the code below.importmap.rb# Pin npm packages by running ./bin/importmappin "application"pin...

View Article


How do I map an array of hashes?

I have an array of hashes:arr = [ {:a => 1, :b => 2}, {:a => 3, :b => 4} ]What I want to achieve is:arr.map{|x| x[:a]}.reduce(:+)but I think it's a bit ugly, or at least not that elegant...

View Article

dynamic components with turbo

I want to make the components dynamic through turbo so that when someone follows another person so it increments to his followers component, the problem is that this component is working but i must...

View Article

How can I avoid running ActiveRecord callbacks?

I have some models that have after_save callbacks. Usually that's fine, but in some situations, like when creating development data, I want to save the models without having the callbacks run. Is there...

View Article

Where should I put authenticated routes tests using Devise + RSpec?

I'm pretty new to Rails.We are using Devise to handle user authentication and RSpec for testing the application (Rails 4).I have an Admin devise model which has access to some authenticated routes....

View Article


uname/ps/readlink/dirname - command not found issue in react-native while...

I am getting this error while installing my react-native project:/Users/username/.rvm/scripts/rvm: line 12: uname: command not found/Users/username/.rvm/scripts/rvm: line 29: ps: command not...

View Article

define_singleton_method with a block argument (or, how to give two blocks as...

I'm trying to run this code, to overwrite each for an Array instance:my_array.define_singleton_method(:each, &block) do super { |x| x.instance_exec(&block) }endThe problem is I get this error...

View Article


Ruby on Rails: Load Utility Module for Unit Test

I have a module Datetools in lib/utils/datetools.rb:module Datetools def hello'world' endendI'd like to test it with a class called DatetoolsTest in test/utils/datetools_test.rb:import Datetoolsclass...

View Article

Polymorphic Association not working with ActiveHash

I have an ActiveHash class that I'd like to use in a polymorphic association:class Person < ActiveRecord::Base extend ActiveHash::Associations::ActiveRecordExtensions belongs_to :placeable,...

View Article


Running "rails server" results in "cannot load such file" error

Running rails server yields the following error:<internal:/usr/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:136:in `require': cannot load such file -- erb (LoadError)Did you...

View Article

The livereload does not work and there is no automatic refresh when changing...

I want to live reload website usign jukyll. I am using windows 11; I have ruby 3.3.5. I am working on the following repository: https://github.com/academicpages/academicpages.github.io. When I build...

View Article

ActiveRecord exists? with associations

I have the following ActiveRecord call:@payment = account.business.payments.find(params[:id])Which searches through associations for a payment with id of params[:id]. However, this throws a...

View Article
Browsing all 4623 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>