I am getting this error from my articles controller:
wrong number of arguments (1 for 2)
|app/controllers/article_controller.rb:38:in `update''
app/controllers/article_controller.rb:38:in `update''|
The controller for the update action looks like this:
def update()
@article = Article.update(@params[''article''])
<<-------- line 38
if @article.update_attributes(@params[''article''])
@article.categories.clear
@article.categories<<@params[''category'']
flash[''notice''] = ''Article was
successfully updated.''
redirect_to :action => ''show'', :id =>
@article.id
else
flash[''notice''] = ''There was a problem
updating your
article. Please try again.''
render_action ''edit''
end
end
These are parameters being sent back from the form:
*Parameters*: {"article"=>{"body"=>"This is a
test.", "title"=>"Wow, the
4th Article", "author"=>"Danielle Ezell"},
"id"=>"6",
"categories"=>["1", "4"]}
Any ideas? BTW, the articles and categories have a habtm to each other.
--
Alex Ezell
On Jun 17, 2005, at 10:50 PM, Alex Ezell wrote:> I am getting this error from my articles controller: > > wrong number of arguments (1 for 2) > > |app/controllers/article_controller.rb:38:in `update'' > app/controllers/article_controller.rb:38:in `update''| > > The controller for the update action looks like this: > def update() > @article = Article.update(@params[''article'']) <<-------- > line 38 > if @article.update_attributes(@params[''article'']) > @article.categories.clear > @article.categories<<@params[''category''] > flash[''notice''] = ''Article was successfully updated.'' > redirect_to :action => ''show'', :id => @article.id > else > flash[''notice''] = ''There was a problem updating your > article. Please try again.'' > render_action ''edit'' > end > end > > These are parameters being sent back from the form: > *Parameters*: {"article"=>{"body"=>"This is a test.", > "title"=>"Wow, the 4th Article", "author"=>"Danielle Ezell"}, > "id"=>"6", "categories"=>["1", "4"]} > > Any ideas? BTW, the articles and categories have a habtm to each > other. > > -- > Alex Ezell > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >I believe you want Article.find(@params[:id]) on line 38. -Justin Palmer ---------------------------------------------- Encytemedia.com Professional User Interface Design
Justin Palmer wrote:> On Jun 17, 2005, at 10:50 PM, Alex Ezell wrote: > >> I am getting this error from my articles controller: >> >> wrong number of arguments (1 for 2) >> >> |app/controllers/article_controller.rb:38:in `update'' >> app/controllers/article_controller.rb:38:in `update''| >> >> The controller for the update action looks like this: >> def update() >> @article = Article.update(@params[''article'']) <<-------- >> line 38 > > > I believe you want Article.find(@params[:id]) on line 38. > -Justin Palmer > > ---------------------------------------------- > Encytemedia.com > Professional User Interface DesignThanks Justin! That was exactly what I needed. Sometimes, you stare at something for so long that you can''t see it. -- Alex Ezell