On 23 June 2013 05:20, Máté Kaszás <kaszas.m...@chello.hu> wrote: > Hi Guys, > > So basically I want a contact form to appear on all the service pages. > I've already created a contact form for the contact page which works > perfectly using this tutorial: > http://matharvard.ca/posts/2011/aug/22/contact-form-in-rails-3/ > > Now I would like to implement this approach on the service pages, and it > works until I push the Submit button, when I get the following error: > > Processing by ScontactController#create as HTML > > Completed 500 Internal Server Error in 1ms > > NoMethodError (undefined method `each' for nil:NilClass): > app/models/servicemail.rb:13:in `initialize'
That means that at that line of code you are calling 'each' on something that is nil. > app/controllers/scontact_controller.rb:9:in `new' > app/controllers/scontact_controller.rb:9:in `create' > > The parameters are ok. > > Rails seems to complain about the each method in the model: > class Servicemail > > include ActiveModel::Validations > include ActiveModel::Conversion > extend ActiveModel::Naming > > attr_accessor :name, :email, :subject, :body, :szolg > > validates :name, :email, :subject, :body, :presence => true > validates :email, :format => { :with => %r{.+@.+\..+} }, :allow_blank => > true > > def initialize(attributes = {}) > attributes.each do |name, value| Assuming that the above is line 13 then it means that attributes is nil. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsdfNpm3rgWboLsAfeugh5cmk71SntH0yhVhM1g%3DQ2E5g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.