Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Singularize / Pluralize problem in formtastic breaking on status/statuses. #17

Closed
greggh opened this Issue May 31, 2009 · 0 comments

Comments

Projects
None yet
1 participant

greggh commented May 31, 2009

As per a request by Justin in this thread: http://groups.google.com.au/group/formtastic/t/cfa36ee67d8345b I am creating this issue. This is in rails 2.3.2.

The problem appears to be formtastic somehow coming up with job_statu_id insteda of job_status_id when building.

First up the stacktrace:

ActionView::TemplateError: undefined method `job_statu_id' for #<Job:
0xb6718e6c>
On line #2 of app/views/jobs/_form.html.erb

    1: <% semantic_form_for @job do |form| %>
    2:   <%= form.inputs %>
    3:   <%= render :partial => "shared/formsubmitbutton" %>
    4: <% end %>

    vendor/plugins/formtastic/rails//lib/formtastic.rb:558:in

select_input' vendor/plugins/formtastic/rails//lib/formtastic.rb:884:insend'
vendor/plugins/formtastic/rails//lib/formtastic.rb:884:in
inline_input_for' vendor/plugins/formtastic/rails//lib/formtastic.rb:99:insend'
vendor/plugins/formtastic/rails//lib/formtastic.rb:99:in
input' vendor/plugins/formtastic/rails//lib/formtastic.rb:98:inmap'
vendor/plugins/formtastic/rails//lib/formtastic.rb:98:in
input' vendor/plugins/formtastic/rails//lib/formtastic.rb:247:ininputs'
vendor/plugins/formtastic/rails//lib/formtastic.rb:247:in
map' vendor/plugins/formtastic/rails//lib/formtastic.rb:247:ininputs'
app/views/jobs/_form.html.erb:2
vendor/plugins/formtastic/rails//lib/formtastic.rb:1225:in
semantic_form_for' app/views/jobs/_form.html.erb:1 app/views/jobs/new.html.erb:3 app/controllers/jobs_controller.rb:29:innew'
/test/functional/jobs_controller_test.rb:11:in
test_should_get_new' /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:inrun'
/usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in each' /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:inrun'
/usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in run' /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:ineach'
/usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in run' /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:inold_run_suite'
/opt/rubymine/rb/testing/patch/test/unit/ui/
testrunnermediator.rb:36:in run_suite' /opt/rubymine/rb/testing/patch/test/unit/ui/teamcity/ testrunner.rb:69:instart_mediator'
/opt/rubymine/rb/testing/patch/test/unit/ui/teamcity/
testrunner.rb:57:in start' /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:inrun'
/usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in run' /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:inrun'
/usr/lib/ruby/1.8/test/unit.rb:278
rake (0.8.4) lib/rake/rake_test_loader.rb:5

Next up we have the schema for the two tables:

create_table "job_statuses", :force => true do |t|
  t.integer "lock_version", :default => 0
  t.string "name", :limit => 50, :null => false

  t.timestamps
end


create_table "jobs", :force => true do |t|
  t.integer "lock_version", :default => 0
  t.references :customer, :null => false
  t.references :employee, :null => false
  t.datetime "job_date", :null => false
  t.text "description", :null => false
  t.references :job_status, :null => false
  t.decimal "estimated_time", :precision => 10, :scale => 2, :default => 0.00, :null => false

  t.timestamps
end

Associations:
in the Job model: belongs_to :job_status
in the JobStatus model: has_many :jobs

The view code:
in views/jobs/edit.html.erb:
<%= render :partial => "form" %>

in views/jobs/_form.html.erb

<% semantic_form_for @job do |form| %>
<%= form.inputs %>
<%= render :partial => "shared/formsubmitbutton" %>
<% end %>

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment