Jump to content

The ultimate community for Ruby on Rails developers.


Accepting parameters from a ruby on rails form

  • Please log in to reply
2 replies to this topic

#1 brep



  • Members
  • 2 posts

Posted 11 August 2014 - 01:08 PM

I am trying to send a field from one form to another form, but I keep receiving a undefined method `[]' for nil:NilClass
<%= form_tag(assets_new_path, method: "submit") do %>
    <%= text_field(:asset, :type, size: 20, class: 'form-control') %>
    <%= submit_tag("+", :class => 'btn btn-default') %>
<% end %>
def new
    @asset = Asset.new
    @type = params[:asset][:type]
Note: I have an object defined with the name of Asset (thus the Asset.new).
Thanks in advance.
Also, the receiving form hasn't been fully programmed yet (specifically the field that will display the submitted value has not been programmed into the view)

#2 Javix



  • Members
  • 6 posts

Posted 11 August 2014 - 01:59 PM

Check your


 for available routes, - I think the right one would be new_asset_path and not assets_new_path as you indicated.

You can display all the available routes by running 

rake routes

 in your terminal after navigating (cd path/to/to/your_project).

#3 brep



  • Members
  • 2 posts

Posted 11 August 2014 - 02:03 PM

You are correct in that it used to be new_assets_path but it is now assets_new_path. I double checked with the command you gave and assets_new_path is still correct.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users