Forum: Ruby on Rails Good code?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
1a9637acaccba514bf6c2cecf80c3f16?d=identicon&s=25 LeonB (Guest)
on 2007-03-11 23:51
(Received via mailing list)

Could you look at some code I created? I don't know if it's good... or
if it could be better.
Especially the controller. I couldn't find a way to let the
declaration_payers be automatically saved.

  def create
    @declaration =[:declaration])

      @users = User.find(:all)
      render :action => 'new'
      return false

    @declarations_payers = params[:declarations_payers]
    @additional_persons = params[:additional_persons]

    #If there are payers, add them
    if @declarations_payers
      @declarations_payers.each_value { |user_id|

        #Add new object
        @declarations_payer =

        #Set user_id variable (from post)
        @declarations_payer.user_id = user_id

        #Add aditional persons (from post)
        @declarations_payer.additional_persons =

        #Add the object to the declaration object
        @declaration.declarations_payers << @declarations_payer

    flash[:notice] = 'Declaration was successfully created.'
    redirect_to :action => 'list'


<%= error_messages_for 'declaration' %>

<p><label for="declaration_amount">Amount</label><br/>
<%= text_field 'declaration', 'amount'  %></p>

<p><label for="declaration_description">Description</label><br/>
<%= text_field 'declaration', 'description'  %></p>

<% unless @users.nil? %>
  <% for user in @users %>
    <label for ="<%= 'user_ids['']' %>"><%=
user.fullname %></label>

    <%= check_box_tag 'declarations_payers['']',, @declaration.users.include?(user) %>
    <%= text_field_tag 'additional_persons['']',
@declaration_payers[], 'size' => 1 %>

    additionele personen
    <br />
  <% end %>
<% end %>


Thanks in advance!
This topic is locked and can not be replied to.