I am new to Sinatra and I am trying to access data from a partial database.
Here is a partial example that I want on the page:
<% @articles.each do |article| %> <ul> <li> <%= article.articleName %> </li> </ul> <% end %>
It works fine if I just set up a route, for example
get '/articles' do @article = Articles.all erb :articles end
and the / articles page with something like
<% @articles.each do |article| %> <article> <p> <%= article.articleName %> </p> <p> <%= article.articleBody %> </p> </article> <% end %>
However, it looks like this code works if I put it in partial.
Any help would be greatly appreciated. I am sure that I am missing something simple.
source share