[Rails] "Cannot convert String to Integer" after using association
Pete Yandell
pete at notahat.com
Mon Apr 17 00:51:20 GMT 2006
Brian,
Can you include the actual code for _entity.rhtml, given that's where
your error is happening?
Cheers,
Pete Yandell
http://9cays.com
On 17/04/2006, at 9:37 AM, Bryan Duxbury wrote:
> So, I've written a partial that does some stuff with a given
> instance of
> my class "entity". Entity is ActiveRecord. I'm able to retrieve all
> sorts of data from an @entity, until I do something like:
>
> <% for @attribute in @entity.attributes %>
> <div id="attribute_<%= @attribute.id %>">
> <%= render(:partial => 'attribute') %>
> </div>
> <% end %>
>
> After which point, any attempt on my part to retrieve data from
> @entity
> ( for instance <%= @entity.id %> results in:
>
> cannot convert String into Integer
>
> The stack trace is:
>
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
> active_record/associations/association_proxy.rb:75:in
> `[]'
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
> active_record/associations/association_proxy.rb:75:in
> `send'
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
> active_record/associations/association_proxy.rb:75:in
> `method_missing'
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
> active_record/associations/has_many_association.rb:90:in
> `method_missing'
> (eval):1:in `id'
> #{RAILS_ROOT}/app/views/main/_entity.rhtml:27
> #{RAILS_ROOT}/app/views/main/index.rhtml:30
> #{RAILS_ROOT}/app/views/main/index.rhtml:29:in `each'
> #{RAILS_ROOT}/app/views/main/index.rhtml:29
>
>
> This is really starting to tick me off. I had a workaround in which I
> retrieved all the important information before I used an association,
> but that won't let me retrieve more than one type of associated
> information.
>
> Help?
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
More information about the Rails
mailing list