How to pass user attributes to action mailer - ruby-on-rails

I'm trying to build a mailer into my rails app, which allows visitors to submit feedback through a form which is sent to a third party email address. This object is defined as a 'comment'.
As part of the app, a user must be authenticated in order to access this form and send me a 'comment', and as such I'm trying to pass the attributes from the User model to the comment form and mailer.
I'm getting the following error, code to follow:
undefined method `user_full_name' for nil:NilClass
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
Name: <%= #comment.user_full_name %>
Email: <%= #comment.user_email %>
routes.rb
Sampleapp::Application.routes.draw do
devise_for :users, :controllers => { :registrations => "registrations" }
devise_scope :user do
get 'register', to: 'devise/registrations#new'
get 'login', to: 'devise/sessions#new', as: :login
get 'logout', to: 'devise/sessions#destroy', as: :logout
end
resources :users do
member do
get 'edit_profile'
end
resources :messages, only: [:new, :create]
end
resources :messages do
get :sent, action: "outbox", type: "sent", on: :collection
end
resources :comments, only: [:new, :create]
root to: "home#index"
match '/about', to: 'static_pages#about', via: 'get'
match '/help', to: 'static_pages#help', via: 'get'
match '/privacy_policy', to: 'static_pages#privacy_policy', via: 'get'
match '/terms_and_conditions', to: 'static_pages#terms_and_conditions', via: 'get'
end
CommentsController.rb
class CommentsController < ApplicationController
def new
#comment = Comment.new
end
def create
#comment = Comment.new comment_params
if #comment.valid?
CommentsMailer.new_comment(#user).deliver
flash[:success] = "We have receieved your message!"
redirect_to users_path
else
flash.now.alert = "Please fill in all fields."
render :new
end
end
private
def comment_params
params.require(:comment).permit(:subject, :feedback)
end
end
comment.rb
class Comment < ActiveRecord::Base
belongs_to :user, inverse_of: :comments
attr_accessible :subject, :feedback
validates :subject, presence: true
validates :feedback, presence: true
end
new.html.erb
<div class="comment">
<div class="container">
<%= form_for #comment do |f| %>
<%= f.hidden_field :user_full_name, value: current_user.full_name %>
<%= f.hidden_field :user_email, value: current_user.email %>
<%= f.label :subject %>
<%= f.text_field :subject %>
<%= f.label :feedback %>
<%= f.text_area :feedback %>
<%= f.submit "Send", class: "btn btn-inverse" %>
<% end %>
</div>
</div>
comments.mailer.rb
class CommentsMailer < ActionMailer::Base
default to: "myemail#gmail.com"
default from: "#comment.user.email"
def new_comment(user)
#user = user
mail(subject: '#comment.subject')
end
end
new_comment.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
Name: <%= #comment.user.full_name %>
Email: <%= #comment.user.email %>
Subject: <%= #comment.subject %>
Feedback: <%= #comment.body %>
</body>
</html>

You are not passing #comment object to CommentsMailer and trying to access it there.
Instead of passing User object (#user) to CommentsMailer in create action CommentsMailer.new_comment(#user).deliver. Try pass #comment object.
Try make following changes in your create action :
def create
#comment = Comment.new comment_params
if #comment.valid?
CommentsMailer.new_comment(#comment).deliver
flash[:success] = "We have receieved your message!"
redirect_to users_path
else
flash.now.alert = "Please fill in all fields."
render :new
end
end
comments.mailer.rb
class CommentsMailer < ActionMailer::Base
default to: "myemail#gmail.com"
default from: "#comment.user.email"
def new_comment(comment)
#comment = comment
#user = #comment.user
mail(subject: '#comment.subject')
end
end

Related

no route matches leading to ActionController UrlGenerationError

I have created a ToDoList based off Hartl's tutorial, and following a video and worded tutorial to add a tagging system. I have followed till Section 10, where they asked me to modify my new.html.erb file to the code as shown on the source. To improvise for structural differences in code, I would edit some other files, like in this case, my micropost_form partial instead. Occasionally, I alternated between the code in the video and code in the worded tutorial because some of them would produce error messages or would not produce the required functionality. Here are the files that I think are involved in this question.
_micropost_form.html.erb(The filling up form that would be displayed on the user's home page)
<%= simple_form_for #micropost do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<div class="field">
<%= f.label :content %><br />
<%= f.text_area :content, placeholder: "Add new task..." %>
</div>
<div class="field">
<%= f.label :tag_list, "Tags (separated by commas)" %><br />
<%= f.text_field :tag_list %>
</div>
<%= f.submit "Add Task", class: "btn btn-primary" %>
<% end %>
micropost.html.erb(for showing the individual micro posts)
<li id="micropost-<%= micropost.id %>">
<%= link_to gravatar_for(micropost.user, size: 50), micropost.user %>
<span class="user"><%= link_to micropost.user.name, user_path(micropost.user) %></span>
<span class="content"><%= micropost.content %></span>
<p><small>Tags: <%= raw micropost.tags.map(&:name).map { |t| link_to t, tag_path(t) }.join(', ') %></small</p>
<span class="timestamp">
Posted <%= time_ago_in_words(micropost.created_at) %> ago.
<% if current_user?(micropost.user) %>
<%= link_to "Done", micropost_path(micropost), method: :delete, data: { confirm: "Keep up the good work!" } %>
<% end %>
</span>
</li>
routes.rb
Rails.application.routes.draw do
resources :users
resources :microposts
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
post '/signup', to: 'users#create'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
get '/users/admin', to: 'users#admin'
get 'tags/:tag', to: 'microposts#index', as: :tag
root 'static_pages#home'
end
micropost_controller
class MicropostsController < ApplicationController
before_action :logged_in_user, only: [:create, :destroy]
before_action :correct_user, only: :destroy
def index
params[:tag] ? #microposts = Micropost.tagged_with(params[:tag]) : #microposts = Micropost.all
end
def show
#micropost = Micropost.find(params[:id])
end
def create
#micropost = current_user.microposts.build(micropost_params)
if #micropost.save
flash[:success] = "Micropost created!"
redirect_to root_url
else
#feed_items = []
render 'static_pages/home'
end
end
def destroy
#micropost.destroy
flash[:success] = "You have deleted a task!"
redirect_to request.referrer || root_url
end
private
def micropost_params
params.require(:micropost).permit(:content, :tag_list, :tag,
{tag_ids: [] }, :tag_ids)
end
def correct_user
#micropost = current_user.microposts.find_by(id: params[:id])
redirect_to root_url if #micropost.nil?
end
end
Micropost model
class Micropost < ApplicationRecord
belongs_to :user
has_many :taggings
has_many :tags, through: :taggings
default_scope -> { order(created_at: :desc) }
validates :user_id, presence: true
validates :content, presence: true, length: {maximum: 140 }
attr_accessor :tag_list
def self.tagged_with(name)
Tag.find_by!(name: name).microposts
end
def self.tag_counts
Tag.select('tags.*, count(taggings.tag_id) as count')
.joins(:taggings).group('taggings.tag_id')
end
def tag_list
tags.map(&:name).join(', ')
end
def tag_list=(names)
self.tags = names.split(',').map do |n|
Tag.where(name: n.strip).first_or_create!
end
end
end
Tag model
class Tag < ApplicationRecord
attr_accessor :name
has_many :taggings
has_many :microposts, through: :taggings
end
static_pages controller
class StaticPagesController < ApplicationController
def home
if logged_in?
#micropost = current_user.microposts.build
#feed_items = current_user.feed.paginate(page: params[:page])
end
end
def help
end
def about
end
def contact
end
end
feed.html.erb
<% if #feed_items.any? %>
<ol class="microposts">
<%= render #feed_items %>
</ol>
<%= will_paginate #feed_items %>
<% end %>
I got the following error
ActionController::UrlGenerationError in StaticPages#home
No route matches {:action=>"index", :controller=>"microposts", :tag=>nil}, missing required keys: [:tag]
app/views/microposts/_micropost.html.erb:5:in `block in _app_views_microposts__micropost_html_erb___3891111682689684005_70324923859580'
app/views/microposts/_micropost.html.erb:5:in `map'
app/views/microposts/_micropost.html.erb:5:in `_app_views_microposts__micropost_html_erb___3891111682689684005_70324923859580'
app/views/shared/_feed.html.erb:3:in `_app_views_shared__feed_html_erb__3168328449514417483_70324923896060'
app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__3511776991923566869_70324898321240'
Can anyone suggest what might be wrong here? Please let me know if more information is needed.
Update: I have implemented some of the changes provided by the answer below, but still has not understood why :tag is not detected, and why the code in red is actually highlighted.
ActionController::UrlGenerationError in StaticPages#home
No route matches {:action=>"index", :controller=>"microposts", :tag=>nil}, missing required keys: [:tag]
The problem is you don't have an index route for your microposts.
Rails.application.routes.draw do
root 'static_pages#home'
get '/readme', to: 'static_pages#readme'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
post '/signup', to: 'users#create'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
get '/users/admin', to: 'users#admin'
resources :users
resources :microposts, only: [:create, :destroy] #Here's the problem
get 'tags/:tag', to: 'microposts#index', as: :tag
end
change to:
resources :microposts, only: [:index, :create, :destroy]
EDIT:
Another problem is
if logged_in?
#micropost = current_user.microposts.build #this just returns a new 1
#feed_items = current_user.feed.paginate(page: params[:page])
end
You probably want something like:
if logged_in?
#microposts = current_user.microposts
#feed_items = Micropost.all.paginate(page: params[:page])
end
This will give you all the user's microposts. Then you iterate through them in your views.
I actually found the cause of the problem to be quite simple. After running rails console, it seems like my db:seed wasn't even raked properly, causing my tags to have nil names and causing me to be unable to find the route. Looking further into Rails console is adding nil instead of values to solve my seed adding problem, I realised I have added attr_accessor, forgetting that normal attributes should be added via the command line into the Migration instead of writing into the Model directly. Removing it according to the post updates my database and the code works.

Ruby Couldn't find ServiceOrder with 'id'=

I'm setting up a in-app notification to show all the notifications that the user has however I am getting an can't find ID error. I am following this guide here https://www.youtube.com/watch?v=KOs8f8TnwZs.
I want to give notifications every time a Service Order gets a new Request associated with it.
Do you know what could be causing this?
I have tried going into my routes and adding something like this:
resources :service_orders do
resources :requests
end
But it didnt work, and it just made the requests route not work.
The code that I newly added is:
(#service_order.users.uniq - [current_user]).each do |user|
Notification.create(recipient: user, actor: current_user, action: "posted", notifiable: #request)
end
And thats whats causing the error, #service_order isn't being found for some weird reason.
My Request Controller is:
class RequestsController < ApplicationController
before_action :set_request, only: [:show, :edit, :update, :destroy]
before_action :old_request, only: [:show, :index, :update]
before_action :set_so
def index
if logged_in?(:site_admin)
#request = Request.all
elsif logged_in?(:itp_user)
#request = Request.pending.requests_by current_user
else
#request = Request.pending.so_user_request current_user.service_orders
end
end
def new
#request = Request.new
end
def create
#request = current_user.requests.new(request_params)
authorize #request
respond_to do |format|
if #request.save
(#service_order.users.uniq - [current_user]).each do |user|
Notification.create(recipient: user, actor: current_user, action: "posted", notifiable: #request)
end
format.html { redirect_to #service_order, notice: 'Your request has been sent' }
else
format.html { redirect_to #request, :flash => { :error => #request.errors.full_messages.join(', ') } }
end
end
end
def show
authorize #request
end
def edit
authorize #request
end
def update
authorize #request
if #request.update(request_params)
redirect_to requests_path, notice: 'Your request was created successfully'
else
render :edit
end
end
def destroy
authorize #request
#request.destroy
redirect_to requests_path, notice: 'Your request was deleted successfully'
end
private
def request_params
params.require(:request).permit(:available_date,
:message,
:charge_range,
:status,
:heading,
:service_order_id,
:user_id
)
end
def set_request
#request = Request.find(params[:id])
end
def old_request
Request.where('created_at <= :fifteen_days', fifteen_days: Time.now - 15.days).where(status: "pending").destroy_all
end
def set_so
#service_order = ServiceOrder.find(params[:service_order_id])
end
end
My routes.rb:
Rails.application.routes.draw do
resources :request_logs
namespace :admin do
resources :users
resources :issue_types
resources :requests
resources :service_orders
root to: "users#index"
end
resources :conversations do
resources :messages
end
resources :requests
devise_for :users, path: '', path_names: { sign_in: 'login', sign_out: 'logout', sign_up: 'register' }
resources :service_orders, except: [:show] do
member do
get :toggle_status
end
end
get 'user-landing', to: 'user_landing#index'
get 'service_order/:id', to: 'service_orders#show', as: 'service_order_show'
get 'contact', to: 'pages#contact'
root to: 'pages#home'
end
Request Form View:
<%= form_for :request, url: requests_path do |f| %>
<% if #request.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#request.errors.count, "error") %> prohibited this request from being sent:</h2>
<ul>
<% #request.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-group">
<h4>Subject:</h4>
<em><%= f.text_area :heading, class: "form-control" %></em>
</div>
<div class="form-group">
<h4>Message:</h4>
<em><%= f.text_area :message, class: "form-control" %></em>
</div>
<div class="form-group">
<h4>Issue Charge Range:</h4>
<em><%= f.number_field :charge_range, class: "form-control" %></em>
</div>
<div class="form-group">
<h4>Soonest Available Date:</h4>
<em><%= f.date_field :available_date, class: "form-control" %></em>
</div>
<%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.hidden_field :service_order_id, :value => #service_orders.id %>
<div>
<%= f.submit 'Send Service Request', class: 'btn btn-primary btn-block' %>
</div>
<% end %>
To route to nested resources you should pass an array.
form_for( [#service_order, #request])
redirect_to([#service_order, #request])
# ... etc
This is equivalent to calling service_order_requests_path(service_order_id: #service_order.to_param). You can also use the shallow: true option to avoid nesting the member routes.

ActionController::UrlGenerationError in UsersController#create ... missing required keys: [:id], possible unmatched constraints: [:locale]

I had some nice form that had been working well, but once I add some translations, I get following error:
Here are some important files I have:
routes.rb
Rails.application.routes.draw do
scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
get 'sessions/new'
get 'teamscrs/index'
get 'teamscrs/new'
get 'teamscrs/show'
get 'profile', to: 'teamscrs#show'
get 'login', to: 'sessions#new'
get 'users', to: 'users#new'
delete 'logout', to: 'sessions#destroy'
post 'login', to: 'sessions#create'
resources :users
root 'teamscrs#index'
end
match '*path', to: redirect("/#{I18n.default_locale}/%{path}"), :via => [:get, :post]
match '', to: redirect("/#{I18n.default_locale}"), :via => [:get, :post]
#get '/teamscrs' => 'teamscrs#home'
end
users_controller.rb
class UsersController < ApplicationController
def index
end
def show
#user = User.find(params[:id])
end
def new
#user= User.new
end
def create
#user = User.new(user_params)
if #user.save
flash[:success] = t(".sukces")
redirect_to #user
else
flash.now[:danger] = t(".fail")
render 'new'
end
end
private
def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation)
end
end
application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_locale
helper_method :current_user, :logged_in?
def current_user
#current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def logged_in?
!!current_user
end
def must_login
if !logged_in?
flash[:danger] = t(".mustlogin")
redirect_to login_path
end
end
private
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_option(options = {})
{locale: I18n.locale}
end
end
users/new.html.erb
...
<%= form_with scope: :user, url: users_path, local: true do |form| %>
<div class="form-group">
<%= form.label(:name,t('.username'))%>
<%= form.text_field :name, class: 'form-control' %>
</div>
<div class="form-group">
<%= form.label(:email,t('.email'))%>
<%= form.text_field :email, class: 'form-control' %>
</div>
<div class="form-group">
<%= form.label(:password_digest,t('.pass'))%>
<%= form.password_field :password, class: 'form-control' %>
</div>
<div class="form-group">
<%= form.label(:password2, t('.passc'))%>
<%= form.password_field :password_confirmation, class: 'form-control' %>
</div>
<%= form.submit t('.join'), class: 'btn btn-success' %>
<% end %>
...
users/show.html.erb
<p>
<strong>Użytkownik:</strong>
<%= #user.name %>
</p>
<p>
<strong>email:</strong>
<%= #user.email %>
</p>
config/environment.rb
...
Rails.application.configure do |variable|
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**/*.{rb,yml}').to_s]
I18n.available_locales = [:en, :pl]
I18n.default_locale = :pl
end
...
I spent whole day reading stackoverflow, I18n guides and watching youtube videos. I'm just a beginner. Please support.
I solved it by changing:
redirect_to #user
to:
redirect_to controller: 'users', action: 'show', id: #user.id
after I read that cause of implementing default_url_options, I have to explicitly let know Rails to pass the id
In the users_controller.rb, there is one update method defined where redirect_to #user. This is in fact which is redirecting to some URL. But this error says this #user is no URL matching against this.
Solution:
The best way to write routes is to run rails routes. From there copy the path for user#index and paste in the arguments of redirect_to.
it may be like
redirect_to user_path
or
redirect_to users_path
or
redirect_to user_index_path

receiving email to my gmail account using actionmailer

Please forgive the newbie question. I'm building a form that has a contact us page, in which a user should be able to fill out a form (user_full_name, user_email, subject, message), which when submitted should be sent as an email to my gmail address. I'm currently getting the following error when I try to access the view with the form on it.
undefined method `feedbacks_path' for #<#:0x007f8fefecd020>
below is my code, does anyone know what I'm doing wrong here? If possible I'd rather change the routes than add a url to the form. Also, want to use a 'match' in the routes to have the url path be 'localhost/contact' instead of 'localhost/feedback'. Does anyone have any ideas?
routes.rb
Sample::Application.routes.draw do
resources :feedback, only: [:new, :create]
root to: "home#index"
match '/about', to: 'static_pages#about', via: 'get'
match '/help', to: 'static_pages#help', via: 'get'
match '/privacy_policy', to: 'static_pages#privacy_policy', via: 'get'
match '/terms_and_conditions', to: 'static_pages#terms_and_conditions', via: 'get'
end
Feedback_Controller.rb
class FeedbackController < ApplicationController
def new
#feedback = Feedback.new
end
def create
#feedback = Feedback.new(params[:feedback])
if #feedback.valid?
FeedbackMailer.new_feedback(#feedback).deliver
flash[:success] = "We have receieved your message!"
redirect_to users_path
else
flash.now.alert = "Please fill in all fields."
render :new
end
end
end
Feedback.rb
class Feedback < ActiveRecord::Base
def self.columns() #columns ||= []; end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
column :user_full_name, :string
column :user_email, :string
column :subject, :text
column :body, :text
belongs_to :user
end
view/feedback.new.html.erb
<div class="feedback">
<div class="container">
<%= form_for #feedback do |f| %>
<%= f.hidden_field :user_full_name %>
<%= f.hidden_field :user_email %>
<%= f.label :subject %>
<%= f.text_field :subject %>
<%= f.label :feedback %>
<%= f.text_area :body %>
<%= f.submit "Send", class: "btn btn-inverse" %>
<% end %>
</div>
</div>
feedback_mailer
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
Name: <%= #feedback.user_full_name %>
Email: <%= #feedback.user_email %>
Subject: <%= #feedback.subject %>
Comments/Question: <%= #feedback.body %>
</body>
</html>
feedback_mailer.rb
class FeedbackMailer < ActionMailer::Base
default to: "railstraining09#gmail.com"
def new_feedback(feedback)
#feedback = feedback
mail(from: #user.email, subject: 'feedback.subject')
end
end
If you are in developement you could add in app/config/environments/development.rb
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
# Gmail SMTP server setup
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:enable_starttls_auto => true,
:port => 587,
:authentication => :plain,
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD']
}
and give it a try.
You can create instead a file mail.rb in config/environments/ or if you want to use a specific email account for each environment than you will need to write in each 'environments' file (production.rb; test.rb, development.rb) your ActionMailer::Base.smtp_settings { options .... }
P.S. I would suggest you to use mandrill/sendgrid etc instead video

Virtual Attributes: No route matches {:controller=>"phone", :action=>"new"}

I have a controller "find_numbers", which I'm using to submit a form to the Twilio API. Before it submits though, I'd like to validate against two form fields, which aren't in the data model for this controller. The fields are :name, and :original_number
So, in my find_numbers model, I added attr_accessor :name, attr_accessor :originial number to run a validates command under it.
After doing that and submitting the form as invalid, I get the error :
Routing Error
No route matches {:controller=>"phone", :action=>"new"}
Try running rake routes for more information on available routes.
I'm not sure why it says there's no roots, but I'm not sure why it's accessing that anyways. I want it to POST to find_numbers
The find_numbers/new template
<%= form_tag("/find_numbers", :method => "post", :id => "new_user" ) do %>
<%= render 'shared/error_messages' %>
<%= label_tag(:name, "What Are You Tracking?") %>
<%= text_field_tag(:name) %>
<%= label_tag(:original_number, "Your Orginal Number") %>
<%= text_field_tag(:original_number) %>
<%= label_tag(:in_postal_code, "Near US postal code (e.g. 94117):") %>
<%= text_field_tag(:in_postal_code) %>
<%= label_tag(:near_number, "Near this other number (e.g. +4156562345)") %>
<%= text_field_tag(:near_number) %>
<%= label_tag(:contains, "Matching this pattern (e.g. 415***EPIC):") %>
<%= text_field_tag(:contains) %>
<%= submit_tag("Search", :class => "btn btn-large btn-primary") %>
<% end %>
here's my find_number model
class FindNumber < ActiveRecord::Base
attr_accessor :name
attr_accessor :original_number
validates :name, presence: true
validates :original_number, presence: true
end
Here's my Find_number controller
class FindNumbersController < ApplicationController
def new
#user = current_user
end
def create
#user = current_user
client = Twilio::REST::Client.new(#user.twilio_account_sid, #user.twilio_auth_token)
search_params = {}
%w[in_postal_code near_number contains].each do |p|
search_params[p] = params[p] unless params[p].nil? || params[p].empty?
end
local_numbers = client.account.available_phone_numbers.get('US').local
#numbers = local_numbers.list(search_params)
unless #numbers.empty?
render 'find_numbers/show'
else
flash.now[:error] = "Sorry, We Couldn't Find Any Numbers That Matched Your Search! Maybe Something Simpler?"
render 'find_numbers/new'
end
end
def show
end
end
Any thoughts on accomplishing this would be greatly appreciated!
Edit
Routes.rb file
Dct::Application.routes.draw do
resources :users
resources :sessions, only: [:new, :create, :destroy]
resources :phones, only: [:new, :create, :destroy]
resources :find_numbers, only: [:new, :create, :destroy]
match '/find_numbers', to: 'find_numbers#new'
match '/signup', to: 'users#new'
match '/login', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
root to: 'static_pages#home'
match '/product_demo', to: 'static_pages#product_demo'
match '/pricing', to: 'plans#index'
match '/contact', to: 'static_pages#contact'
Edit
Here is the server log, of what happened when I hit submit
http://stepanp.com/railserror.jpg
Also, here's the find_numbers/show view
From what you've posted, the only other thing that looks suspicious to me is that you presumably have a PhonesController (plural) since you've declared resources :phones, but the routing error seems to occur because it is looking for a PhoneController (singular).

Resources