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 417795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:36:55+00:00 2026-05-12T18:36:55+00:00

I haven’t used rails since version 1.2 or so and a few things have

  • 0

I haven’t used rails since version 1.2 or so and a few things have changed. I have an issue where I am trying to save an empty model to get validation errors on attributes using :validates_presence_of and instead I am getting the error ‘can’t convert HashWithIndifferentAccess into String’. I will attempt to simplify my code to get the point across as tersely as possible…

my model:

class Project < ActiveRecord::Base

    validates_presence_of :title, :description
    validates_uniqueness_of :title

    has_one :address

    accepts_nested_attributes_for :address, :allow_destroy => true
end

Child model:

class Address < ActiveRecord::Base
    validates_presence_of :title, :street
    belongs_to :project
end

controller:

class ProjectsController < ApplicationController
    def create
        @project = Project.new(params[:project])
        if @project.save
            flash[:notice] = @project.title + ' successfully created'
            redirect_to projects_path
        else
            render :action => 'new'
        end
    end
end

view:

<%= error_messages_for 'project' %>
<% form_for @project do |f| %>
<table width="100%" cellpadding="3" cellspacing="0">
    <tr>
        <td class="adminlabel">
            <label for="Title">Title</label>
        </td>
        <td class="adminbody">
            <%= f.text_field :title %>
        </td>
    </tr>   
    .....
    <% f.fields_for :address do |address| %>
    ....

This code adds and updates just fine as long as I fill in all the required fields, if I leave any blank I get the error mentioned above, not the most graceful way of alerting users there is an issue 😉

Request params:
{“commit”=>”Save”,
“project”=>{“title”=>””,
“notes”=>””,
“description”=>””,
“address_attributes”=>{“city”=>””,
“zip”=>””,
“title”=>””,
“country”=>””,
“suite”=>””,
“street”=>””,
“state”=>””}},
“authenticity_token”=>”iNPQZrf/oBv22vaI0toTGhknwx0aAU3BSvnIh6qgYQ8=”}

I have been searching for days and am at my wits end, if anyone can shed a little light on this for me I would greatly appreciate it.

Thanks in advance!

Brendan

PS – the stack trace as requested:

.../app/controllers/projects_controller.rb:27:in `+'  
.../app/controllers/projects_controller.rb:27:in `create'  
../actionpack-2.3.4/lib/action_controller/base.rb:1331:in `send'  
../actionpack-2.3.4/lib/action_controller/base.rb:1331:in `perform_action_without_filters'  
../actionpack-2.3.4/lib/action_controller/filters.rb:617:in `call_filters'  
../actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'  
../actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'  
../activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'  
../activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:10:in `realtime'  
../activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'  
../actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'  
../actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'  
../actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action'  
../actionpack-2.3.4/lib/action_controller/base.rb:532:in `send'  
../actionpack-2.3.4/lib/action_controller/base.rb:532:in `process_without_filters'  
../actionpack-2.3.4/lib/action_controller/filters.rb:606:in `process'  
../actionpack-2.3.4/lib/action_controller/base.rb:391:in `process'  
../actionpack-2.3.4/lib/action_controller/base.rb:386:in `call'  
../actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call'  
../actionpack-2.3.4/lib/action_controller/dispatcher.rb:87:in `dispatch'  
../actionpack-2.3.4/lib/action_controller/dispatcher.rb:121:in `_call'  
../actionpack-2.3.4/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'   
../activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'  
../activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'  
../activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'  
..activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache'   
../activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call'  
../activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'  
../rack-1.0.1/lib/rack/head.rb:9:in `call'  
../rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'  
../actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call'  
../actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call'  
../actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'  
../rack-1.0.1/lib/rack/lock.rb:11:in `call'  
../rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'  
../rack-1.0.1/lib/rack/lock.rb:11:in `call'  
../actionpack-2.3.4/lib/action_controller/dispatcher.rb:114:in `call'  
../actionpack-2.3.4/lib/action_controller/reloader.rb:34:in `run'  
../actionpack-2.3.4/lib/action_controller/dispatcher.rb:108:in `call'  
../rails-2.3.4/lib/rails/rack/static.rb:31:in `call'  
../rack-1.0.1/lib/rack/urlmap.rb:46:in `call'  
../rack-1.0.1/lib/rack/urlmap.rb:40:in `each'  
../rack-1.0.1/lib/rack/urlmap.rb:40:in `call'  
../rails-2.3.4/lib/rails/rack/log_tailer.rb:17:in `call'  
../rack-1.0.1/lib/rack/content_length.rb:13:in `call'  
../rack-1.0.1/lib/rack/chunked.rb:15:in `call'  
../rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process'
..... etc.

A bit lengthy, sorry 😉

  • 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-05-12T18:36:56+00:00Added an answer on May 12, 2026 at 6:36 pm

    Try adding

    @project.address.build
    

    to your controller. You need to instantiate the address object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Haven't done serious JavaScript since 90s, so looks like a couple of things changed.
I haven't worked with SQL Reporting much, however I have been trying to get
Haven't done as much of Javascript as I should have done. I am trying
haven't used regex replaces much and am not sure if how I have done
I haven't used the implements keyword before, and I've been trying to use it
Haven't done ASP.NET development since VS 2003, so I'd like to save some time
I haven't used C++ since college. Even though I've wanted to I haven't needed
I haven't touched Java since using JBuilder in the late 90's while at University,
I have just tried to save a simple *.rtf file with some websites and
I haven't seen this question anywhere else, I hope someone can help. I have

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.