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 ?
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 ?
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>
.html.erb file has access to notes?notes variable is in JS (.js) file or in ruby (.rb) file? If it is ruby file, you can proceed as @Viktor suggested, create an instance variable in your controller and use it in your view.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.