Reputation:
When I click the submit button, I am rendering with json in controller.
My json is {notes: array[1], array[2]}
. Now I am rendering view.html.erb file
.
I want to show the values in notes like <%= notes %>
in this file, how to display it ?
Upvotes: 0
Views: 397
Reputation: 40780
sounds like you are confusing JSON requests with HTML request.
The incoming request should be a HTML
controller
# GET /the_controller/view
# not /the_controller/view.json <- wrong
def view
@notes = array
end
view.html.erb
<%= @notes %>
see @rishabh0211 answer for better presentation
if indeed you intend this to be a json request, through som ajax request or similiar, you need to specify that in your question.
Upvotes: 0
Reputation: 443
If notes
is an arary you can loop over it and display the content in your .erb.html
file as below:
<div>
<% notes.each_with_index do | note, index | %>
<div id="title">
<%= note[:title] %>
</div>
<% end %>
</div>
Upvotes: 2