I would like to send the controller instance variable to the partial.
Click on the timeline of the post and click
I created a view so that a modal window like Twitter appears.
view displayed in the modal window クリック Clicked post
If you use one view file, the code will be hard to read, so I put a partial one.
However, the view file with that partial is also partial, so no variables are passed.
As a result, the modal window will no longer display any information about micropost such as the contents...
[microposts/_micropost.html.erb]
[microposts/_modal.html.erb]
】Partial flow br
index.html.erb→_user_index.html.erb→_micropost.html.erb→_modal.html.erb
< _micropost.html.erb has been successfully sent...
I think so.
[page#index]
@user=User.find_by (id:current_user.id)
@microposts=current_user.feed.includes(:comments,:calls,:insists,:says)
@ micropost=current_user.microposts.build
[_user_index.html.erb]
<span class="index-microposts">%=render partial:'microposts/micropost', collection:@microposts,micropost:@micropost%></span>
[_micropost.html.erb]
<%=render'microposts/modal', microposts:@microposts, microposts:@micropost%>
[_modal.html.erb]
<%=simple_format("#{markdown(micropost.content)}")%>
If you don't mind, please tell me how to send the variables.
In the first place, please let me know if you point out that there are too many partials.
multi-post Teratale
ruby-on-rails bootstrap
How about changing from @micropost
to micropost
as follows?
<%=render'microposts/modal', microposts:@microposts, microposts:micropost%>
© 2024 OneMinuteCode. All rights reserved.