A Love of Surf | 23 Jul 01:19
Picon

Can someone please help a very eager Rails newbie?


ok, so I am trying to learn the 'c' in crud from a tutorial right
now.  Using the source below, I am loading the action 'new', filling
out a form to create a new record, and submitting the form to save the
record.  The problem comes when I submit the form.  The app generates
an error saying that the method commit= is not defined.  At this
point, I don't know enough about rails to extrapolate meaning from
this weirdness or to know what I should include in this request that'd
help someone to help me.

================================
SOURCE:
================================

CONTROLLER:

class PublicController < ApplicationController

  def album_list
    @page_title = 'railstest/public/album_list (Original)'
    @albums = Album.find_by_sql('SELECT * FROM albums;')
  end

  def alt_album_list
    @page_title = 'railstest/public/alt_album_list'
    release_date = '2003-01-01'
    @albums = Album.find(:all,
      :order => 'title, release_date ASC')
    render(:action => 'album_list')
  end

  def show_album
    @page_title = 'railstest/public/show_album (Inspect Album)'
    @album = Album.find(:first)

  end

  def show
      @album = Album.find(params[:id])
      render(:action => :show_album)
  end

  def create
    @album = Album.new(params)
    if @album.save
#      redirect_to(:action => 'show', :id => @album.id)
      redirect_to(:action => 'alt_album_list')
    else
      render(:action => 'new')
    end
  end

  def new
    @album = Album.new
    @page_title = 'New Model'

  end

end

CREATION FORM PAGE:

<html>
<head>
<title>Rails DB: <%= @page_title %></title>
</head>
<body>

<% form_tag(:action => 'create') do -%>
  Id: <%= text_field(:id, @album.id) %><br />
  Artist: <%= text_field(:artist, @album.artist) %><br />
  Title: <%= text_field(:title, @album.title) %><br />
  Genre: <%= text_field(:genre, @album.genre) %><br />
  Release Date: <%= datetime_select(:release_date,
@album.release_date, :start_year => 1960, :end_year => 2008) %><br />
  <%= submit_tag('Create') %><br />
<% end -%>

<br /><br /><br />

<%= debug(params) %>

</body>
</html>

VIEW ON SUCCESS:

<html>
<head>
<title>Rails DB: <%= @page_title %></title>
</head>
<body>

<% for album in @albums -%>
  <%= link_to(album.artist, :controller => 'public', :action =>
'show', :id => album.id) %> - <%= album.title %> (<%= album.id %>)<br /
>
<% end -%>

</body>
</html>

ON FAIL IT SHOULD GO BACK TO CREATION FORM PAGE

================================
ERROR:
================================

 NoMethodError in PublicController#create

undefined method `commit=' for #<Album:0x6068320>

RAILS_ROOT: C:/www/railstest
Application Trace | Framework Trace | Full Trace

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
attribute_methods.rb:251:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2361:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2361:in `attributes='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2360:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2360:in `attributes='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2130:in `initialize'
app/controllers/public_controller.rb:28:in `new'
app/controllers/public_controller.rb:28:in `create'

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
attribute_methods.rb:251:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2361:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2361:in `attributes='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2360:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2360:in `attributes='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2130:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1162:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1162:in `perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:580:in `call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:573:in `perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
rescue.rb:201:in `perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:13:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
query_cache.rb:8:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:12:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:569:in `process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
session_management.rb:130:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:389:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:149:in `handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:107:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:104:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:104:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:120:in `dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:35:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
rails.rb:76:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
rails.rb:74:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
rails.rb:74:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
159:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
158:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
158:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
268:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
268:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
268:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
configurator.rb:282:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
configurator.rb:281:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
configurator.rb:281:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/bin/mongrel_rails:
128:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
command.rb:212:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/bin/mongrel_rails:
281
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/servers/
mongrel.rb:64
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
script/server:3

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
attribute_methods.rb:251:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2361:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2361:in `attributes='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2360:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2360:in `attributes='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:2130:in `initialize'
app/controllers/public_controller.rb:28:in `new'
app/controllers/public_controller.rb:28:in `create'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1162:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1162:in `perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:580:in `call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:573:in `perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
rescue.rb:201:in `perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:13:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
query_cache.rb:8:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:12:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:569:in `process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
session_management.rb:130:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:389:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:149:in `handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:107:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:104:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:104:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:120:in `dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:35:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
rails.rb:76:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
rails.rb:74:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
rails.rb:74:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
159:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
158:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
158:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
268:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
268:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel.rb:
268:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
configurator.rb:282:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
configurator.rb:281:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
configurator.rb:281:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/bin/mongrel_rails:
128:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/lib/mongrel/
command.rb:212:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-mswin32/bin/mongrel_rails:
281
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/servers/
mongrel.rb:64
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
script/server:3

Request

Parameters:

{"artist"=>["Jack Johnson"],
 "commit"=>"Create",
 "title"=>["Sleep Through the Static"],
 "authenticity_token"=>"ae4530b9c7db12cb6ae7d7326d44b2f7d0bdf3e4",
 "id"=>["2"],
 "genre"=>["Beautiful"],
 "release_date"=>{"(3i)"=>"1",
 "(4i)"=>"00",
 "(5i)"=>"00",
 "(1i)"=>"2008",
 "(2i)"=>"1"}}

Show session dump

---
:csrf_id: 4fe64497155d2f8d5dd1359e937beb49
flash: !map:ActionController::Flash::FlashHash {}

Response

Headers:

{"cookie"=>[],
 "Cache-Control"=>"no-cache"}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane