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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jul-22 23:27 UTC
Re: Can someone please help a very eager Rails newbie?
On Jul 23, 12:19 am, A Love of Surf <wetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.The short version is that there are parameters that are submitted that don''t correspond to model attributes (eg the name of the button you clicked), so when you give Artists.new your params hash there are some keys it doesn''t know what to do with.> Id: <%= text_field(:id, @album.id) %><br />You don''t need an edit field for id.> Artist: <%= text_field(:artist, @album.artist) %><br />You''ve got the wrong pattern here. You should be doing text_field ''album'', ''artist'' (and similarly for the other ones) This tells rails ''I''m editing an album, and right now i''m looking at the artist attribute. This also makes what the user types appear as params[:album][:artist], so instead of doing Album.new params you do Album.new params[:album] and since params[:album only contains what you put there you won''t get the error message you got. Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A Love of Surf
2008-Jul-22 23:39 UTC
Re: Can someone please help a very eager Rails newbie?
alright! thanks so much for the speedy and helpful answer. the only thing that is more fun than ruby/rails is how awesome the community is =] On Jul 22, 4:27 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 23, 12:19 am, A Love of Surf <wetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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. > > The short version is that there are parameters that are submitted that > don''t correspond to model attributes (eg the name of the button you > clicked), so when you give Artists.new your params hash there are some > keys it doesn''t know what to do with. > > > Id: <%= text_field(:id, @album.id) %><br /> > > You don''t need an edit field for id. > > > Artist: <%= text_field(:artist, @album.artist) %><br /> > > You''ve got the wrong pattern here. You should be doing > text_field ''album'', ''artist'' > (and similarly for the other ones) > This tells rails ''I''m editing an album, and right now i''m looking at > the artist attribute. > This also makes what the user types appear as params[:album][:artist], > so instead of doing > Album.new params > you do > Album.new params[:album] > and since params[:album only contains what you put there you won''t get > the error message you got. > Fred--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A Love of Surf wrote:> def create > @album = Album.new(params)Until you learn to use form_for, or Hash#block, you must break out all the arguments to .new: @album = Album.new(:artist => params[:artist], :title => params[:title], :etc => params[:etc]) Also, next time don''t worry about pasting the entire stack trace; it just fills up the servers, and we honestly won''t read a line of it! -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A Love of Surf
2008-Jul-23 01:14 UTC
Re: Can someone please help a very eager Rails newbie?
ok, i''m sorry about putting that huge text in my post. but, i dont know what you mean about paste...i typed that On Jul 22, 6:09 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> A Love of Surf wrote: > > > def create > > @album = Album.new(params) > > Until you learn to use form_for, or Hash#block, you must break out all the > arguments to .new: > > @album = Album.new(:artist => params[:artist], > :title => params[:title], > :etc => params[:etc]) > > Also, next time don''t worry about pasting the entire stack trace; it just fills > up the servers, and we honestly won''t read a line of it! > > -- > Phlip--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---