redirect - error validations not showing in rails -


i have hit wall in displaying error messages. error validation messages don't show up.

on users show template:

<%= form_for([current_user, @pub_message])  |f| %>   <%= render 'shared/error_messages', object: f.object %>     <%= f.hidden_field :to_id, :value => @user.id %>   <div class="micropost_message_field">     <%= f.text_area :content, placeholder: "any thoughts? questions? comments?", :id => 'public_message_text' %>   </div>   <%= f.submit "post", class: "btn btn-large btn-primary" %> <% end %> 

which goes pub_messages#create

def create     @pub_message = current_user.pub_messages.build     @pub_message.to_id = params[:pub_message][:to_id]     @pub_message.user_id = current_user.id     @pub_message.content = params[:pub_message][:content]     if @pub_message.save         flash[:success ] = "your post has been sent"         unless params[:pub_message][:slug].nil?             redirect_to lesson_path(params[:pub_message][:slug])         else             redirect_to user_path(params[:pub_message][:to_id])         end     else         #redirect_to :controller => :users, :action => :show, :id => params[:pub_message][:to_id]         #redirect_to user_path(params[:pub_message][:to_id])         render 'users/show'     end end 

however wont' display error messages. ive read number of other stackoverflow posts error_messages not survive redirect_to instead have render. however, since render displays view, i'm missing variables. tried copying , pasting user#show action earlier seems bad practice. if did that, ran issue templates missing. seemed have move templates shared folder in order work seems wrong since things specific user.

my error messages being displayed correctly elsewhere cant figure out wrong pub_messages.

i have similar called microposts, , works.

def create     @user = current_user     @micropost = current_user.microposts.build(params[:micropost])     if @micropost.save         flash[:success] = "micropost created!"         redirect_to root_path     else         @feed_items = current_user.feed.paginate(page: params[:page], per_page: 20)         render 'static_pages/home'     end end 

the difference think render has templates needs in shared folder. way work?


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -