Note that there are some explanatory texts on larger screens.

plurals
  1. POundefined method `latitude=' Geocoder Rails
    primarykey
    data
    text
    <p>I'm trying to get Geocoder working in my app. I am trying to use a user's zip code to geocode their location and I've run into this error upon submitting a new sign-up:</p> <pre><code>NoMethodError in Devise::RegistrationsController#create undefined method `latitude=' </code></pre> <p>I'm using Devise for authentication, here's my sanitation of the <code>:zip</code> attribute in case it's relevant. Also below is my User sign up form.</p> <pre><code>class ApplicationController &lt; ActionController::Base protect_from_forgery before_filter :configure_permitted_parameters, if: :devise_controller? def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:zip, :email, :password, :password_confirmation) } end end </code></pre> <p>Here is my relevant User model:</p> <pre><code>class User &lt; ActiveRecord::Base validates :zip, presence: true geocoded_by :zip after_validation :geocode end </code></pre> <p>My sign-up form:</p> <pre><code>&lt;h2&gt;Sign up&lt;/h2&gt; &lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; registration_path(resource_name)) do |f| %&gt; &lt;%= devise_error_messages! %&gt; &lt;div&gt;&lt;%= f.label :email %&gt; &lt;%= f.email_field :email, :autofocus =&gt; true %&gt;&lt;/div&gt; &lt;div&gt;&lt;%= f.label :zip %&gt; &lt;%= f.text_field :zip %&gt; &lt;/div&gt; &lt;div&gt;&lt;%= f.label :password %&gt; &lt;%= f.password_field :password %&gt;&lt;/div&gt; &lt;div&gt;&lt;%= f.label :password_confirmation %&gt; &lt;%= f.password_field :password_confirmation %&gt;&lt;/div&gt; &lt;div&gt;&lt;%= f.submit "Sign up" %&gt;&lt;/div&gt; &lt;% end %&gt; &lt;%= render "devise/shared/links" %&gt; </code></pre> <p>Any thoughts on why I'm getting this error? Do I need to include a field in my sign-up form for lat and long? Thanks in advance!</p> <p><strong>EDIT</strong></p> <p>Here's the schema for my User table:</p> <pre><code>class DeviseCreateUsers &lt; ActiveRecord::Migration def self.up create_table(:users) do |t| t.integer :zip t.float :latitude t.float :longitude ## Database authenticatable t.string :email, :null =&gt; false, :default =&gt; "" t.string :encrypted_password, :null =&gt; false, :default =&gt; "" ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable t.integer :sign_in_count, :default =&gt; 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip t.string :last_sign_in_ip end end end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload