Question: I'm trying to build a form which posts data to another controller/action and then redirect back to another page.

My template with the form:

```
<%= form_for @url, :url => { :controller => "url", :action => "create" }, :html => {:method => :post} do |f| %>
    <%= f.text_field :url, :placeholder => "http://" %>
   <%= f.submit "Kürzen", :class => "btn" %>
<% end %>

```

My url\_controller:

```
class UrlController < ApplicationController
  def create
    redirect_to shorturl_path
  end
end

```

My route:

```
Ssurl::Application.routes.draw do
  get 'shorturl' => 'landingpage#shorturl', :as => :shorturl
  post '/url/create' => 'url#create'
  root :to => 'landingpage#index', :as => :landingpage
end

```

When i submit the form, the page reload with the get parameters of the form?
So there are 2 errors:

1. The form uses get instead of post?
2. Redirect doesn't work

What's wrong?

Answer: 
It looks like you're trying to generate a URL in your `form_for` by specifying the controller and the action but you're not mapping this route in your routes.rb.

So you have two options. The first is to 'hardcode' the URL in the `form_for`, like this:

```
<%= form_for @url, :url => "/url/create", :html => {:method => :post} do |f| %>

```

But a much better solution would be to get your routes into RESTful shape.

You could do this:

```
Ssurl::Application.routes.draw do
  get 'shorturl' => 'landingpage#shorturl', :as => :shorturl
  resource :url, :only => [:create]
  root :to => 'landingpage#index', :as => :landingpage
end

```

Which will create a RESTful create route using the POST http method. So your `form_for` would then look like this:

```
<%= form_for @url do |f| %>

```

Much cleaner!
User `url_for` to access the action of different controller- 

```
form_for @url, :url => url_for(:controller => 'url', :action => 'create')

```

**For redirect problem -**

Controllers aren't meant to communicate to each other. If you want to do something after creating a url, make it a method on the model and call it from the UrlController. You could even add an after\_save callback to the model, but be aware that callbacks can lead to mayhem, especially if they're complicated.

Think carefully which method goes on which object. Where does it belong? Controllers should be fairly straight forward: Get a resource and show it (for GET requests), or perform one action and redirect back to a GET page. If the stuff you want to do doesn't belong on the model either, make a service class or a different model.