I have a location model and a post model. I want to allow the user to create new posts on the index page of the location model. How can I do it? I tried to make post new.html.erb partial in location index.html.erb , but this leads to errors since post new.html.erb refers to the @post variable.
location
post
posts
index
new.html.erb
index.html.erb
@post
How to do it?
Try something like this
LocationController def index @location = Location.find(:all) @post = Post.new end
Now ur will have access to @post instance @post . Partial use of this
render :partial => 'posts/post', :object => @post
You can run the form as follows:
<%= form_for Post.new do ... %>
Just create the @post variable in your action in the LocationsController.
Source: https://habr.com/ru/post/895853/More articles:CodePage error while importing data from Oracle to SQL Server using SSIS - oracleCan PHP issue multiple processed mysql queries in Apache environment? - phpHow to check in NAnt script whether property is set or not? - xmlPayPal Integration - htmljQGrid hidden column column - pluginsHow to hide / show UIimageview? - objective-cWCF BasicHttpBinding - Where can I find SOAP1.1 in WSDL - soapCan I embed Arial Narrow in a webpage for free using @ font-face? - fontshttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/895857/add-you-might-be-interested-in-products-to-transactional-emails-in-magento&usg=ALkJrhhCTjpwHazBmgO-eAbWMj81imqd0AWhat fonts are included (i.e. installed by default), with which operating systems? - cssAll Articles