how to solve a TypeError error in rails 4 in the form?

vidur punj

I have a form to create vehicals and define the route corresponding to it, But it consistently gives a TypeError error, I think I am doing it wrong, please correct following is the code:

<%= form_for @vehical, url_for(:action => :create, :controller => 'vehicals') do |vehical| %>
<div>
<%= vehical.label 'house power'%>
  <%= vehical.text_field 'horse_power'%>
</div>
    <div>
      <%= vehical.label 'brand' %>
      <%= vehical.text_field 'brand' %>
    </div>
    <div>
      <%= vehical.label 'model' %>
      <%= vehical.text_field 'model' %>
    </div>

    <%= vehical.submit 'create' %>
<% end %>

routes for it:

 match '/vehicals/create', :to => 'vehicals#create', :as => 'vehicals_create', :via => :post

Error:

ActionView::Template::Error (no implicit conversion of Symbol into Integer):
    1: 
    2: <%= form_for @vehical, url_for(:action => :create, :controller => 'vehicals') do |vehical| %>
    3: <div>
    4: <%= vehical.label 'house power'%>
    5:   <%= vehical.text_field 'horse_power'%>

thanks in advance

NM Pennypacker

You're passing a symbol for the action value. You need a string:

url_for(action: 'create', controller: 'vehicals')

You could also do this, but you may have to tweak the route helper if you don't have that route set up:

form_for @vehical, create_vehicle_path, method: :post

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to solve argument error in Rails?

From Dev

How to solve nil:NilClass errror in Rails 4?

From Dev

How to solve an error 500 in heroku/rails?

From Dev

rails 4 views form syntax error

From Dev

How to solve "TypeError: tuple indices must be integers or slices" error in Python?

From Dev

How to render a form partial in Rails 4?

From Dev

how to use search form in rails 4

From Dev

Rails 4: How to use form_for and partials

From Dev

How to solve undefined method `to_key' error with simple_form

From Dev

Wordpress form submission is shows error. how to solve that?

From Dev

popup validation error msgs showing in main form not in popup how to solve it

From Dev

How to show an error outside of a form in Rails

From Dev

How to solve this error on Rails: "Couldn't digest ActiveSupport::SafeBuffer"

From Dev

Rails form_for Error | How to Bind Nested ActiveRecord Object to Form

From Dev

Cannot redirect to nil! (Error) - Rails 4 Nested Form

From Dev

Cannot redirect to nil! (Error) - Rails 4 Nested Form

From Dev

Nested Form in rails 4

From Dev

Rails 4: How to display fields with error in red?

From Dev

Rails nested form error

From Dev

NoClassDefFound Error, how to solve it?

From Dev

How to solve this compiler error

From Dev

How to solve the error: MethodNotAllowedHttpException

From Dev

How to solve this compile error?

From Dev

How to solve BackgroundUploadAsync error?

From Dev

how to solve oop error

From Dev

What is error? and how to solve

From Dev

How to solve this error in Swift?

From Dev

Error in this query : how to solve it ?

From Dev

How to solve following Error?