jeudi 29 septembre 2022

ActiveRecord::HasManyThroughAssociationNotFoundError cannot get the posts for each user for some reason Rails

In the rails console I am inputing User.first.posts and i am getting this error ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :likes in model User from

USER MODEL

class User < ApplicationRecord
    has_secure_password
    has_many :posts
    has_many :comments
    has_many :posts, through: :likes

    validates :name, presence: true, uniqueness: true
end

POSTS MODEL

class Post < ApplicationRecord
belongs_to :user
has_many :comments
has_many :likes
has_many :users, through: :likes
def number_of_comments
    comments.length
end
def number_of_likes
    likes.length
end

end

LIKES MODEL

class Like < ApplicationRecord
belongs_to :user
belongs_to :post
end

Im only showing you the likes model because its popping up in the error but i just want all the posts for each user so if i type User.first.posts all their posts will show up

How can I access these nested attributes in parameters?

I'm trying to get the value of one of the parameters sent, but I'm using nested attributes and when creating an object, the nested attributes have a kind of token, which prevents me from accessing the attributes through the key.

How can I access these nested attributes in parameters?

 Parameters: {"utf8"=>"✓", "authenticity_token"=>"Xodtke+W96O+hiEH8AvnK4F5XZF5U9b8148YyVTsZX5XNlkdOxmv4RTge+9MmOtfoNLOaUZbcpMcTVxRFSwRUQ==", "comanda"=>{"cliente_id"=>"1", "forma_pagamento_id"=>"1", "R$valor_total"=>"", "status"=>"false", "itens_comandas_attributes"=>{"1664413214142"=>{"produto_id"=>"1", "valor"=>"", "quantidade"=>"", "_destroy"=>"false"}, "1664413217936"=>{"produto_id"=>"2", "valor"=>"", "quantidade"=>"", "_destroy"=>"false"}}}, "commit"=>"Create Comanda"}

Here, in the nested attributes, this token "1664413214142" that contains the values, but if I try to access the "product_id" key, it doesn't return anything:

    puts params[:comanda].has_key?(:itens_comandas_attributes)

true

    puts params[:comanda][:itens_comandas_attributes]

it doesn't return anything

dimanche 25 septembre 2022

Avoid duplicate sidekiq job

I have a worker that runs when the user selects a time. If the user selects a time twice, the worker runs twice. How do I avoid it from being executed multiple times? I mean, If the user selects to be executed after 10 minutes, then deletes this request and again selects to be executed after 10 minutes, the worker executed twice.

class EnableWorker
  include Sidekiq::Worker
  sidekiq_options queue: :general, retry: 0

  def perform(enable_at)
    puts enable_at
  end
end

jeudi 22 septembre 2022

Calling AJAX in Coffeescript

I have an ajax call that works well in a view, but I would like to make it in a coffee script, right inside a datatable call. The code looks like:

    $(document).ready(function () {
    $.ajax({
      type: "GET",
      url: "<%= people_path(format: :json) %>",
      dataType: "json",
      success: function({data}) {
        const user_ids = data.map(user => user.id)
        $("#people-ids").html(user_ids.join());
      }
    });
  });

I am new to coffeescript, so I need some help to finish the method around the mapping section. I could go as far as this:

ajax:
  type: 'GET'
  url: $('#people-datatable').data('source')
  dataType: 'json'
  success: ({data}) ->

I obtain 7 objects in {data}, but i do not know how to continue to retrieve their ID as in JS. can someone help please ?

mercredi 21 septembre 2022

Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted

config.action_mailer.default_url_options = { :host => 'localhost'} 
  ActionMailer::Base.smtp_settings = {
    :user_name => 'xyz@gmail.com',
    :password => 'nico6655',
    :domain => 'gmail.com',
    :address => 'smtp.gmail.com',
    :port => 587,
    :authentication => :plain, 
    :enable_starttls_auto => true,
    :openssl_verify_mode  => 'none'

  }

How to fix the 'SMTP could not authenticate' error?

mardi 20 septembre 2022

Rails partial path when bootstrap tab active

I am building a profile page that contains a navigation tab with 3 tabs(account, settings, and language&display). Each tab renders a partial. What I want to achieve is that for each partial rendered the URL will change as well.

For example when Settings tab is active I want to be on settings_path, and the url: localhost:3000/settings.

