Understanding Standard Method Utilization within a Controller Class

Asked 2 years ago, Updated 2 years ago, 36 views

Nice to meet you.I'm a beginner at ruby.
I am trying to create a web system using ruby on rails.
There was an error that could not be resolved, so I would like to ask you a question.


in the controller class you created
String type string retrieved from DB using ransack I want to split using split method, but I can't do it well.

The error message is as follows:

 undefined local variable or method `"' for #
<HogeController:0x007f9529648cf8>

The source code is as follows:

def index
  @q = Hoge.search (params[:q])
  @[email protected](distinct:true)
  @hoges.each do|a|
  str=a.hogestr.to_s.split(",")
  end
end

Thank you for your cooperation.

ruby-on-rails ruby

2022-09-30 19:44

1 Answers

This is because the ", " double quotation marks are not ASCII ".
You can erase ", " and re-enter ", ".


2022-09-30 19:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.