Ruby on Rails Tuesday, February 1, 2011

I tried to do it by myself, 


I've a model named Entry with a field named type_id (added via migration) and a model named EntryType with a field named description.

class Entry < ActiveRecord::Base
  belongs_to :entry_type
  ...
end
 
class EntryType < ActiveRecord::Base
  has_many :entries
end

I added the following code line to my /_form.erb:

<%= f.select('entry', 'type_id', EntryType.all.collect {|t| [t.description, t.id]}, {:include_blanks => 'None'}) %>

but when I try to load the page I get this exception:

NoMethodError in Entries#new

Showing I:/Labs/RailsProjects/sisingresos/app/views/entries/_form.html.erb where line #18 raised:

 undefined method `merge' for [["Ordinario", 1], ["Especial", 2], ["Concejo Comunal", 3]]:Array

Extracted source (around line #18):

 15:   </div> 16:   <div class="field"> 17:     <%= f.label t('entries.fields.type') %><br /> 18:     <%= f.select('entry', 'type_id', EntryType.all.collect {|t| [t.description, t.id]}, {:include_blanks => 'None'}) %> 19:   </div> 20:   <div class="field"> 21:     <%= f.label t('entries.fields.generalentrydate') %><br /> 

Trace of template inclusion: app/views/entries/new.html.erb

Rails.root: I:/Labs/RailsProjects/sisingresos

Application Trace | Framework Trace | Full Trace
app/views/entries/_form.html.erb:18:in `block in _app_views_entries__form_html_erb__326164559_25362852_503356076' app/views/entries/_form.html.erb:1:in `_app_views_entries__form_html_erb__326164559_25362852_503356076' app/views/entries/new.html.erb:3:in `_app_views_entries_new_html_erb___750658673_25375572__1012098428' app/controllers/entries_controller.rb:23:in `new'

Regards,
--
TSU. Amador Cuenca

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment