Reputation:
I have to pass multiple values into a query and execute it. How can I do?
Eg:
values = name.to_s + 'Check'
data = TestController::values.method_name
Outcome: TestController::RailsCheck
How I can get multiple values in values variable?
Upvotes: 0
Views: 41
Reputation: 2399
Not sure what you want to do but there are many different way to do it, either you can create Hashes and use it, or as in your code seem you want to make object and than call its method name. So I am giving you here sample class and with object example you can add it in either concern if you are using it with ActiveRecord or you can add in lib folder if you are using in controllers.
class Solution
attr_accessor :name
def initialize(name)
@name = name
end
def method_name
name.to_s + 'Check'
end
end
values = Solution.new('Rails')
puts values.method_name
Upvotes: 1