Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8621373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:48:22+00:00 2026-06-12T06:48:22+00:00

Right now I’m trying to build an app which has the ability to search

  • 0

Right now I’m trying to build an app which has the ability to search for phone numbers, buy them, and record the transaction to a database.

The way I thought to do it was to have two controllers– (1) the find_numbers controller takes paramaters and searches for numbers. And (2) the phones controller buys the chosen number and saves the parameters to the database.

Here’s a diagram of what I’m trying to do.

http://www.stepanp.com/search-and-buy.jpg

Though I can search for the numbers, and buy the numbers, I can’t seem to save it to the database.

It redirects me and tells me that I did not fill in the proper fields.

This makes me think that the parameters in find_numbers form aren’t being accepted as the parameters for the create action of the phones controller

here’s find_numbers/show

    <%= @numbers.each do |number| %>

        <%= form_tag(:controller => "phones", :action => "create" ) do %>
            <%= hidden_field :original_number, params[:original_number] %>
            <%= hidden_field :name, params[:name] %>
            <%= hidden_field(:twilio_number,  number.phone_number) %>

            <div class="found_list">
                <div class="found_phone_number">
                    <%= label_tag(:number, number.friendly_name) %>
                </div>
                <div class="choose_found_number">
                 <%= submit_tag("Choose This Number", :class => "btn btn-large btn-success") %>
                </div>
            </div>
                <hr>
        <% end %>
    <% end %>

And, here’s the create action of the phones controller

  def create
    @user = current_user
    @phone = @user.phones.build(params[:phone])
    client = Twilio::REST::Client.new(@user.twilio_account_sid, @user.twilio_auth_token)
    number = client.account.incoming_phone_numbers.create(
                   :phone_number => params[:twilio_number])
    if @phone.save && !number.nil?
      flash[:success] = "Phone Number Created!"
      redirect_to user_path
    else
      render new_find_number_path
      flash[:error] = "It looks like there were errors with the submission"
    end
  end

What would I need to edit on the create action, to make it so it takes the parameters that the show action POSTS to it, and than saves it to the database?

I think this might be the culprit :

@phone = @user.phones.build(params[:phone])

Thanks for sticking with me this far! Any guidance would be greatly appreciated

Here’s the debugger information when I hit Phones#create via find_numbers/show

--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
utf8: ✓
authenticity_token: RMvjP9PQt9hVEJE449pMqgqnFcreqvXtmZFEyU+641g=
original_number: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
  '1231231234': ''
name: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
  Example Name: ''
twilio_number: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
  '+18322415354': ''
commit: Choose This Number
action: create
controller: phones

The Phone Model

# == Schema Information
#
# Table name: phones
#
#  id              :integer          not null, primary key
#  name            :string(255)
#  twilio_number   :string(255)
#  original_number :string(255)
#  user_id         :integer
#  created_at      :datetime         not null
#  updated_at      :datetime         not null
#

class Phone < ActiveRecord::Base
      attr_accessible :name, :original_number, :twilio_number
      belongs_to :user

  validates :name, presence: true
  validates :twilio_number, presence: true
  validates :original_number, presence: true
  validates :user_id, presence: true

  default_scope order: 'phones.created_at DESC'

end

http://stepanp.com/search-and-buy-debug.jpg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:48:23+00:00Added an answer on June 12, 2026 at 6:48 am

    Try this

    def create
        @user = current_user
        @phone = @user.phones.new(params[:phone])
        client = Twilio::REST::Client.new(@user.twilio_account_sid, @user.twilio_auth_token)
        number = client.account.incoming_phone_numbers.create(
                       :phone_number => params[:twilio_number])
        if @phone.save && number.present?
          flash[:success] = "Phone Number Created!"
          redirect_to user_path
        else
          render new_find_number_path
          flash[:error] = "It looks like there were errors with the submission"
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I am trying to instantiate the Circle class (which is a subclass
Right now I have some TabItems in my App which are implicitly styled. I
Right now I'm asking the user for two numbers. I'm trying to print the
Right now I am trying to design an Android app where a critical feature
Right now, I've just some code which fetches the picture from the URL directly.
Right now, the label for my Activity has the name of the current Activity.
Right now, I use subprocess to invocate find which does the job fine, but
Right now, I have developed an android app that is available free on the
Right now I detect the credit card type based upon the first four numbers
Right now I have a mysql database with a table userphone(id, phone, type,userid) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.