Okay I figured out my error.
I needed to specify my form_for like:
- form_for [:admin, @user] do |f|
This is obviously cleaner. It is strange that a running rails app would
accept this while rspec rendered view would not. Anyway, I''m glad that
rspec
didn''t accept this since the way i''m using it now is cleaner.
Thanks,
Brandon
On Thu, Dec 3, 2009 at 11:09 AM, Brandon Goodin <brandon.goodin at
gmail.com>wrote:
> 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/7ec3dd5f/attachment.html>