I want to preview my form content before save, when user click button to preview. Here, below is my create action
def create
@article = Article.new(params[:article])
if params[:preview_button] || !@article.save
render :action => 'new'
else
@article.save
flash[:notice] = "Successfully created Article."
redirect_to article_path(@article)
end
end
And here is my new form
<%= form_for :article, url: articles_path do |f| %>
<% if params[:preview_button] %>
<div id="preview">
preview content...
</div>
<% end %>
<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :text %><br>
<%= f.text_area :text %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
<%= submit_tag 'Preview', :name => 'preview_button' %>
Button when i click preview button nothing happen.Kindly help help me what i should do further.