super noob looking for help

1 view
Skip to first unread message

Brian

unread,
Nov 11, 2009, 1:07:01 PM11/11/09
to Ruby on Rails: Talk
Hello all,
I've just started to play around on Ruby and have read some tutorials,
books, and Why's guide. I do understand syntax of coding, or at least
that within the controller, but I have limited web programming
experience, so the view is giving me some problems. So here is the
issue,

I have a database of wines, that i'd like to be able to select by the
producer, and then those the associated wines. I thought this would
work, but I keep getting the 'Couldn't find Wine with ID=Show' error.
Any help and or pointers on this would be great. Thanks a ton!

from view:
<% form_for @wines, :url => { :action => 'Show' } do |f| %>

Producer: <%= collection_select(:wine,:desc,@wines,:id,:desc,
options ={:prompt => "Select a producer"}) %>

<%= submit_tag 'Submit' %>
<% end %>

from controller:
def show
@wine = Wine.find(params[:desc])

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @wine }
end
end

Robert Walker

unread,
Nov 11, 2009, 4:06:16 PM11/11/09
to rubyonra...@googlegroups.com
Brian wrote:
> Hello all,
> I've just started to play around on Ruby and have read some tutorials,
> books, and Why's guide. I do understand syntax of coding, or at least
> that within the controller, but I have limited web programming
> experience, so the view is giving me some problems. So here is the
> issue,
>
> I have a database of wines, that i'd like to be able to select by the
> producer, and then those the associated wines. I thought this would
> work, but I keep getting the 'Couldn't find Wine with ID=Show' error.
> Any help and or pointers on this would be great. Thanks a ton!
>
> from view:
> <% form_for @wines, :url => { :action => 'Show' } do |f| %>

<% form_for @wines, :url => { :action => 'show' } do |f| %>
The action name is 'show' not 'Show'

The 'show' action is for displaying the details of one item, yet you
have @wines (a collection) in your form_for.

<% form_for @wine do |f| %>

This syntax would take care of everything for showing the detail view
via the 'show' action.

In your case it sounds like you might be trying to make a search form.
If that's the case you probably shouldn't be using form_for anyway, but
rather form_tag.

Have you read though the Rails Guide on form helpers?

http://guides.rubyonrails.org/form_helpers.html
--
Posted via http://www.ruby-forum.com/.

Reply all
Reply to author
Forward
0 new messages