Skip to content

Commit

Permalink
Fix the questions page and add error message partial (#9036)
Browse files Browse the repository at this point in the history
* added error message partial

* fix legacy question

Co-authored-by: Cess <cessmbuguar@gmail.com>
  • Loading branch information
Manasa2850 and cesswairimu authored Jan 31, 2021
1 parent 286a823 commit 97247e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ def index_shadow

# a form for new questions, at /questions/new
def new
@node = Node.new
@revision = Revision.new
# use another node body as a template
node_id = params[:n].to_i
if node_id && !params[:body] && Node.exists?(node_id)
node = Node.find(node_id)
params[:body] = node.body
@node = Node.find(node_id)
@revision = @node.revision.first
params[:body] = @node.body
end
if current_user.nil?
redirect_to new_user_session_path(return_to: request.path)
Expand Down
11 changes: 5 additions & 6 deletions app/views/editor/question.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@
%>
<div class="card bg-light">
<div class="card-body">
<% if params[:id] %>
<%= form_for :node, :as => :drupal_node, :url => url do |f| %>
<% if f.error_messages != "" %><div class="alert alert-danger"><%= f.error_messages :header_message => "Your note couldn't be saved." %></div><% end %>
<%= form_for :node, :as => :drupal_node, :url => url if params[:id] do |f| %>
<%= render partial: 'layouts/errorMessages', locals: { model: @node } %>

<% end %>

<%= form_for :revision, :as => :revision, :url => url, :html => {:class => "form well legacy-form row"} do |f| %>

<% if f.error_messages != "" %><div class="alert alert-danger"><%= f.error_messages :header_message => "Your note couldn't be saved." %></div><% end %>
<% end %>
<%= render partial: 'layouts/errorMessages', locals: { model: @revision } if @revision.present? %>
<%= render :partial => "editor/main_image" %>

<div class="col-lg-9 order-md-1">
Expand Down Expand Up @@ -120,8 +119,8 @@
<p class="col-md-12">By publishing, you agree to <a target="_blank" href="/licenses">open source your work</a> so that others may use it.</p>
<br />
</div>
<% end %>

<% end %>
</div>
</div>
</div>

0 comments on commit 97247e3

Please sign in to comment.