Can't get error messages for model submit to one controller show with another Rails 2.3.2 -


i have read on other people's posts , still can't head wrapped around problem having. thought ask.

i have form gets uploading avatar. form displayed :controller => 'board', :action => 'show'

<% form_tag("avatar/upload", :multipart => true ) %>   <%= error_messages_for :avatar %>   ... 

this works great. problem can't error messages display.

the upload handled :controller => 'avatar', :action => 'upload'

if params_posted?(:avatar)   image = get_image(params)   @board = board.find(session[:board_id])   @avatar = avatar.new(@board.id, image)   if @avatar.save     # ???   end end 

now part have trouble with. know can't redirect_to or lose error_messages_for @avatar , no error messages doing render problem because have routes.

in routes.rb have following:

map.connect 'board/celebrating/:id/:name', :controller => 'board', :action => 'show' 

so want know how display board again located @ :controller => 'board', :action => 'show' , display error messages @avatar?

sorry if seems trivial. me been struggle. thank in advance.

mitchell

you can rendering template instead of redirecting or rendering action. example, if want render boards/show.html.erb on failure, following:

if params_posted?(:avatar)   image = get_image(params)   @board = board.find(session[:board_id])   @avatar = avatar.new(@board.id, image)   if @avatar.save     ...   else     render :template => 'boards/show'   end end 

keep in mind boardscontroller#show action not run, flash messages , instance variables (@avatar, @board) preserved.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -