Problem with submit button

Hi,

I wanted to create some static pages using rails and used
rails g controller Staticpages main movie song book
Which has created a controller file “static_pages_controller.erb” and
view files under /views/static_pages/main.html.erb etc

I have created a form using form_for on my main page which has a drop
down menu for selecting one of “movie, song, book” and a submit button
using
<%= form_for :mode do |f| %>


<%= f.label :mode %>

<%= f.select :mode, [‘Please select one’, ‘Movie’, ‘Book’,
‘Song’] %>


<%= f.submit “Submit” %>

<% end %>

My controller file looks like this
class StaticPagesController < ApplicationController
def main

end
def movie
end

end

A click on submit on my main page generates 'No route matches POST
“/static_pages/main” . Do i have to create a func for post? If so since
the static pages class is same for the remaining movie,book, song how do
i handle submits from other pages?

Also how do i retrieve the values of form_for in the controller?

routes.rb have only these

get “staticpages/main”
get “staticpages/movie”
get “staticpages/book”

How do i add a route to post method?

Check Rails Routing from the Outside In — Ruby on Rails Guides

You’ll find everything you need to understand how to configure your
routes.
Le 22 juin 2012 21:24, “cyber c.” [email protected] a crit :

Sorry didn’t finished my previous message I’m on my phone.

First of all, read Getting Started with Rails — Ruby on Rails Guides

You’ll understand how to start and you’ll understand what you need to do
in
your controller and your routes.rb.
Le 22 juin 2012 23:05, “Arnaud Augier” [email protected] a crit
:

u need to do this form_for(:mode, :url => {:action => “action_name”,
:controller => “controller_name”})
and in the routes file, u need to add
post “static_pages/main” “contoller_name#action_name”

On Sat, Jun 23, 2012 at 4:32 AM, cyber c. [email protected] wrote:

You received this message because you are subscribed to the Google G.
“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.


Thanks,
Aash

On 23 June 2012 00:02, cyber c. [email protected] wrote:

I can specify the controller using
:url => {:action => ‘XYZ’}
But since I don’t have ( nor need) a model file for the form , so what
should i write here “?”
<%= form_for (?) do |f| %>

If you have not got an object to populate the form then you can use
form_tag instead.

Colin

I can specify the controller using
:url => {:action => ‘XYZ’}
But since I don’t have ( nor need) a model file for the form , so what
should i write here “?”
<%= form_for (?) do |f| %>