I'm a bit confused on how this works. My form is sending to a weird location. Here's my situation: I have a model: youtube.rb I have a controller called: youtube_editor_controller.rb In my youtube_editor view, i have new.html.erb, where I'm trying to make a form for the var I created in my youtube_editor_controller.rb: def new @video_new = Youtube.new end SO, I use the form_for @video_new, but when I view the page, the form action="/youtubes". Why is it doing that? Did I define "youtubes" or is it just pluralizing my model name? Where does it decide which controller to go to?
on 2009-04-23 21:29
on 2009-04-23 21:33
On 23 Apr 2009, at 18:29, firstname.lastname@example.org wrote: > > > SO, I use the form_for @video_new, but when I view the page, the form > action="/youtubes". Why is it doing that? Did I define "youtubes" or > is it just pluralizing my model name? Where does it decide which > controller to go to? that comes from your routes. Fred
on 2009-04-23 21:48
OK, I have this in my routes: map.resources :youtube_editor map.resources :youtubes I deleted youtubes and I got an error. (I think "youtube" is my model name, but "youtubes" may be my table name. "youtube_editor" is my controller. How do I get the resource youtube_editor linked to the @video_new variable? (if that's how it works...) THanks!
on 2009-04-23 22:38
On 23 Apr 2009, at 18:47, email@example.com wrote: > you'll make life easier for yourself if you stick to the default (ie the controller for editing instances of Youtube should be youtubes_controller). You should be able to the :controller option to override that if you want. Fred
on 2009-04-23 22:50
So, models and controllers should always have the same name?
on 2009-04-23 23:30
brent wejrowski wrote: > So, models and controllers should always have the same name? Yes. Standard practice has the model called Thing, the controller called ThingsController, and the database table called things. Note that you will not necessarily need all three of those for any given Thing. It is quite common to have models without associated controllers and vice versa. Best, -- Marnen Laibow-Koser http://www.marnen.org firstname.lastname@example.org