2

I have a problem with form_for on Ruby on Rails, using Ruby 2.0 and Rails 4.0.0.

I followed this tutorial, everything went perfect until i added the form_for. When I open the sign up page, it throws:

Completed 500 Internal Server Error in 4ms

ActionView::Template::Error (no implicit conversion of Bignum into String):
    3: 
    4: <div class="row">
    5:   <div class="span6 offset3">
    6:     <%= form_for User.new do |f| %>
    7: 
    8:       <%= f.label :name %>
    9:       <%= f.text_field :name %>
  app/views/users/new.html.erb:6:in `_app_views_users_new_html_erb___700836681490305320_18582480'

This is my app/views/users/new.html.erb

<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<div class="row">
    <div class="span6 offset3">
        <%= form_for(@user) do |f| %>
            <%= f.label :name %>
            <%= f.text_field :name %>
            <%= f.label :email %>
            <%= f.text_field :email %>
            <%= f.label :password %>
            <%= f.password_field :password %>
            <%= f.label :password_confirmation, "Confirmation" %>
            <%= f.password_field :password_confirmation %>
            <%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
        <% end %>
    </div>
</div>
Arman H
  • 5,488
  • 10
  • 51
  • 76
Manuel
  • 21
  • 1
  • This is my app/views/users/new.html.erb <% provide(:title, 'Sign up') %>

    Sign up

    <%= form_for(@user) do |f| %> <%= f.label :name %> <%= f.text_field :name %> <%= f.label :email %> <%= f.text_field :email %> <%= f.label :password %> <%= f.password_field :password %> <%= f.label :password_confirmation, "Confirmation" %> <%= f.password_field :password_confirmation %> <%= f.submit "Create my account", class: "btn btn-large btn-primary" %> <% end %>
    – Manuel Aug 02 '13 at 22:10
  • Can you please edit the original question, add the form, and format it as code so there is syntax highlighting. It is very hard to read the comment. Thanks! – Powers Aug 02 '13 at 22:14

1 Answers1

3

I had a similar problem, and it ended up being related to SSL, and how I had stored the secret token in /initializers/secret_token.rb, since this code gets run prior to generating a form.

Check to see that your secret token is a hex number stored as a string.

should look like

RailsApp::Application.config.secret_key_base = 'abcdef01234567890'

Zackkenyon
  • 352
  • 1
  • 2
  • 18
  • Yupp, that one bit me too. It should also be noted that you can have rails generate a good secret for you with `:$ rake secret` – Sam Figueroa Jan 14 '15 at 14:25
  • it should also be noted that this is not the usual way for ruby to store hex values, and I don't believe it would hurt if rails itself accepted both a hex value and a valid hex valued string. – Zackkenyon Jan 31 '15 at 01:11