Sorry for a simple question but i am a bit confused trying to follow ruby on rails tutorial book
I am at the chapter 10 and confused, yes i trick a bit my version for learning purpose
So I have a controller called customer
customers_controller.rb
def show
@customer = Customer.find(params[:id])
@posts = @customer.posts
end
I then have the following folder
_post.html.erb
Welcome to a post
Which his called from the show customer file has follow
/view/customer/show.html.erb
<% provide(:title, @customer.name) %>
<aside class="customer_show_nav">
<h1><%= @customer.name %></h1>
<%= @customer.email %>
</aside>
<div class="events">
<%= render @posts %>
</div>
But when loading nothing his appearing not even Welcome to a post. What i am doing wrong?
Thanks in advance. I am following the tutorial http://ruby.railstutorial.org/chapters/user-microposts#top 10.22
if
_post.html.erbis inview/customersyou do this in
view/customers/show.html.erb<%= render 'controller_where_post_lives/post' %>which will look forcustomers/_post.html.erbSometimes, you also need
=in<%= %>with rails 3Also, show is used to show one item, and index is used to show all items.
So to render you will do
Edit:
When you call render you give it the view, no objects here. Unless like above passing a collection.
http://guides.rubyonrails.org/layouts_and_rendering.html
Also if you just want to render text you can do
render :text => "OK"