Rails, pass a path variable to a partial
partial-views, ruby-on-rails
Solution
I don't know is this is your error, but it seems to me that `game_path` expects a game object as argument, that might be your error.
EDIT:
<% @games.each do |item| %>
<section>
<%= render partial: 'application/item_synopsis_builder', locals:{item: item, path: game_path(item) %>
</section>
<% end %>
Problem
I 'm building a partial that will be use by different views (games and promotions). I've created a partial in view/application ``` <%= content_tag :article, class: ['article'] do %> <a href="#"> <%= image_tag item.thumbnail %> </a> <h2><%= item.name %></h2> <p><%= item.description %></p> <p> <%= link_to 'Read more', "#" %> </p> <% end %> ``` and I call it from the view games view (or promotions): ``` <% @games.each do |item| %> <section> <%= render 'application/item_synopsis_builder', item: item %> </section> <% end %> ``` It works fine to populate and render the partial, but i can't suss out how to pass to the partial the view_path so that it is dynamically replace the temporary # with <%= the_right_path =>. I tried to do: ``` <%= render partial: 'application/item_synopsis_builder', locals: {item: item, path: game_path } %> ``` But I just get an error message: ``` No route matches {:action=>"show", :controller=>"games"} ``` But if I render the partial with href="#", it renders fine. I also tried my luck with `href="<%= "#{item}_path" %>"` but it just print out the ref of the object item. Cheers