my page here

I did not find anything about partials and paths, do you have any idea about this?

Why do I get a syntax error in my ajax based shopping cart?

adding ajax features to cart 1

I am trying to build an online store, and I have opted to include ajax in the shopping cart. I am stuck as I don't understand why ajax is not showing. I am only seeing this error in console which I have failed to understand.

VM1510:2 Uncaught SyntaxError: Private field '#hiding' must be declared in an enclosing class
    at processResponse (rails-ujs.js:281:1)
    at rails-ujs.js:194:1
    at xhr.onreadystatechange (rails-ujs.js:262:1)

dimanche 18 septembre 2022

How to bypass hCaptha with accessibility

Hi I have a rails application built for web scraping our results from the site by entering register ID. But they have updated the site by including hCaptcha so I would like to know how to bypass and fetch the results from the site by looping roll calls( register IDs). Can anyone help me with that, please?

Site: https://jntuaresults.ac.in/view-results?resultSetId=fb1924a4-494e-41ba-a9ad-0aff49cc0064

Roll calls range : 219f1a0501..219f1a0599

https://dashboard.hcaptcha.com/welcome_accessibility

I have seen this cookie setting which works but I need it in the form of a script.

samedi 17 septembre 2022

Ruby on Rails Developer Coding Test [closed]

Please I need help with preparing for the Ruby on Rails coding test assessment for a Ruby on Rails developer position. Please can anyone recommend a very good resource for practice?

vendredi 16 septembre 2022

Websocket fails to start in ruby rails 7.0.4

I have been trying to set up an action cable with ruby on rails version 7.0.4 and fail to do In the app/channels/application_cable.rb my configuration file is as below. As per official documentation, every connection should be identified, so I decided to identify that via random string:

module ApplicationCable class Connection < ActionCable::Connection::Base identified_by: random_string

def random_string
  return SecureRandom.base64()
end

end end

I have only a single channel, called room_channel for learning purposes:

class RoomChannel < ApplicationCable::Channel

def subscribed stream_from "room_channel" end

def unsubscribed # Any cleanup needed when channel is unsubscribed end end

in the app/javascript/channels/consumer.js I created below configuration and set up at least 1 consumer, so my app could work

import { createConsumer } from "@rails/actioncable"

export default createConsumer()

createConsumer(getWebSocketURL)

function getWebSocketURL() {
  return "ws://159.61.241.9:8000/cable"
}

My config/environments/development.rb file is as below for action cable related settings:

config.action_cable.url = "ws://localhost:6379/cable"
  config.action_cable.allowed_request_origins = ['http://159.65.241.9:8000']
  config.action_cable.mount_path="ws://localhost:6379/cable"

my cable.yml file in the config as below:

    development:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>


test:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>


production:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
  channel_prefix: action_cable_chat_app_production

I started up the redis server already. The error I end up with is as below: enter image description here

Can someone please help me why WebSocket tries to start at 8000 port even though I mount the server in 6379 in the config file ?

jeudi 15 septembre 2022

NoMethodError : Undefined method in NilClass

I'm currently accessing the same piece of code from two routes in two different files. I have the code in file X which is rendering or accessing by a link. I created a file Y and copy pasted same code present in X and rendering this particular file from a different link in routes file. For example - two different links -

 get '/holdings/:holding_name/board ,to : 'dashboard/x

 get '/scoldings/:scolding_name/board ,to : 'dashboard/y 

I've created file Y and copy pasted code from file X which has a method named .operations. Please don't ask me why I have to create file Y when I can render to file X itself. I have to do it. So, I'm getting an error :

