Hello, i have a problem, had a table called news and other called
news_images,
the first é for save news and other for save url for images associated
with news.
Make migrations for each table manual and db:migrate after that i run
scaffold for news, and generate model for news_image… put has_many
and belongs_to in file_column on news_image model and ok… when i
try access page for new News i get this error:
ActionController::RoutingError in News#new
news_url failed to generate from
{:action=>“show”, :controller=>“news”} - you may have ambiguous
routes, or you may need to supply additional parameters for this
route. content_url has the following required parameters:
[“news”, :id] - are they all satisfied?
news_url failed to generate from
{:action=>“show”, :controller=>“news”} - you may have ambiguous
routes, or you may need to supply additional parameters for this
route. content_url has the following required parameters:
[“news”, :id] - are they all satisfied?
The word news is uncountable, so you have to specify a
:singular option with map.resources.
Actually the problem is not that @news is not defined in the edit
action
(it might be an additional problem)
The way I see it, he :singular option is only used to create
the the url-generation methods for the resource (e.g.
edit_news_instance_path, etc.)
This option however is not used by the form_for @news call to deduct
the name
of the url-generation-method. It just gets the singular class name of
the News class
from the inflections, hence instead of edit_news_instance_path,
edit_news_path
is called, which, of course, does not exist.
A workaround might be specifying the :url option in form_for, although
I’ve had
trouble with this, too, at least when using namespaced resources.