Hello everybody,
Here you can see my short code:
in routes.rb:
map.resources :users
in users_controller.rb
def new
@user = User.new
end
in views/users/new.html.erb:
<% form_for @user do |f| %>
And that work very well. I would like to update the current route like
this:
in routes.rb:
map.resources :apps do |app|
app.resources :users
end
in users_controller.rb
def new
@user = User.new
@user.app_id = the_current_app.id
end
But after refresh, I got this error:
NoMethodError in Users#new
Showing users/new.html.erb where line #1 raised:
undefined method `users_path’ for #ActionView::Base:0x20c4a34
Extracted source (around line #1):
1: <% form_for @user do |f| %>
Is there a clean way to solve this error? (I believe it’s possible to
add a :url parameter in the form_for tag but I don’t know if it’s the
best way.)
Thanks a lot