undefined method `operations' for nil:NilClass

when trying to call file Y. But everything is file when I'm accessing file X. Can someone please explain the root cause. Thankyou!

How is different data shown to different users on the same URL?

I'm currently dealing with a situation where I need to display same URL to two types of users for viewing different data on the URL. Here is the background - Initially we had two different URLs for Metrics of type 1 and Metrics of type 2. So, in order to display which URL to which user we simply had an if condition something like this-

<%= if User1? %>
DISPLAY URL A
<%=end%>
<%= if User2? %>
DISPLAY URL B
<%=end%>

Later situation - For some reason the content(Basically metrics here) from URL B have been moved to URL A now (which is both types of metrics are present in single link here) Problem - Now we want to present only single URL to both types of users 1&2. However, when USER 1 is accessing he should be able to view all types of metrics in the URL. But when USER 2 is viewing the URL he should not view a particular metric (lets say type 2) but should see all the rest. So, in a nut shell we need to provide same URL for both users but they have to view different content and this has to be achieved with a simple IF statement something like -

<%= if User1? %>
<%= if User2? %>
DISPLAY URL A and block the content of metric type 2.
<end>
Display URL A with all metrics
<%=end%>

P.S - we have two types of metrics now in the consolidated link and both of them have different code-files from where they are fetching the code. I'm assuming if we can block accessing a file which has metric type 2 with an if condition then might solve problem. But can someone help me with this please ? Thank you!

My question - Can someone translate this pseudo code to actual code that works? Would be really really helpful.

How to display same URL by hiding a specific data inside URL to two different users

I’m trying to display a particular URL to users which consists of three metrics(dashboards) where they are fetching the code from three separate code-files for each metric.Here we have two types of users - USER1 &USER2.USER2 should not have the access/ should not be able to see a particular metric out of three but still be able to access the same URL to see other two metrics. USER 1 should be able to access the same URL and be able to see all the three metrics. So, let’s assume that particular metric which USER2 is supposed to not see is Analytics_metric from file “Analytics_metric.html.erb”.I want to achieve this by using if statements to validate USER1 & USER 2 from watching the metrics inside same URL for example- URL :https:/example/metrics.

Here is the code which I’m using currently to display the URL link to both USERS (Not performing any operations here) -


<%# if USERS?%>
<%= a_link url:example/metrics do%>
Metrics dashboards //Title of link
<%=end%>

As we can see the current code is accessible by both USER1 & USER 2 in order to display all three metrics when they just click the URL. But we don’t want this to happen as USER2 is also able to see the Analytics_metric which should not be seen.

How to Create table in ruby on rails [closed]

How to create a table like this one in the picture using ruby (html) and also using radio_button ? I have tried in the view to create just a simple table not like this, but also I have searched for it in many questions and did not find a clear answer for it. picture for the table

mercredi 14 septembre 2022

JSON key reducer and formtter in Ruby

I am facing a situation where it seems helpful to have a gem that can format the JSON that comes as a response from any API. For example I may make a call to fetch some data but I don't need all the fields, instead I need to create a new JSON by parsing the original one to only include some fields and also be able to select only some of nested fields from arrays or array of arrays inside that JSON. The result of the reduced JSON can be a JSON that has only one level of nesting. Can you please help me if there is an existing gem in Ruby to do this?

dimanche 11 septembre 2022

Undefined method error in Ruby on rails. However the method doesn't exist at all

I'm getting the following error:

undefined method `posix_group' for ["494149846749", "12"]:Array. 

However I don't have a method named possix_group in my entire code package. But I do have a piece of code

posix_group = application.posix_group

Also some annotations like @possix_group. I can't find a method named with the above to solve the problem.

While working on Ruby on Rails I came across this piece of line. Can someone explain this [closed]

set_name_prod = Rails.configuration.material_set[:general][:prod] % application.client_token Can someone take time in helping me understand please.

Rails Devise failed attempts unlock customer handling

I currently use devise with config.unlock_strategy = :email But I want to change it to none, so the template email is not sent, and I use my own logic. but my question is - how do I know the number of failed attempts is reached? Do I need to constantly check on my own - or is there some function I can implement that is automatically called upon maximum_attempts reached? Thanks

dimanche 4 septembre 2022

Fail to install Gollum on MacOS BigSUr. Gem::Ext::BuildError: ERROR: Failed to build gem native extension

I want to install Gollum in my MacOS Big Sur

I already follow the instruction on Github. My Ruby and gem version is as follows

ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]
gem 3.2.3

