On 2 April 2010 21:21, WSzP <[email protected]> wrote:
> Thanks a lot Colin, that was my problem.
>
> From documentation I managed to make a working form_for:
>
> <% form_for :student, @student, :url => { :action => "create" }, :html
> => { :method => :post, :id => "beiratkozok" }   do |f| %>
>
> This works, but I don't understand why do I need the :student in the
> front. What does it do?

It is in the docs, the :student says that the object being displayed
and submitted is of type student, the @student is the variable
containing the student.  In fact since these are the same word you do
not need both, either :student or @student will work I think, though
using @student is more usual I think.  Having both allows the class
name and variable to be different.

I don't know why you have the html options they should not be needed.

I also don't understand why this is going to the beiratkozas
controller, I would have expected it to go to the students controller.
 I would have expected you to put  :url => { :controller =>
'beiratkozas', :action => "create" } to send it to that controller.
Check the html of the page (View, Page Source or similar in browser).

By the way it may be a good idea to put your comments inline with the
previous posts as it is then easier to follow the thread.

Colin

>
> On Apr 2, 11:18 pm, Colin Law <[email protected]> wrote:
>> On 2 April 2010 21:00, WSzP <[email protected]> wrote:
>>
>> > You got me wrong. I can't put the create method in the student
>> > controller.
>> > The question if, how could I use the create method from the
>> > BeiratkozasController class, while the model is NOT Beiratkozas, but
>> > Student.
>>
>> Have a look at the docs for form_for, you will see it has a url
>> parameter which will allow you to specify the controller and action
>> that you wish to be performed on the submit.
>>
>> Colin
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to