mardi 7 avril 2015

ActionView::Template::Error (undefined method `emails_path' for

I am making simple email registration form in rails but I stuck in this error.


I have generate controller Emails and Model Email with only email field in Email Model.


here is my controller with method new



class EmailsController < ApplicationController
def new
@email = Email.new
end
end


below is my view which is very simple



<h2>Register Email</h2>

<% form_for(@email) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>


Now I have defined the routes using rake routes


which was working fine until I added code in controller and html page


In routes.rb I defined path for root as this



root 'emails#new'


and my rake routes looks like this



emails_new GET /emails/new(.:format) emails#new
home_index GET /home/index(.:format) home#index
root GET / emails#new


Now I get this error



ActionView::Template::Error (undefined method `emails_path' for #<#<Class:0x007f25edc36a58>:0x007f25edc4ffa8>):
App 4103 stderr: 1: <h2>Register Email</h2>
App 4103 stderr: 2:
App 4103 stderr: 3: <% form_for(@email) do |f| %>
App 4103 stderr: 4: <div class="field">
App 4103 stderr: 5: <%= f.label :email %><br />
App 4103 stderr: 6: <%= f.text_field :email %>
App 4103 stderr: app/views/emails/new.html.erb:3:in `_app_views_emails_new_html_erb___4438819380742713977_69900439838140'


any help thanks


Aucun commentaire:

Enregistrer un commentaire