This project is archived and is in readonly mode.
Deprecation problem with Errors#invalid?(attribute)
Reported by Diego Plentz | September 30th, 2010 @ 06:29 PM
It happens just with the "id" attribute. If I comment it out, it renders correctly
NoMethodError in Territories#show
Showing /xpto/app/views/territories/_form.html.erb where line #32 raised:
undefined method `invalid?' for {:id=>[]}:ActiveModel::Errors
Extracted source (around line #32):
29:
30: <div class="three-column">
31: <%= f.label :id %>
32: <%= f.text_field :id, :class => "txt" %>
33: </div>
34:
35: <div class="three-column">
PS: using Rails 3, it's just give me a warning: DEPRECATION WARNING: Errors#invalid?(attribute) has been deprecated, use Errors#[attribute].any? instead. (called from block in app_views_regionsform_html_erb2157815937372262069_2170992780_2129561860386323192 at /xpto/app/views/regions/_form.html.erb:32)
Comments and changes to this ticket
-
David Trasbo October 9th, 2010 @ 04:14 PM
- State changed from new to invalid
- Importance changed from to Low
Unable to reproduce on edge Rails:
$ script/rails g controller territories new ... $ script/rails g model territory ... $ rake db:migrate ...
app/views/territories/new.html.erb
:<%= form_for @territory do |f| %> <%= f.label :id %> <%= f.text_field :id %> <% end %>
app/controllers/territories_controller.rb
class TerritoriesController < ApplicationController def new @territory = Territory.new end end
routes.rb
:Ticket5745::Application.routes.draw do resources :territories end
A request to
http://localhost:3000/territories/new
renders correctly with no error messages:$ script/rails s => Booting WEBrick => Rails 3.1.0.beta application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2010-10-09 17:06:23] INFO WEBrick 1.3.1 [2010-10-09 17:06:23] INFO ruby 1.9.2 (2010-08-18) [x86_64-darwin10.4.0] [2010-10-09 17:06:23] INFO WEBrick::HTTPServer#start: pid=14814 port=3000 Started GET "/territories/new" for 127.0.0.1 at 2010-10-09 17:07:22 +0200 Processing by TerritoriesController#new as HTML Rendered territories/new.html.erb within layouts/application (7.2ms) Completed 200 OK in 19ms (Views: 10.4ms | ActiveRecord: 0.0ms)
Besides: Making the
id
column a user input is, mildly speaking, an extremely bad idea, and you should expect to encounter problems. -
Diego Plentz October 30th, 2010 @ 08:10 PM
David, you're right. These messages are being displayed because of a gem I'm using (delocalize_it). Sorry for the inconvenience.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>