When I write sudo bundle install, I found the error message in the log below :

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.1.10
Using racc 1.6.0
Using public_suffix 5.0.0
Using rack 2.2.4
Using regexp_parser 2.5.0
Using childprocess 4.1.0
Using crass 1.0.6
Using execjs 2.8.1
Using ffi 1.15.5
Using json 2.6.2
Using github-markup 4.0.1
Using mime-types 1.25.1
Using rouge 3.30.0
Using unf_ext 0.0.8.2
Using builder 3.2.4
Using bundler 2.2.3
Using matrix 0.4.2
Using mini_mime 1.1.2
Using stringio 3.0.2
Using rb-fsevent 0.11.2
Using ruby2_keywords 0.0.5
Using tilt 2.0.11
Using multi_json 1.15.0
Using therubyrhino_jar 1.7.8
Using useragent 0.16.10
Using webrick 1.7.0
Using metaclass 0.0.4
Using ruby-progressbar 1.11.0
Using power_assert 2.0.1
Using rubyzip 2.3.2
Using websocket 1.2.9
Using shoulda-context 1.2.2
Using i18n 1.12.0
Using tzinfo 2.0.5
Using addressable 2.8.1
Using rack-test 0.6.3
Using gemojione 4.3.3
Using rb-inotify 0.10.1
Using rack-protection 2.2.2
Using nokogiri 1.13.8 (arm64-darwin)
Fetching rugged 1.1.1
Using sprockets 3.7.2
Using unf 0.1.4
Using psych 4.0.4
Using sass-listen 4.0.0
Using mustermann 2.0.2
Using therubyrhino 2.1.2
Using mocha 1.8.0
Using test-unit 3.3.9
Using uglifier 4.2.0
Using rdoc 6.4.0
Using sass 3.7.4
Using sinatra 2.2.2
Using sprockets-helpers 1.4.0
Using minitest 5.16.3
Using ansi 1.5.0
Using rexml 3.2.5
Using mustache 0.99.8
Using activesupport 7.0.3.1
Using twitter-text 1.14.7
Using xpath 3.2.0
Using loofah 2.18.0
Using octicons 12.1.0
Using kramdown 2.4.0
Using mustache-sinatra 1.0.1
Using rss 0.2.9
Using sinatra-contrib 2.2.2
Using minitest-reporters 1.3.8
Using selenium-webdriver 4.4.0
Using capybara 3.37.1
Using kramdown-parser-gfm 1.1.0
Using shoulda-matchers 3.1.3
Using shoulda 3.6.0
Installing rugged 1.1.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/rugged-1.1.1/ext/rugged
/Users/fendy/.rvm/rubies/ruby-3.0.0/bin/ruby -I /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0 -r ./siteconf20220904-7725-ezc495.rb extconf.rb
checking for gmake... yes
checking for cmake... yes
checking for pkg-config... yes
-- The C compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "0.29.2") 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM - Failed
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC - Success
-- Performing Test HAVE_STRUCT_STAT_MTIME_NSEC
-- Performing Test HAVE_STRUCT_STAT_MTIME_NSEC - Failed
-- Performing Test HAVE_STRUCT_STAT_NSEC
-- Performing Test HAVE_STRUCT_STAT_NSEC - Success
-- Performing Test IS_WALL_SUPPORTED
-- Performing Test IS_WALL_SUPPORTED - Success
-- Performing Test IS_WEXTRA_SUPPORTED
-- Performing Test IS_WEXTRA_SUPPORTED - Success
-- Performing Test IS_WDOCUMENTATION_SUPPORTED
-- Performing Test IS_WDOCUMENTATION_SUPPORTED - Success
-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED
-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED - Success
-- Performing Test IS_WNO_MISSING_FIELD_INITIALIZERS_SUPPORTED
-- Performing Test IS_WNO_MISSING_FIELD_INITIALIZERS_SUPPORTED - Success
-- Performing Test IS_WSTRICT_ALIASING_SUPPORTED
-- Performing Test IS_WSTRICT_ALIASING_SUPPORTED - Success
-- Performing Test IS_WSTRICT_PROTOTYPES_SUPPORTED
-- Performing Test IS_WSTRICT_PROTOTYPES_SUPPORTED - Success
-- Performing Test IS_WDECLARATION_AFTER_STATEMENT_SUPPORTED
-- Performing Test IS_WDECLARATION_AFTER_STATEMENT_SUPPORTED - Success
-- Performing Test IS_WSHIFT_COUNT_OVERFLOW_SUPPORTED
-- Performing Test IS_WSHIFT_COUNT_OVERFLOW_SUPPORTED - Success
-- Performing Test IS_WUNUSED_CONST_VARIABLE_SUPPORTED
-- Performing Test IS_WUNUSED_CONST_VARIABLE_SUPPORTED - Success
-- Performing Test IS_WUNUSED_FUNCTION_SUPPORTED
-- Performing Test IS_WUNUSED_FUNCTION_SUPPORTED - Success
-- Performing Test IS_WINT_CONVERSION_SUPPORTED
-- Performing Test IS_WINT_CONVERSION_SUPPORTED - Success
-- Performing Test IS_WFORMAT_SUPPORTED
-- Performing Test IS_WFORMAT_SUPPORTED - Success
-- Performing Test IS_WFORMAT_SECURITY_SUPPORTED
-- Performing Test IS_WFORMAT_SECURITY_SUPPORTED - Success
-- Performing Test IS_WMISSING_DECLARATIONS_SUPPORTED
-- Performing Test IS_WMISSING_DECLARATIONS_SUPPORTED - Success
-- Looking for futimens
-- Looking for futimens - found
-- Checking prototype qsort_r for HAVE_QSORT_R_BSD
-- Checking prototype qsort_r for HAVE_QSORT_R_BSD - True
-- Checking prototype qsort_r for HAVE_QSORT_R_GNU
-- Checking prototype qsort_r for HAVE_QSORT_R_GNU - False
-- Looking for qsort_s
-- Looking for qsort_s - not found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) 
-- Found Security /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Security.framework
-- Looking for SSLCreateContext in /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Security.framework
-- Looking for SSLCreateContext in /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Security.framework - found
-- Found CoreFoundation /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreFoundation.framework
-- Found PCRE: /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libpcre.tbd  
-- Looking for dirent.h
-- Looking for dirent.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for windows.h
-- Looking for windows.h - not found
-- Looking for bcopy
-- Looking for bcopy - found
-- Looking for memmove
-- Looking for memmove - found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for strtoq
-- Looking for strtoq - found
-- Looking for _strtoi64
-- Looking for _strtoi64 - not found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of long long
-- Check size of long long - done
-- Check size of unsigned long long
-- Check size of unsigned long long - done
-- Performing Test IS_WNO_UNUSED_FUNCTION_SUPPORTED
-- Performing Test IS_WNO_UNUSED_FUNCTION_SUPPORTED - Success
-- Performing Test IS_WNO_IMPLICIT_FALLTHROUGH_SUPPORTED
-- Performing Test IS_WNO_IMPLICIT_FALLTHROUGH_SUPPORTED - Success
-- http-parser version 2 was not found or disabled; using bundled 3rd-party sources.
-- Performing Test IS_WIMPLICIT_FALLTHROUGH_1_SUPPORTED
-- Performing Test IS_WIMPLICIT_FALLTHROUGH_1_SUPPORTED - Failed
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libz.tbd (found version "1.2.11") 
-- Checking for module 'libssh2'
--   Package 'libssl', required by 'libssh2', not found
-- LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.
-- Checking for module 'heimdal-gssapi'
--   No package 'heimdal-gssapi' found
-- Could NOT find GSSAPI (missing: GSSAPI_LIBRARIES) 
-- Found GSS.framework /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/GSS.framework
-- Looking for iconv_open
-- Looking for iconv_open - not found
-- Found Iconv: -L/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib -liconv
-- Enabled features:
 * nanoseconds, whether to use sub-second file mtimes and ctimes
 * tracing, tracing support
 * threadsafe, threadsafe support
 * HTTPS, using SecureTransport
 * SHA, using CollisionDetection
 * regex, using bundled PCRE
 * http-parser, http-parser support (bundled)
 * zlib, using system zlib
 * ntlmclient, NTLM authentication support for Unix
 * iconv, iconv encoding conversion support

