11

私はややRailsの初心者です。私はソファレストレールアプリを書いているので、このモデルにはアクティブレコードを使用していません。という意味だということだけはわかった

form_for(@model) 

動作しません。form_tag の使用方法を理解しようとしていますが、ほとんどの例には new & create アクションが含まれていません。

これは間違っています:

<h1>New article</h1>

<% form_tag new_article_url(@article), :method => :post do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

<%= link_to 'Back', articles_path %>

Cucumber シナリオを実行すると、次のようになります。

Scenario: Create Valid Article                            # features/article.feature:16
  Given I have no articles                                # features/step_definitions /article_steps.rb:8
  And I am on the list of articles                        # features/step_definitions/webrat_steps.rb:6
/home/deploy/www/www.trackingplace.com/app/ccc/app/views/articles/new.html.erb:3: warning: multiple values for a block parameter (0 for 1)
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/helpers/capture_helper.rb:36
When I follow "New Article"                             # features/step_definitions/webrat_steps.rb:18
  You have a nil object when you didn't expect it!
  The error occurred while evaluating nil.error_messages (ActionView::TemplateError)
  features/article.feature:19:in `When I follow "New Article"'

しかし、私はエラーを理解していないか、それを修正する方法を理解していません。

4

1 に答える 1