Comment puis-je utiliser “Form_tag” par opposition à “Form_for” dans ce fichier

Je suis nouveau sur Ruby on Rails et ont été immensément aidé par Michael Hartl de l'excellent livre: Ruby on Rails Tutoriel. J'ai obtenu le Chapitre 8 et je suis maintenant sur les exercices de ce chapitre. Je vais avoir ( je suppose un type de "newbie") problème avec l'exercice 1. Dans cet exercice, il est demandé "1.Refactoriser le signin utiliser le formulaire de form_tag en place de form_for." J'ai essayé de chercher de l'aide dans cette Stackoverflow, Google, Railscast, et beaucoup d'autres "recherches sur le web" depuis deux jours maintenant et je n'arrive pas à trouver l'aide dont j'ai besoin pour répondre à ce problème. Le fichier que je suis en train de la modifier avec form_tag est ci-dessous:

<% provide(:title, "Sign in") %>
<h1>Sign in</h1>

<div class="row">
  <div class="span6 offset3">
    <%= form_for(:session, url: sessions_path) do |f| %>

      <%= f.label :email %>
      <%= f.text_field :email %>

      <%= f.label :password %>
      <%= f.password_field :password %>

      <%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
     <% end %>

    <p>New user? <%= link_to "Sign up now!", signup_path %></p>
  </div>
</div>

Je suis à l'aide de Rails 3.2.3 dans cette application. Quelqu'un peut-il me diriger dans la bonne direction? Quelqu'un peut-il m'aider avec ce problème? Je vous serais très reconnaissant.

C'est l'implémentation qui utilise form_tag:

<% provide(:title, "Sign in") %>
<h1>Sign in</h1>

<div class="row">
  <div class="span6 offset3">
    <%= form_tag( url: sessions_path ) do  %>

      <%= label_tag :email %>
      <%= text_field_tag :email %>

      <%= label_tag :password %>
      <%= password_field_tag :password %>

      <%= submit_tag "Sign in", class: "btn btn-large btn-primary" %>
    <% end %>

    <p>New user? <%= link_to "Sign up now!", signup_path %></p>
  </div>
</div>

Je suis à l'aide de Rspec 2.9.0 et ci-dessous sont la faute de tests:

describe "signin page" do
    before { visit signin_path }

    it { should have_selector('h1',    text: 'Sign in') }
    it { should have_selector('title', text: 'Sign in') }
  end 

et

describe "with invalid information" do
            before { click_button "Sign in" }

            it { should have_selector('title', text: 'Sign in') }
            it { should have_selector('div.alert.alert-error', text: 'Invalid') }

            describe "after visiting another page" do
              before { click_link "Home" }
              it { should_not have_selector('div.alert.alert-error') }
            end
      end

et

describe "with valid information" do
            let(:user) { FactoryGirl.create(:user) }
            before do
              fill_in "Email",    with: user.email
              fill_in "Password", with: user.password
              click_button "Sign in"
            end

            it { should have_selector('title', text: user.name) }
            it { should have_link('Profile', href: user_path(user)) }
            it { should have_link('Sign out', href: signout_path) }
            it { should_not have_link('Sign in', href: signin_path) }

            describe "followed by signout" do
                    before { click_link "Sign out" }
                    it { should have_link('Sign in') }
            end
      end

Voici mon fichier de routes:

SampleApp::Application.routes.draw do
  resources :users
  resources :sessions, only: [:new, :create, :destroy]


  get "users/new"

  root to: 'static_pages#home'

  match '/signup',  to: 'users#new'
  match '/signin',  to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete

  match '/help',    to: 'static_pages#help'
  match '/about',   to: 'static_pages#about'
  match '/contact', to: 'static_pages#contact'
end
InformationsquelleAutor Tim Greider | 2012-05-07