[rspec-users] form_for problem

Brandon Goodin brandon.goodin at gmail.com
Thu Dec 3 12:09:24 EST 2009


Greetings All,

I have an interesting issue that I can only assume is me doing something
dumb.

======
I have the following route defined
======

map.namespace(:admin) do |admin|
  admin.resources :users
end

======
I have a form:
======

- form_for @user, :url=>admin_user_path do |f|

======
and an rspec
======

require 'spec_helper'

describe "/admin/users/edit.html.haml" do

  it "renders edit admin user form" do
    @user = mock_model(User)#Factory.create(:valid_user)
    assigns[:user] = @user
    render
  end
end

======
it produces the following error when ran
======

ActionView::TemplateError: admin_user_url failed to generate from
{:action=>"show", :controller=>"admin/users"} - you may have ambiguous
routes, or you may need to supply additional parameters for this route.
 content_url has the following required parameters: ["admin", "users", :id]
- are they all satisfied?
On line #1 of app/views/admin/users/edit.html.haml

    1: - form_for @user, :url=>admin_user_path do |f|
    2:   %p

    (eval):16:in `admin_user_path'

========

This form works when I fire up WEBrick and navigate to it manually.

<form action="/admin/users/2" class="edit_user" id="edit_user_2"
method="post">
<div style="margin:0;padding:0;display:inline"><input name="_method"
type="hidden" value="put" />
<input name="authenticity_token" type="hidden"
value="lnRnobSwBwf8lQcPzqE/uxndBzCaSey89ebEe9djFEU=" />
</div>
<p></p>
</form>

========

What am I doing wrong?

Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091203/18c9e732/attachment.html>


More information about the rspec-users mailing list