Can't convert Symbol to string

Hi there,

I ran into an error I don’t fully understand, and some cursory Googling
didn’t yield any answers (at least none that I understood). I’m creating
a page where users have to verify something by submitting a form. Doing
so inserts a value into their user record. Here’s what I have:

controller:

def profile_link
@current_fb = session[:fbsession].session_uid
@user = User.find(params[:id])
end

profile_link.rhtml:

<%= start_form_tag :controller => ‘users’, :action => ‘update’, :id =>
@user %>
<%= hidden_field “user”, “facebook_id”, @current_fb %>

<%= submit_tag “Link your profile!” %> Cancel

<%= end_form_tag %>

When I go to profile_link, I get this error:

can’t convert Symbol into String

And it points to the hidden field line. What about this line doesn’t
work? The @current_fb variable?

Thanks in advance!

Dave

I found neither ‘can’t convert’ nor ‘can’t convert Symbol to String’
in the source of 1.2.3 rails or ruby 1.8.6. My best guess would be an
empty string.

Michael

On May 28, 6:02 pm, “Dave A.” [email protected]

Thanks! I figured it out. There were like three different things wrong
with what I posted. :slight_smile:

MichaelLatta wrote:

I found neither ‘can’t convert’ nor ‘can’t convert Symbol to String’
in the source of 1.2.3 rails or ruby 1.8.6. My best guess would be an
empty string.

Michael

On May 28, 6:02 pm, “Dave A.” [email protected]

I have habtm relationships as follows…

class Schoolclass < ActiveRecord::Base
has_and_belongs_to_many :students, :join_table =>
:student_schoolclasses
has_and_belongs_to_many :tests, :class_name => :teste, :join_table =>
:test_schoolclasses

end

when I access Schoolclass.find(1).students, its giving all the students
of class, but when I access Schoolclass.find(1).tests, its throwing an
error “can’t convert Symbol into String”.

Please help me.

2009/8/25 Archana T. [email protected]:

I have habtm relationships as follows…

class Schoolclass < ActiveRecord::Base
 has_and_belongs_to_many :students, :join_table =>
:student_schoolclasses
 has_and_belongs_to_many :tests, :class_name => :teste,  :join_table =>

Should that be :class_name => :test rather than :teste?

Colin

From the code you’ve pasted, :class_name => :teste seems to be the
problemFrom
what I know it should be :class => :teste assuming you have all the
spellings correct.

Thanks & Regards,
Dhruva S…

Mike Ditka http://www.brainyquote.com/quotes/authors/m/mike_ditka.html

“If God had wanted man to play soccer, he wouldn’t have given us arms.”

On Tue, Aug 25, 2009 at 3:26 PM, Archana T. <

:class => :teste is giving error Unknown key(s): class,
It should be :class_name => :teste only. I’m sure.

My Two models are teste.rb , schoolclass.rb

i) class Teste < ActiveRecord::Base
set_table_name “tests”
has_and_belongs_to_many :schoolclasses, :join_table =>
:test_schoolclasses, :order=>‘schoolclasses.standard, ASCII(division)
asc’

end

ii) class Schoolclass < ActiveRecord::Base

 has_and_belongs_to_many :students, :join_table =>

:student_schoolclasses
has_and_belongs_to_many :tests, :class_name => :teste, :join_table
=>
:test_schoolclasses

end

What’s the problem here?

2009/8/25 Colin L. [email protected]:

2009/8/25 Archana T. [email protected]:

I have habtm relationships as follows…

class Schoolclass < ActiveRecord::Base
 has_and_belongs_to_many :students, :join_table =>
:student_schoolclasses
 has_and_belongs_to_many :tests, :class_name => :teste,  :join_table =>

Should that be :class_name => :test rather than :teste?

Or even :class => :test

2009/8/25 Archana T. [email protected]:

asc’
:test_schoolclasses
Try :class_name =‘Teste’

Colin

I came had this error and found it was being caused by trying to add a
symbol to a string.

a string"+:a_symbol #=> TypeError: can’t convert Symbol into String

On Aug 25, 2009, at 6:20 AM, Archana T. wrote:

asc’
=>
:test_schoolclasses
:class_name => ‘Teste’

end

What’s the problem here?

When you get an error message about “Can’t convert Symbol to string”
even though there is a Symbol#to_s, perhaps you need to look at using
a String where you presently have a Symbol.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Hi

ruby-1.9.2-p180 > a string"+:a_symbol #=> TypeError: can’t convert
Symbol into String

You cannot concat string to symbol directly.
convert symbol to string and then concat it.

“string”+:sym.to_s

*to_s *is used to convert to string