-- Disabled features:
 * debugpool, debug pool allocator
 * SSH, SSH transport support
 * SPNEGO, SPNEGO authentication support

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/rugged-1.1.1/vendor/libgit2/build
 -- /opt/local/bin/gmake
checking for -lgit2... yes
checking for git2.h... yes
creating Makefile

current directory: /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/rugged-1.1.1/ext/rugged
make "DESTDIR=" clean
/Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': can't find gem make (>= 0.a) with executable make (Gem::GemNotFoundException)
    from /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'
    from /Users/fendy/.rvm/gems/ruby-3.0.0/bin/make:23:in `<main>'

current directory: /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/rugged-1.1.1/ext/rugged
make "DESTDIR="
/Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': can't find gem make (>= 0.a) with executable make (Gem::GemNotFoundException)
    from /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'
    from /Users/fendy/.rvm/gems/ruby-3.0.0/bin/make:23:in `<main>'

make failed, exit code 1

Gem files will remain installed in /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/rugged-1.1.1 for inspection.
Results logged to /Users/fendy/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rugged-1.1.1/gem_make.out

An error occurred while installing rugged (1.1.1), and Bundler cannot continue.
Make sure that `gem install rugged -v '1.1.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  gollum was resolved to 5.3.0, which depends on
    gollum-lib was resolved to 5.2, which depends on
      gollum-rugged_adapter was resolved to 1.1.2, which depends on
        rugged

I already read the stackoverflow topic here but it seems different problem with mine. I think my problem is to find the appropriate gem of ruby which I can not figure it out which one. Therefore I would like to ask this question, perhaps someone here has already encounter and solve similar problem.

Thank you

vendredi 2 septembre 2022

Custom form for active admin is not displaying

I have added a piece of code in my active admin model for input form, but weirdly, it's not getting displayed, instead, it's showing the default form. Neither it's showing any error nor displaying my custom form.

form do |f|
f.inputs do
  f.input :email
  f.input :phone
  f.input :gender
  f.input :birthday
  f.input :password
  f.input :password_confirmation
  f.input :us_citizen
  f.input :invitation_limit
end
f.actions

end

jeudi 1 septembre 2022

ArgumentError: tried to create Proc object without a block

How can I resolve the following error:

$ rails db:migrate
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, 
spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, 
spell_checker)' instead.
rails aborted!
ArgumentError: tried to create Proc object without a block
D:/Projects/lms-2021/config/application.rb:9:in `<top (required)>'
D:/Projects/lms-2021/Rakefile:4:in `require_relative'
D:/Projects/lms-2021/Rakefile:4:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
(See full trace by running task with --trace)

These are the logs after rails db:migrate --trace:

$ rails db:migrate --trace
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
rails aborted!
ArgumentError: tried to create Proc object without a block
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:472:in `new'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:472:in `service_added'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:510:in `<module:Aws>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:18:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `block in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-resources-2.9.24/lib/aws-sdk-resources.rb:1:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `block in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-2.9.24/lib/aws-sdk.rb:1:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:66:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:61:in `each'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:61:in `block in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:50:in `each'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:50:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler.rb:174:in `require'
D:/Projects/lms-2021/config/application.rb:9:in `<top (required)>'
D:/Projects/lms-2021/Rakefile:4:in `require_relative'
D:/Projects/lms-2021/Rakefile:4:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:703:in `raw_load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:104:in `block in load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:103:in `load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:20:in `block in perform'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:18:in `perform'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/command.rb:46:in `invoke'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'

