On 2 April 2010 22:10, WSzP <c...@ctdd.ro> wrote:
> Thanks a lot Colin,
>
> First of all, I'm using Rails 2.3.5. and Ruby 1.8.7.
> The generated HTML looks like this: <form method="post"
> id="beiratkozok" action="/beiratkozas">
> The option suggested by you: <% form_for :student, @student, :url =>
> {:controller => 'beiratkozas', :action => "create" }, :html =>
> { :method => :post, :id => "beiratkozok" }   do |f| %> gives the very
> same result, so somehow the form_for assumes that controller is
> 'beiratkozas'. Maybe because the path is: Views/beiratkozas/
> new.html.erb to the view that contains the form_for.

Well obviously if it is a beiratkozas view it will default to sending
it to that controller.  I thought the whole point of the question was
that you wanted to send it to a different controller.  I see now that
that you thought that the fact that it was a Student that it was
manipulating would make it send it to that controller.  That is not
the case.  There is no explicit link between a model and a controller
as far as rails is concerned.  Often a controller does manage a model
of the same name but this is not necessary (as you are finding
yourself).  A controller can manipulate models of a different name, or
several different model classes, or no model at all.  Rails does not
care.

>
> And works, since I have:
>
>  map.connect 'beiratkozok', :controller => 'beiratkozas', :action =>
> 'new'
>  map.connect 'hallgato/:id', :controller => 'beiratkozas', :action =>
> 'show'
>  map.connect 'beiratkozas', :controller => 'beiratkozas', :action =>
> 'create'
>
> I know that map.resources :beiratkozas would be a more Rails like
> approach, but it's more human readable for Hungarians if I use
> meaningful Hungarian words.
>
> The html is added since I need the ID for CSS, and I wanted a
> meaningful word as ID, since it makes CSS easier to read. On the other
> hand :method => :post was added since I saw something like that
> somewhere, and it made sense, since I want to use the POST verb in
> this case. Right?

The submit for a form_for will default to POST, but it does no harm to
include it explicitly

Colin

>
> Peter
>
> P.S.: What do you mean putting my comments inline with the previous
> post? I'm simply hitting reply.
>
>
>
> --
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to