Skip to main content

All Questions

Tagged with
0 votes
0 answers
53 views

Search results undefined while loading from controller on Rails view

I am trying to do search functionality for my Rails MVC learning. I am adding title , description and category name as filter columns. And checking each parameter id defined in my model class using ...
Mr.DevEng's user avatar
  • 2,815
0 votes
1 answer
72 views

Rails method parameter call convention problems

I have following method with lots of parameters. I have converted this method from parameter list to Hash to avoid mess with default parameters. def foo_bar(options = {}) Rails.logger.info("...
pkilpo's user avatar
  • 3
-1 votes
2 answers
934 views

Ruby: ArgumentError (wrong number of arguments (given 1, expected 0)) [closed]

I'm clearly fundamentally not understanding how to pass arguments and call methods in Rails. I'm trying to make a test call to stripe with dummy information and I'm getting the subject error when I ...
John Gerard's user avatar
0 votes
1 answer
38 views

Override part of the inherited controller method in Rails

i have a method in the first class class1 def method(param_test) if !organization.empty? organization = test(param_test) end end end Class 2 inherits from Class 1 class2 &...
Davi Luis's user avatar
  • 426
0 votes
2 answers
681 views

Rails best practice for calling a model method from a different controller

I have Model_a, model_a_controller and Model_b. I have a method in model_b that I would like to call in model_a_controller. But I am not sure what the best practice for doing so would be. This is my ...
aj soprano's user avatar
0 votes
1 answer
54 views

Overide method in gem

I am using AwesomeNestedSet and have a place in my app that calls the parent method on a model instance. In some cases, parent returns nil. That's fine but in the cases where it does I need it to ...
rctneil's user avatar
  • 7,210
1 vote
1 answer
138 views

Avoid calling private method from module

Is there any possibility to make private method in module ? I want to prevent to call method from other modules. module A private def name # this method can be used in module B &...
oczek.scala's user avatar
0 votes
1 answer
88 views

showing a default mage on bootstrap if images are not attached

I am in a bootstrap carousel, I want to call a method that will play the images in the carousel IF they are attached and that will play a default image (in the carousel) IF they are not attached. Here ...
user avatar
1 vote
2 answers
648 views

What is the 'self' keyword doing exactly in this Class method?

class Restaurant attr_accessor :average_rating, :city def initialize(city, name) @city = city @name = name @number_of_ratings = 0 @sum_of_ratings = 0 end def rate(new_rate) ...
BuiltByDan's user avatar
0 votes
2 answers
804 views

Rubocop Lint/DuplicateMethods -- which duplicate should I keep?

Rubocop reports: app/models/transformer.rb:8:3: W: Lint/DuplicateMethods: Method Painter#last_color is defined at both app/models/painter.rb:2 and app/models/painter.rb:5. Painter class looks like:...
David Hempy's user avatar
  • 6,139
1 vote
1 answer
280 views

Ruby on rails helper method instance variable

I am following along with Michael Hartl's rails tutorial. I am confused with a portion of the sessions helper module. In the following code can someone please clarify if the current_user in the ...
Ari Ticas's user avatar
2 votes
2 answers
1k views

How to assign multiple attributes at once to an object in Ruby

I have an object Foo and want to assign multiple attributes to it at once, similar to assign_attributes in Rails: class Foo attr_accessor :a, :b, :c end f = Foo.new my_hash = {a: "foo", ...
max's user avatar
  • 167
0 votes
1 answer
84 views

Dynamic method creation from block parameter

I have the following structure of data array_of_hashes = [{"key"=>"2020-10-01", "foo"=>"100", "bar"=>38, "baz"=>19, &...
dehelden's user avatar
1 vote
3 answers
6k views

Rspec how to test a Sidekiq job?

I have a Sidekiq job that looks something like this: class Arbitrary::MarkSold < ApplicationJob def perform(item_id) return if Rails.env.test? item = Item.find_by(item_id) item.sold = ...
Panpaper's user avatar
  • 541
0 votes
0 answers
129 views

Why is the delete post button not working correctly in a blog application built on rails using scaffold?

for some reason the delete post button is not deleting but taking you to the article page, the alert message is not even triggered. It's as if the read button were identical to the delete button. I ...
Antony M. Luz's user avatar

15 30 50 per page
1
2 3 4 5
52