This is the application.rb file where the error is shown:

require 'uri'
require "uri/generic"
require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)


module Ilms
  class Application < Rails::Application    

    config.to_prepare do
      # Load application's model / class decorators
      Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
        Rails.configuration.cache_classes ? require(c) : load(c)
      end

      # Load application's view overrides
      Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
        Rails.configuration.cache_classes ? require(c) : load(c)
      end
    end
    
    config.assets.initialize_on_precompile = false    
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.1
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

  end
end

I am not understanding where is the error and how to fix it. There seems no error in my code. The logs with --trace are showing the error occured in lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:472:in `new' which callback = Proc.new .

  • Database : postgresql
  • gem 'pg' already installed
  • rails v 5.1.7
  • ruby v 3.1.2
  • windows 10 pro
  • git bash terminal

Devise Token Auth customised routes for additonal endpoints

I'm trying to setup custom routes for Devise_Token_Auth for additional endpoints for my User model. Here's my default devise_token_auth routes.

mount_devise_token_auth_for 'User', at: 'auth'

Now, I want to add routes for some endpoints which are defined in UsersControllers. e.g endpoints are with name:

  • signup_email
  • verify_mobile_signin
  • register_sports_complex

which are post requests. How can I define routes for these additional endpoints which are not already defined in Devise_token_auth controllers. My UsersController.rb file is in directory custom_users/users_controller.rb.

Any help is much appreciated.