# How to bind controller and model with different names?

**URL:** <https://www.ruby-forum.com/t/how-to-bind-controller-and-model-with-different-names/175521>\
**Category:** Rails\
**Created:** [September 15, 2009, 6:09am UTC](https://www.ruby-forum.com/t/how-to-bind-controller-and-model-with-different-names/175521 "2009-09-15T06:09:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d9b06d/32.png) [@anton](https://www.ruby-forum.com/u/anton)\
**Post date:** [September 15, 2009, 6:09am UTC](https://www.ruby-forum.com/t/how-to-bind-controller-and-model-with-different-names/175521/1 "2009-09-15T06:09:41Z")

</div>

I’m quite new in ruby.I’m doing simple guestbook. There are feedback  
controller and message model with a scaffolding. I made scaffolding for  
“message” model for example reasons, but when I send some data via  
feedback/index it redirects me to the messages controller’s “create”  
action.

1. Can you show my mistakes and edit some code for clear work with one  
controller.
2. I want to make form\_for function in the partial shorter

here is a feedback controller

```auto
class FeedbackController < ApplicationController
layout 'application'

  def index
      @message = Message.new(params[:id])
      @messages = Message.all

  end

  def show
    @message = Message.find(params[:id])
  end

  def new
    @message = Message.new
  end

  def edit
    @message = Message.find(params[:id])
  end

  def create
    @message = Message.create(params[:message])

      if @message.save
        flash[:notice] = 'Message was successfully created.'

########### I'm sure that problem somewhere here, but I don't know which
string should replace that #########
        redirect_to(@message)

      else
        render :action => "new"

      end
  end

  def update
    @message = Message.find(params[:id])

    respond_to do |format|
      if @message.update_attributes(params[:message])
        flash[:notice] = 'Message was successfully updated.'
        redirect_to(@message)

      else
        render :action => "edit"

      end
    end
  end

  def destroy
    @message = Message.find(params[:id])
    @message.destroy

    respond_to do |format|
      redirect_to(messages_url)

    end
  end
end

```

Here is form partial, which render by application layout.(i want to make  
form\_for shorter and working without 1st argument “:feedback”)

```auto
 <% form_for(:feedback, @message, :method => 'post', :url => {:action =>
'create', :controller => 'feedback'}, :html => {:class =>
'mycleancssform', :id =>'stylized'}) do |f| %>
<%= f.error_messages %>

  <p>
    <%= f.label :message, 'Message' %><br />
    <%= f.text_area (:message, :cols => 53, :rows =>5) %>
  </p>

  <p>

    <%= f.label :firstname, 'Name' %><br />
    <span class="small">min 2 chars</span>
    <%= f.text_field :firstname %>
  </p>

  <p>
    <%= f.label :secondname, 'SEcondname' %><br />
    <span class="small">min 2 chars</span>
    <%= f.text_field :secondname %>
  </p>

  <p>
    <%= f.label :email, 'Email' %><br />
    <span class="small"></span>
    <%= f.text_field :email%>
  </p>

  <p>
    <%= f.label :site, 'Site' %><br />
    <span class="small"></span>
    <%= f.text_field :site %>
  </p>

  <p>
    <%= f.submit 'Submit' %>
  </p>
  <div class="spacer"></div>
<% end %>

```
