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

better way to use rails activerecord query

I have to get primary users and secondary usersquery I have written as below:users = User.where(organization_id: 1234)primary_user = users.find{ |user| !user.secondary }secondary_users =...

View Article


(Canvas LMS) Email Attribute Missing on Canvas LMS User API with non-admin...

I'm building an application for my school as a project for one of my courses. Authentication for this application is being handled by our own Canvas instance with OAuth2. But I encounter an issue when...

View Article


Ruby forgets local variables during a while loop?

I'm processing a record-based text file: so I'm looking for a starting string which constitutes the start of a record: there is no end-of-record marker, so I use the start of the next record to delimit...

View Article

When sending a reply with the Gmail API, is there a way to include the text...

When I use the MS Graph API to reply to emails, it automatically adds the quoted text to the reply email from previous emails in the email thread. Is there a way to accomplish this with the Gmail API...

View Article

Regex to match certain numbers from and to a range

I have tried chatgpt for a correct answer but it doesn't give me a working solution.I want to match (only) the digits before the "m2" and only if it is preceded by the wording "landgang" (as is in this...

View Article


Can VSCode override environment variables

I've set up a devcontainer in a VSCode Ruby project, and the launch configurations don't seem to be able to override environment variables from the devcontainer. I set up the devcontainer to launch...

View Article

Destructuring in a Ruby block when using index

Without using index I was able to destructure the first and second elements of an Array of Arrays like so:[ [ 1, 2 ], [ 3, 4 ] ].each do |first, second| puts secondend#=> 2#=> 4I then needed to...

View Article

Accessing class constant from within a module

I need to access an ActiveRecord constant from an included module in a Rails app.class User < ApplicationRecord include ModOne OPTIONS = {a: 1}.freeze ...endModule ModOne extend...

View Article


Ruby Rspec Mock Same instance to behave different in the first and second call

I have a code that looks like this:def call(some_id:) verify_before = @verify.call(some_id) return verify_before if verify_before.sucess? did_something = @processor.call(some_id) return did_something...

View Article


How do I resolve the `Dynamic constant references` error in Sorbet?

How do I resolve the Dynamic constant references error in Sorbet?module A CONSTANT = { x: 1, y: 0 }.freezeendmodule B CONSTANT = { x: 0, y: 1 }.freezeendclass C def initialize(kind) @kind = kind end...

View Article

How to make helper_methods available to Views in Rspec

We have some helper_methods in our controllers that are used across both the controller and the view they render.For example:helper_method :example_methoddef example_method @example_method ||=...

View Article

NameError in CompetitorsController#index

I am getting this problem when I run this code in server. In my localhost everything is running fine. But when I deploy my code in the server it shows me the error.I am using FERRET SERARCH IN...

View Article

Suppress Ruby warnings when running specs

I'm looking for a way to suppress Ruby warnings when I run my specs.spec spec/models/account_spec.rbI receive warnings such as:DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated,...

View Article


Rspec - How to replace receive by have_received when dealing with an expect...

I have the following Ruby class I want to test:class Logger # ... def process X.process rescue StandardError => e ::Rails.logger.error('Progname') { 'Could not produce the audit log' }...

View Article

Is there a hook similar to Class#inherited that's triggered only after a Ruby...

#inherited is called right after the class Foo statement. I want something that'll run only after the end statement that closes the class declaration.Here's some code to exemplify what I need:class...

View Article


How to fetch the first matching item from an array

Given an array: [1, 2, 3, 5, 8. 13]I can select all items greater than 3:[1, 2, 3, 5, 8. 13].select { |num| num > 3 }(I am aware of the shorthand select(&:>) syntax, that is not the point...

View Article

Undefined method `create_table' for ActiveRecord::SchemaMigration:Class...

When i create padrino framework with sqlite3 and activerecord.padrino rake ar:migrate@schema_migration.create_tableOr when:padrino rake ar:schema:dump undefined method `with_connection' for...

View Article


can't find gem cocoapods (>= 0.a) with executable pod (react-native pod install)

I just start a react-native project. However, this question had me for a day.I tried all possible way to solve it. For example,sudo gem uninstall cocoapodsrvm uninstallbrew install cocoapodsHowever,...

View Article

Ruby on Rails: How can I access Action Cable through ngrok?

I started the puma server as normal as port 3000. In my development file, I have:config.action_cable.url = "wss://xxxxxx.ngrok.io/cable"config.action_cable.allowed_request_origins = [/http:\/\/*/,...

View Article

Is it possible to use Ruby FFI to send a Ruby (C API) VALUE to a function?

I'm currently trying to bridge Numo::NArray and FFI, so that an FFI Pointer can access the raw data in a Numo::NArray without having to copy data through String like I do now (thus causing GC churn and...

View Article
Browsing all 4612 articles
Browse latest View live


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