I am working on a rails application and I have a Dashboard::user(dashboard/user) controller and I would like for users to update their blog post through the backend of the site. That works fine but when I am trying to get a list of the latest blog post a user has created I get an error.
dashboard/users_controller
def content
@blog = Blog.new
render ('content')
end
dashboard/blogs/_blog_list.html.erb
<%= div_for(:dashboard ,blog) do %>
<%= link_to image_tag(blog.preview.url(:thumb)), dashboard_blog_path(blog) %>
<h1><%= link_to (blog.title),dashboard_blog_path(blog) %></h1>
<p><%= truncate blog.excerpt, length: 160 %></p>
<%= blog.published_at %>
<%= blog.site_id %>
<% end %>
controller
def content
@site = Site.find_by_subdomain!(request.subdomain)
@blogs = @site.blogs.all
@blog = Blog.new
render ('content')
end
content.html.erb
<%= render :partial => 'dashboard/blogs/blog_list', :locals => {:blogs => @blog} %>
Any reason why this is not working?
My best guess is that the local variable
blogwas never set.@blogwill be available in the partial, butblogwill only be available if it is explicitly set, for example if the partial is rendered viaSee http://apidock.com/rails/ActionView/Partials for more details about partials.