> i think that my Form_for is not in correct form because when i
> delete create function from the controller everythings is as
> before and when i changed :vorlesung in Form_for to @vr
> an error occured :

This looks wrong:

  def create
     @vorlesung=Vorlesung.create(params[:vr])

What the hell is :vr?

What version of rails are you using?  In rails 3, you would write:


<%= form_for(@vorlesung) do |v| %>

    Name : <%= v.text_field :name, "Name:" %>    <br>

    Name de Professur : <%= v.text_field :leiter_name, "Leiter name:"
%><br>

    <%= v.submit 'Speicher'%>

<% end %>


===

With that form, rails will create name attributes for your html elements
like this:

    name="vorlesung[name]"
    name="vorlesung[leiter_name]"

You can verify that by doing "View Source' in your browser after the
page loads.  So the name of the form_for() variable, e.g. @vorlesung,
because the first part of the name attribute, and the symbol you
specified for the html element, e.g. :name, becomes the subscript.  As a
result, in your controller you can get a hash of the all the name
attributes and the corresponding values entered into the form, like
this:

@attributes = params[:vorlesung]

which will look something like this:

{ :name => 'Joe', :leiter_name => 'Blow' }


Therefore, in your controller you can do this:

  def create
    @vorlesung =  Vorlesung.new(params[:vorlesung])

    if @vorlesung.save
       ...

  end

-- 
Posted via http://www.ruby-forum.com/.

-- 
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